I have made a fiddle for reference: http://jsfiddle.net/kLFn9/
The overflow:hidden
in question is highlighted.
Basically, i\'m using :hover:af
You can use margin-top
and padding-top
.
padding-top
will extend your parent area, but a negative margin-top
will keep it in the expected position.
It will look like you're escaping the overflow, but in fact you're not.
div {
width:500px;
height:200px;
background:red;
margin: 50px;
overflow: hidden; /* this rule */
background-clip: content-box; /*use this to constrain the background color within the content-box and do not paint the padding */
padding-top: 200px; /* space required to display the tooltip */
margin-top: -150px; /*200px - 50px of the original margin*/
}
span {
background: blue;
color: white;
position: relative;
top:100px;
display:block;
width: 100px;
margin: auto;
}
span:hover:after {
content: attr(data-name);
color: black;
position: absolute;
top: -150px;;
left: 0;
}
hover
This may introduce pointer events problems, but you can fix them using pointer-events
then.