http://codepen.io/basickarl/pen/Wrwdam?editors=110
html:
<div class="back">
</div>css:
html,
body {
height: 100%;
}
div.back {
margin-top: 50px;
display: absolute;
width: 30px;
height: 30px;
background-image: url('http://simpleicon.com/wp-content/uploads/arrow-35.png');
background-repeat: no-repeat;
background-position: center;
background-size: contain;
}将显示右侧的滚动条。我必须有html,正文100%,因为我使用粘性页脚。有什么想法吗?
发布于 2015-12-18 22:11:12
body元素在大多数主要浏览器中都有一个默认的margin: 8px;,因此首先必须通过重置body元素的margin属性来删除它
body {
margin: 0;
}然后,不是在主体上使用height: 100%;,而是使用min-height: 100%;,这样当与overflow: hidden;结合使用时,主体也可以超过100%的高度
由于如果未显式设置父高度,则min-height不起作用,因此还必须向html元素添加height属性。
html {
height: 100%;
}
body {
margin: 0;
min-height: 100%;
overflow: hidden;
}此外,display属性上的div.back选择器的值无效。display属性接受inline、inline-block、block、none、flex、inline-flex、grid etc...,而position属性接受D24(每个元素的默认值)、D25、D26或fixed。这不是问题,而是浏览器忽略的东西,因为它不理解它。
div.back {
display: absolute; // <------ remove this line
//... snipped ...
}https://stackoverflow.com/questions/34357434
复制相似问题