Reputation: 3155
I am trying to generate an :after pseudo element when mouse hover over. For example:
.email{
width:100px;
overflow:hidden;
text-overflow:ellipsis;
}
.email:hover:after{
content:"the current email address"; /*how I get the content?*/
position: absolute;
background-color:white;
}
Please check http://jsfiddle.net/R4YRN/2/ for full example.
Is there anyway to achieve what I want without javascript? Thanks.
Upvotes: 0
Views: 59
Reputation: 64164
One posibility is to set the email in a data attribute, and then retrieve it:
HTML
<div class="email" data-email="[email protected]">[email protected]</div>
<div>other stuff</div>
CSS
.email{
width:100px;
overflow:hidden;
text-overflow:ellipsis;
}
.email:hover:after{
content: attr(data-email);
position: absolute;
background-color:yellow;
border: solid 1px black;
}
Upvotes: 3
Reputation: 386
Can you check if this will do: jsFiddle
I added the following:
.email:hover{
height: auto; white-space: normal; z-index: 1; text-overflow: none; overflow: none;
width: auto;
}
Your email DIV will contain the email address.
Upvotes: 0
Reputation: 113
This is working like intended? if you want it behind it. you need to float or display inline it.
.email:hover .email:after {}
Upvotes: 0