gpt4 book ai didi

html - 如何制作固定页脚?

转载 作者:太空宇宙 更新时间:2023-11-04 07:50:42 25 4
gpt4 key购买 nike

  <section>
<div class="main-wrapper">
<div class="upper-div">
<img src="images/pic.jpg" class="img-responsive" alt="">
</div>
<div class="lower-div">
<div class="header">
<p>Header</p>
</div>
<div class="content">
<div class="content-card">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nihil sequi possimus alias numquam sunt perspiciatis sint, molestiae aperiam, rerum, deleniti quos. Repellat tenetur, repudiandae quae odit obcaecati libero magnam vero.</p>
</div>
<div class="content-card">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. A error libero impedit sequi quae blanditiis assumenda, dolores beatae mollitia quas dolor voluptatibus saepe voluptate quod velit id eaque nostrum architecto.</p>
</div>
<div class="content-card">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. A error libero impedit sequi quae blanditiis assumenda, dolores beatae mollitia quas dolor voluptatibus saepe voluptate quod velit id eaque nostrum architecto.</p>
</div>
</div>
<div class="footer">
<p>Footer</p>
</div>
</div>
</div>

How do I pull the footer section to the bottom of the screen??

.main-wrapper{
padding:15px;
}

.header,
.footer{
text-align: center;
}

.header p,
.footer p{
padding:10px;
background-color: green;
color: white;
}

.content{
height: 200px;
overflow: scroll;
}

.content-card{
border-bottom: 1px solid black;
}

我已经尝试将固定位置赋予页脚 div 和底部 0,但随后它离开了 div 并否定了外部主包装器的填充。我该如何修复它,这样我就不必为内容包装器指定特定的高度,内容 div 的高度会适应设备并且页脚固定在底部。?

最佳答案

您必须减小页脚的宽度以使其与页眉相似。

.main-wrapper{
padding:15px;
}

.header,
.footer{
text-align: center;
}

.header p,
.footer p{
padding:10px;
background-color: green;
color: white;
}

.content{
height: 200px;
overflow: scroll;
}

.content-card{
border-bottom: 1px solid black;
}
.footer {
position: fixed;
bottom: 0;
right: 20px;
left: 20px;
width: 93%;
}
 <section>
<div class="main-wrapper">
<div class="upper-div">
<img src="images/pic.jpg" class="img-responsive" alt="">
</div>
<div class="lower-div">
<div class="header">
<p>Header</p>
</div>
<div class="content">
<div class="content-card">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nihil sequi possimus alias numquam sunt perspiciatis sint, molestiae aperiam, rerum, deleniti quos. Repellat tenetur, repudiandae quae odit obcaecati libero magnam vero.</p>
</div>
<div class="content-card">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. A error libero impedit sequi quae blanditiis assumenda, dolores beatae mollitia quas dolor voluptatibus saepe voluptate quod velit id eaque nostrum architecto.</p>
</div>
<div class="content-card">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. A error libero impedit sequi quae blanditiis assumenda, dolores beatae mollitia quas dolor voluptatibus saepe voluptate quod velit id eaque nostrum architecto.</p>
</div>
</div>
<div class="footer">
<p>Footer</p>
</div>
</div>
</div>
</section>

关于html - 如何制作固定页脚?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47785600/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com