gpt4 book ai didi

html - 如何将“关于”部分放在页眉下方但位于页脚上方?

转载 作者:行者123 更新时间:2023-11-28 03:40:56 24 4
gpt4 key购买 nike

我希望关于部分位于 FIXED 页眉下方和页脚顶部?我正在努力解决这个问题,我试图在顶部添加填充,但我注意到它只是移动内容而不是整个 div。而且相对位置也不能解决问题,因为页脚不在关于部分下面解释对答案将有助于正确理解答案。

body {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
margin: 0;
padding: 0;
line-height: 50px
}

header {
background-color: #191919;
position: fixed;
width: 100%;
color: #edf9ff;
min-height: 70px;
border-bottom: #0fe216 3px solid;
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 20px;
margin-top:0;
}

header a {
text-decoration: none;
text-transform: uppercase;
color: #edf9ff;
}
a:hover {
color:blue;
}

header ul {
margin: 0;
}

header li {
list-style-type: none;
float: left;
padding-right: 20px;
}
#showtime {
position:relative;
top:100px;
width:80%;
margin: 0 auto;
background-color: #f2f2f2;
}
#showtime img {
width:300px;
height:300px;
}
/*Image Repz*/
.showright {
clear:both;
}

.highlight {
font-size:125%;
color:blue;
}
.showright img {
float:right;
clear:both;
}
.boxes:first-child {
padding-top:50px;
}
.boxes:not(:first-child) {
padding-top:100px;

}
.showright > p, .showright > h2 {
text-align: center;
}
.showleft img {
float:left;
clear:both;
}
.showleft > p, .showleft > h2 {
text-align: center;
}
footer {
margin-top:30px;
background-color:#191919;
height: 100px;
display: flex;
align-items: center;
justify-content: center;
clear:both;
}
footer p{
text-align: center;
color: white;
}
<!DOCTYPE html>
<html>
<head>
<title>Photography | Home </title>
<link href="About.css" rel="stylesheet"/>
<script type="application/javascript" src="Home.js"></script>
</head>
<body>

<header>
<div id="branding">
<h2>PHOTOGRAPHY</h2>
</div>
<nav id="links">
<ul>
<li><a href="Home.html">Home</a></li>
<li><a href="About.html">About</a></li>
<li><a href="#">PHOTO GALLERY</a></li>
<li><a href="#">VIDEO GALLERY</a></li>
</ul>
</nav>
</header>
<section id="showtime">
<div class="showleft boxes">
<h2>What are we about?</h2>
<p>In Mukhtar Photography, we specialise in creating a perfect video with the highest quality and we always tend to keep our promise. Whether it is an
Video or not we are <span class="highlight">MASTERS</span> at delivering the best photos
</p>
</div>
<div class="showleft boxes">
<h2>Why should you ask Mukhtar Photography for like: Marriages, videos?</h2>
<p>Because we put our dedication towards and is very unlikely to be any cancels to the project and if there is you will be paid 90% of the money you gave us.
</p>
</div>
</section>

<footer>
<p>Note that any copyright &copy; is reserved</p>
</footer>
</body>
</html>

最佳答案

要确保内容位于标题后面,您可以在 css 中使用“z-index”。要在内容 div 下方安排页脚,您必须使其位置“相对”。要获得内容和页脚之间的间距,您可以向内容 div 添加底部边距。

body {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
margin: 0;
padding: 0;
line-height: 50px
}

header {
background-color: #191919;
position: fixed;
z-index: 4;
width: 100%;
color: #edf9ff;
min-height: 70px;
border-bottom: #0fe216 3px solid;
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 20px;
margin-top:0;
}

header a {
text-decoration: none;
text-transform: uppercase;
color: #edf9ff;
}
a:hover {
color:blue;
}

header ul {
margin: 0;
}

header li {
list-style-type: none;
float: left;
padding-right: 20px;
}
#showtime {
position:relative;
top:100px;
width:80%;
margin: 0 auto;
margin-bottom: 50px;
background-color: #f2f2f2;
}
#showtime img {
width:300px;
height:300px;
}
/*Image Repz*/
.showright {
clear:both;
}

.highlight {
font-size:125%;
color:blue;
}
.showright img {
float:right;
clear:both;
}
.boxes:first-child {
padding-top:50px;
}
.boxes:not(:first-child) {
padding-top:100px;

}
.showright > p, .showright > h2 {
text-align: center;
}
.showleft img {
float:left;
clear:both;
}
.showleft > p, .showleft > h2 {
text-align: center;
}
footer {
position: relative;
margin-top:30px;
background-color:#191919;
height: 100px;
display: flex;
align-items: center;
justify-content: center;
clear:both;
}
footer p{
text-align: center;
color: white;
}
<!DOCTYPE html>
<html>
<head>
<title>Photography | Home </title>
<link href="About.css" rel="stylesheet"/>
<script type="application/javascript" src="Home.js"></script>
</head>
<body>

<header>
<div id="branding">
<h2>PHOTOGRAPHY</h2>
</div>
<nav id="links">
<ul>
<li><a href="Home.html">Home</a></li>
<li><a href="About.html">About</a></li>
<li><a href="#">PHOTO GALLERY</a></li>
<li><a href="#">VIDEO GALLERY</a></li>
</ul>
</nav>
</header>
<section id="showtime">
<div class="showleft boxes">
<h2>What are we about?</h2>
<p>In Mukhtar Photography, we specialise in creating a perfect video with the highest quality and we always tend to keep our promise. Whether it is an
Video or not we are <span class="highlight">MASTERS</span> at delivering the best photos
</p>
</div>
<div class="showleft boxes">
<h2>Why should you ask Mukhtar Photography for like: Marriages, videos?</h2>
<p>Because we put our dedication towards and is very unlikely to be any cancels to the project and if there is you will be paid 90% of the money you gave us.
</p>
</div>
</section>

<footer>
<p>Note that any copyright &copy; is reserved</p>
</footer>
</body>
</html>

关于html - 如何将“关于”部分放在页眉下方但位于页脚上方?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44215623/

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