Darren
Darren

Reputation: 177

:hover targeting not working exactly the way I want it to

if you hover over a project some text will appear, but if you mouse over the text it kills the hover style because that's not what triggers the hover.

p.description {
    position:absolute;
    top:50%;
    left:50%;
    margin: 40px 0 0 -125px; /*offset 50px from center*/
    transform: translateY(-50%); /*vertically centered*/
    width:250px;
    height:80px;
    z-index:1000;
    color: #ffffff;
    opacity: 0;
}
.holder:hover p.description {
    margin-top: 0; /*makes me slide up*/
    opacity:1;
    visibility:visible;
    -moz-transition: all .2s ease-in;
    -o-transition: all .2s ease-in;
    -webkit-transition: all .2s ease-in;
    transition: all .2s ease-in;
}
p.description span {
    font-family: 'aileronbold';
    font-size: 110%;
}

This is my css for trying to accomplish this. I am not sure how to re-target to achieve this. Everything works as I want it minus when you mouse over the text.

You can check this at: http://darrenbachan.com/

Upvotes: 1

Views: 84

Answers (4)

Bian Jiaping
Bian Jiaping

Reputation: 966

Change

.holder a:hover {
   opacity:0;
}

To

.holder:hover a {
   opacity:0;
}

The key point is to prefix all hover style's selector with .holder:hover.

Upvotes: 0

Josh Crozier
Josh Crozier

Reputation: 240888

Change the selector from .holder a:hover to .holder:hover a. You were seeing this flicker issue because the transition would end when you hover over the p description element that would transition in. By moving the :hover pseudo class to the parent element, the transition will remain intact even when you aren't hovering over the a element:

.holder:hover a {
    opacity: 0;
    -moz-transition: all .2s ease-in;
    -o-transition: all .2s ease-in;
    -webkit-transition: all .2s ease-in;
    transition: all .2s ease-in;
}

In order for the anchor element to be positioned over the p description element, you could absolutely position it relative to .holder (since it's relatively positioned).

.holder a {
    position: absolute;
    z-index: 10;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

Then remove z-index: 1000 from p.description.

Upvotes: 1

Quelklef
Quelklef

Reputation: 2147

Change

.holder:hover p.description

to

.holder:hover p.description, p.description:hover

A little bit of a hack, but it'll work.

P.S. Love the site! Very pretty.

Upvotes: 1

Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

Reputation: 167172

It is a z-index issue:

z-index: 9999; /* Or anything more than 1000 */

Give the above z-index to .grow:

.grow {
    z-index: 9999;
}

And just because you are using transition, that jerk happens. Guess there's no way.

Upvotes: 1

Related Questions