Identical CSS behaves differently when applied to either body or a div
Posted
by
Razor
on Stack Overflow
See other posts from Stack Overflow
or by Razor
Published on 2014-05-27T20:23:47Z
Indexed on
2014/05/29
21:28 UTC
Read the original article
Hit count: 198
css
Using a DIV as container
<div class="container">
<div class="half-hidden"></div>
</div>
CSS
.container {
margin: 20px auto 0;
width: 200px;
height: 200px;
border: 1px solid red;
position: relative;
overflow: hidden;
}
.half-hidden {
position: absolute;
top: 10px;
bottom: 10px;
left: -50px;
width: 100px;
border: 1px solid teal;
}
Using body as container
<div class="half-hidden"></div>
CSS
Replace the above .container
with body
Why?
© Stack Overflow or respective owner