固定位置响应

时间:2015-01-13 23:51:50

标签: html css

现在,当调整页面大小时,它会继续向右滚动页面。我希望它在调整大小时保持不变。我把它放在一个codepen中,这样会更容易理解。出于某种原因,包含p标签的div不会像固定的那样起作用,而是让p标签保持对页面大小的响应。

http://codepen.io/anon/pen/XJMJWp

<div id = "contents">
<div class = "add" align = "center">
<p id = "entry" style = "position: fixed;margin-left:1163px;margin-top:415px;">One</p>
</div>
</div>

CSS

#contents .add{
width: 1600px;
height: 750px;
margin: auto; position: fixed; top: 0; left:0; bottom:0; right:0;
font-family: "Cedarville Cursive","Lato";
}

#contents{
width: 1600px;
height: 750px;
margin: auto; position: absolute; top: 0; left:0; bottom:0; right:0;
font-family: "Cedarville Cursive","Lato";
}

1 个答案:

答案 0 :(得分:0)

摆脱margin: auto;这导致#contents .add元素在视口大于1600px时居中。

相关问题