如何在居中时将页脚修复到页面底部?我想不出是为了我的命。
我希望页脚以50%的速度坐在中间的页面底部,但由于某些原因,页边距左和右不能工作。它就坐在左边。
.navigation2 {
padding: 8px;
background-color: #888;
width: 50%;
margin-left: auto;
margin-right: auto;
position: fixed;
bottom: 0px;
}<footer>
<div class="navigation2">
© 2019 - <a href="index.html">X</a>
</div>
</footer>
任何帮助都将不胜感激。
发布于 2019-05-25 02:03:04
你可能只需要一点不同的数学方法。这可能会让你更接近你想要的东西:
CSS:
.navigation2 {
padding: 8px;
background-color:#888;
left: 25%;
right: 25%;
position: fixed;
bottom: 0px;
}另一种方法是更动态的(不管你的脚有多宽都行),并且缩放得更好,这样你的脚就不会在小屏幕上被挤压那么多了:
.navigation2 {
padding: 8px;
background-color:#888;
left: 50%;
transform:translatex(-50%);
position: fixed;
bottom: 0px;
}https://stackoverflow.com/questions/56301110
复制相似问题