I have a div with data-content in it that is used for hover effect. It looks like this:
HTML:
<div data-content="TEXT THAT NEEDS TO BE POSITIONED" class="teamleft">
</div>
Thanks to stackoverflow I found neat css code that uses :after and :hover:after to make hover effect possible. The only thing I can't figure out is positioning and styling the data-content text. I want to vertically center my text. Also, how do I add differently styled text in one data-content? Or maybe I should use two different data-contents?
CSS:
teamleft
{
position: absolute;
width:50%;
height: 100%;
background-color: #25335a;
}
.teamleft:after
{
position: absolute;
width: 100%;
height: 100%;
content: attr(data-content);
color:#fff;
background:rgba(0,0,0,0.6);
opacity:0;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.teamleft:hover:after
{
opacity:1;
}
Thanks in advance!
JSFiddle: https://jsfiddle.net/e8t2gcxg/3/