【发布时间】:2020-07-30 05:29:32
【问题描述】:
我将 div 按我想要的方式对齐,但中间 div 中的内容与页脚 div 的内容重叠。关于如何让中间 div 中的内容增加高度以使其不会与下面的 div 重叠的任何建议?
当 div 垂直对齐时,是否有办法永久防止它们与上方和下方的 div 重叠或重叠?
我正在为一个非常小的屏幕(Galaxy Fold)设计这个,我计划随着过程的继续扩大规模。
body {
font-family: Helvetica,Arial,sans-serif; /* styles the font of the entire page */
margin: 0px; /* removes the margin from around the page */
text-transform: capitalize; /* capitalizes the text on the page */
}
li {
display: inline; /* makes the links lay horizontally */
list-style-type: none; /* removes the markers for the list items behind the links */
}
#nav, #main, #footer {
width: 100%;
position: absolute; /* fixes the <div> elements to the page */
}
#nav {
background-color: #393e46;
padding-bottom: 16px; /* adds extra padding underneath the search bar */
top: 0px;
right: 0px;
left: 0px;
}
#nav-container {
margin: 0 auto; /* centers the 'nav-container' within the <nav> */
max-width: 200px;
}
#rowA {
background-color: red;
}
.nav-menu {
margin-top: 0px; /* removes the extra margin above the links in the nav */
}
#rowB {
background-color: green;
}
#nav-logo {
font-size: 32px;
text-align: center; /* centers the 'FGCPEDIA' logo */
}
#rowC {background-color: pink;}
.nav-menu {
float: right; /* makes the 'Sign Up/ Log In' links float to the right */
}
/* removes the highlight from the form when selected */
input:focus, textarea:focus {
outline: 0;
}
#main {
background-color: orange;
top: 26.4%; /* pushes the main directly under the nav */
/* top: 32.9%; */
}
#main-container {
margin: 0 auto; /* centers the elements in the main */
max-width: 100px;
}
#footer {
background-color: #222831;
right: 0px;
bottom: 0px;
left: 0px;
}
#footer-container {
margin: 0 auto;
max-width: 200px;
}
.footer-row {
padding-inline-start: 0px; /* removes the extra padding on the left side of links */
}
#copyright {
color:#eeeeee; /* colors the footer text */
font-size: 13px; /* the font size of the copyright text is '13' */
text-align: center; /* centers the */
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<!-- <link href="../../css/stylesheet2.css" rel="stylesheet"> -->
<link href="stylesheet2.css" rel="stylesheet">
</head>
<body>
<nav id="nav">
<div id="nav-container">
<!-- nav-row-1 -->
<div id="rowA">
<ul class="nav-menu">
<li>
<a href="">Sign Up</a>
</li>
<li>
<a href="">Log In</a>
</li>
</ul>
</div>
<!-- nav-row-1 -->
<div id="rowB">
<h3 id="nav-logo">DICTIONARY</h3>
</div>
<!-- nav-row-1 -->
<div id="rowC">
<form action="" method="get">
<input id="nav-search-bar" type="search" placeholder="Search">
</form>
</div>
</div>
</nav>
<!-- main section -->
<main id="main">
<div id="main-container">
<!-- header -->
<div id="btd-masthead">
<h2>Browse the Dictionary</h2>
</div>
<hr>
<!-- btd links -->
<div id="btd-links">
<div id="btd-links-1">
<a href="a.html">a</a>
<a href="b.html">b</a>
<a href="c.html">c</a>
<a href="d.html">d</a>
<a href="e.html">e</a>
<a href="f.html">f</a>
<a href="g.html">g</a>
<a href="h.html">h</a>
<a href="i.html">i</a>
<a href="j.html">j</a>
<a href="k.html">k</a>
<a href="l.html">l</a>
<a href="m.html">m</a>
<a href="n.html">n</a>
<a href="o.html">o</a>
<a href="p.html">p</a>
<a href="q.html">q</a>
<a href="r.html">r</a>
<a href="s.html">s</a>
<a href="t.html">t</a>
<a href="u.html">u</a>
<a href="v.html">v</a>
<a href="w.html">w</a>
<a href="x.html">x</a>
<a href="y.html">y</a>
<a href="z.html">z</a>
</div>
</div>
<hr>
<div>
</div>
<!-- terms list row -->
<div id="terms-container">
<!-- column 1 -->
<div class="terms-col">
<a href="">Abare</a>
<a href="../terms/a/adaptation.html">Adaptation</a>
<a href="../terms/a/air_dash.html">Air Dash</a>
<a href="">Air Throw</a>
<a href="../terms/a/air_to_air.html">Air-to-Air</a>
<a href="../terms/a/anti_air.html">Anti-Air</a>
<a href="../terms/a/armor.html">Armor</a>
<a href="">Assist</a>
<a href="../terms/a/auto_correct.html">Auto Correct</a>
</div>
</div>
</div>
</main>
<!-- the footer stays the same on every page -->
<footer id="footer">
<div id="footer-container">
<!-- row 1 -->
<ul class="footer-row">
<li>
<a href="a.html" style="text-transform: none;">Browse the Dictionary:</a>
</li>
<li>
<a href="a.html">a</a>
</li>
<li>
<a href="b.html">b</a>
</li>
<li>
<a href="c.html">c</a>
</li>
<li>
<a href="d.html">d</a>
</li>
<li>
<a href="e.html">e</a>
</li>
<li>
<a href="f.html">f</a>
</li>
<li>
<a href="g.html">g</a>
</li>
<li>
<a href="h.html">h</a>
</li>
<li>
<a href="i.html">i</a>
</li>
<li>
<a href="j.html">j</a>
</li>
<li>
<a href="k.html">k</a>
</li>
<li>
<a href="l.html">l</a>
</li>
<li>
<a href="m.html">m</a>
</li>
<li>
<a href="n.html">n</a>
</li>
<li>
<a href="o.html">o</a>
</li>
<li>
<a href="p.html">p</a>
</li>
<li>
<a href="q.html">q</a>
</li>
<li>
<a href="r.html">r</a>
</li>
<li>
<a href="s.html">s</a>
</li>
<li>
<a href="t.html">t</a>
</li>
<li>
<a href="u.html">u</a>
</li>
<li>
<a href="v.html">v</a>
</li>
<li>
<a href="w.html">w</a>
</li>
<li>
<a href="x.html">x</a>
</li>
<li>
<a href="y.html">y</a>
</li>
<li>
<a href="z.html">z</a>
</li>
</ul>
<!-- row 2 -->
<ul class="footer-row">
<li>
<a href="../../index.html">home</a>
</li>
<li>
<a href="../about_us.html">About Us</a>
</li>
<li>
<a href="../contact_us.html">Contact Us</a>
</li>
<li>
<a href="../disclaimer.html">Disclaimer</a>
</li>
</ul>
<!-- row 3 -->
<div class="footer-row">
<p id="copyright">© 2020 copyright</p>
</div>
</div>
</footer>
<script src="js/script.js"></script>
</body>
</html>
【问题讨论】: