Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Text over images

Hi guys trying to get some text to display over an image here's the CSS

.inset {
  width: 200px;
  position: absolute;
  left: 450px;
  top: 100px;
}

.main {
  width: 1100px;
  height: 500px;
  background-image: url("../images/main.png");
  background-color: green;
  box-shadow: rgba(0, 0, 0, 0.298039) 0 0 15px;
  position: relative;
  top: 150px;

.inset is the text and .main is the image. What do I need to do to get the text to display over the image?

Thanks in advance.

2 Answers

It depends on your html, if it looks like this, the text should display over the image;

<div class="main"><p class="inset">This is my text</p></div>

Muchos Gracis Justen.... Knew It was relatively simple.

the css z-index is another way to get elements in front of/behind one another