div (페이지 상단에 있음)에 margin-top: 10px
이있는 경우 절대적으로 위치가 지정된 div (더 높은 z- 인덱스에 있고 해당 div 바깥에있는 및 div의 부모 바깥에)는 top: 0px
이 아니라 10px
에! 왜 이런 일이왜 body 태그의 스타일을 "position : relative"로 지정하면 절대 위치 div 시작이 낮습니까?
입니까? 본문에있는 position: relative
을 제거하기 만하면 모든 것이 수정되지만 (코드에서 다른 것들과 문제가 발생합니다. 상대적으로 몸체를 배치해야합니다).
http://jsfiddle.net/afv3gze7/1/
문제 코드는 :
<!DOCTYPE html>
<html>
<head>
<style>
html
{
position: relative;
min-width: 100%;
height: 100%;
min-height:100%;
}
body
{
min-width: 100%;
min-height:100%;
font-size: 100%;
}
.outer
{
position: relative;
top: 0em;
left: 0em;
width: 100%;
height: 100%;
background-color: #ffffff;
}
.overlay
{
position: absolute;
top: 0px;
left: 0em;
width: 100%;
height: 100%;
background-color: #000000;
-moz-opacity: 0.50;
-khtml-opacity: 0.50;
-webkit-opacity: 0.50;
opacity: 0.50;
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha"(Opacity=50);
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=50);
filter:alpha(opacity=50);
z-index: 6;
display: none;
}
.inner
{
position: relative;
width: 100%;
border: none;
margin: 0em;
padding: 0em;
margin-top: 3.875em;
overflow: hidden;
z-index: 0;
}
</style>
</head>
<body>
<div class="outer">
<div class="inner">s</div>
</div>
<div class="overlay" style="display: block;"></div>
</body>
</html>
절대적으로 위치한 요소는 가장 가까운 위치에있는 조상에 대해 배치되기 때문에. – j08691
그러나 @ j08691 가장 가까운 위치에있는 조상은 본문입니다. –
[Top : 0 \'이 본문에 상대적인 절대 위치에있는 요소에서 작동하지 않는 이유는 무엇입니까?] (http://stackoverflow.com/questions/33594788/why-doesnt-top-0-work-on - 신체에 관련된 절대적으로 위치 된 요소) –