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

General Discussion

Transition + text.

Hey everybody. So I had a really cool idea for Transitions. Image scrolling over a box that moves as soon as you have you hover your cursor over it. And when it moves Text is revealed under it. I have the transition part down. I just need help with getting text to under it. If anybody can help that would be awesome. Cheers.

Here is Codepen version http://codepen.io/Petarg/pen/yrGzn

The code I have so far: HTML: <html> <title>Web</title> <body> <p>Peter's Web</p> <div class="wrap"> <h1>Computer Skills</h1> <div class="design"></div> </div> </body> </html>

CSS: body { background-color: #4d; } /*p { text-align: center; font-size: 75px; color: black; font-family: sans-serif; } */ .wrap { margin: 0 auto; padding: 15px; width: 1000px; height: 300px; box-shadow: 0 0 20px rgba(0,0,0,.5); } .design { width: 50%; height: 100%; border-radius: 8px; background: #4682b4; transition-duration: 1s; transition-timing-function: cubic-bezier(.5, -.5, .3, 1.3);

} .design:hover { background: #f08080; margin-left: 75%; }

3 Answers

My biggest issue is getting computer skills text to appear under the blue box not above it.

Hi Peter,

Using positioning and z-index is one way you can do this. I made a few additions and changes to your code and forked it.

http://codepen.io/anon/pen/mLFJf

First, if you give the h1 a position of absolute then it will be taken out of the document flow and this will allow the h1 and div.design to overlap each other. However, the h1 appears on top of the blue box.

This is where z-index comes into play. Elements with a higher z-index will appear on top of elements with a lower value. So it's a matter of making sure div.design has a higher z-index than the h1. I used 1 for the h1 and 2 for .design but you can use other numbers too if those are conflicting with other elements on the page.

I also had to set position: relative on .design so that the z-index would take effect. Z-index is ignored unless the element has a positioning context set.

Also, I changed the hover rule so that the box will move all the way across if you hover in the wrap area. This prevents the box from bouncing back and forth as you may have noticed.

I changed this:

.design:hover {
    background: #f08080;
    margin-left: 75%;
}

To this:

.wrap:hover .design {
    background: #f08080;
    margin-left: 50%;
}

Let me know if you have any questions about it.

WOW Damn Jason. Your freakin' great at this. You have no idea how thankful I am for this. It was bothering me the whole day. :) Hopefully one day I can help other people learning to code, just like you helped me today. :)