四列布局未调整为屏幕尺寸
Four Column Layout Not Resizing to Screen Size
我正在尝试向我的网站添加页脚。我使用了 W3schools 四列布局:linked here。当我尝试添加调整大小时它不起作用。我试图将它从影响宽度更改为颜色,并且成功了,所以我知道识别屏幕尺寸或任何具有不正确 class/id 名称的东西都不是问题。
.footer {
padding-top: 10px;
padding-bottom: 10px;
width: 100%;
background-color: #1F363D;
text-align: center;
color: white;
}
.footer-column {
float: left;
width: 20%;
height: 100%;
}
@media screen and (max-width: 600px) {
.footer-column {
width: 100%;
}
}
.footer a:link {
color: white;
font-size: 12px;
}
.footer a:visited {
color: white;
}
.footer a:hover {
color: white;
}
.footer a:active {
color: white;
}
<div class="footer">
<div style="width:100%; display: flex; justify-content: space-evenly; align-text: center; font-size: 13px;">
<div class="footer-column">
<p style="font-size: 15px;">Pages</p>
<a href="/index.html">Home</a><br>
<a href="/projects.html">Projects</a><br>
<a href="/contact.html">Contact</a><br>
<a href="/about.html">About</a>
</div>
<div class="footer-column">
<p>Projects</p>
<a href="/projects/mastermind.html">Mastermind</a><br>
<a href="/projects/simon.html">Simon</a><br>
<a href="/projects/trivia.html">Trivia</a><br>
</div>
<div class="footer-column">
<p>Column 3</p>
</div>
<div class="footer-column">
<p>Column 4</p>
</div>
</div>
<p style="color: white; text-align: center; font-family: monospace;">© 2022 Jake Poyer</p>
</div>
删除具有内联样式的第二个父项并将 flex
设置到主父项 .footer
上。然后使用媒体查询将 .footer-column
宽度设置为 100%
,您还可以指示浏览器在同一断点处从默认 flex-row
更改为 flex-direction: column;
,以便它使用全部可用 space.
.footer {
padding-top: 10px;
padding-bottom: 10px;
width: 100%;
background-color: #1F363D;
text-align: center;
color: white;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.footer-column {
width: calc(100%/4);
height: 100%;
}
@media screen and (max-width: 600px) {
.footer-column {
width: 100%;
}
.footer {
flex-direction: column;
}
}
.footer a:link {
color: white;
font-size: 12px;
}
.footer a:visited {
color: white;
}
.footer a:hover {
color: white;
}
.footer a:active {
color: white;
}
<div class="footer">
<div class="footer-column">
<p style="font-size: 15px;">Pages</p>
<a href="/index.html">Home</a><br>
<a href="/projects.html">Projects</a><br>
<a href="/contact.html">Contact</a><br>
<a href="/about.html">About</a>
</div>
<div class="footer-column">
<p>Projects</p>
<a href="/projects/mastermind.html">Mastermind</a><br>
<a href="/projects/simon.html">Simon</a><br>
<a href="/projects/trivia.html">Trivia</a><br>
</div>
<div class="footer-column">
<p>Column 3</p>
</div>
<div class="footer-column">
<p>Column 4</p>
</div>
<p style="color: white; text-align: center; font-family: monospace; width: 100%;">© 2022 Jake Poyer</p>
</div>
将 flex-wrap: wrap
添加到 div 和 display: flex
。也不需要 float: left
for .footer-column
:
.footer {
padding-top: 10px;
padding-bottom: 10px;
width: 100%;
background-color: #1F363D;
text-align: center;
color: white;
}
.footer-column {
width: 20%;
height: 100%;
}
@media screen and (max-width: 600px) {
.footer-column {
width: 100%;
}
}
.footer a:link {
color: white;
font-size: 12px;
}
.footer a:visited {
color: white;
}
.footer a:hover {
color: white;
}
.footer a:active {
color: white;
}
<div class="footer">
<div style="width:100%; display: flex; flex-wrap: wrap; justify-content: space-evenly; align-text: center; font-size: 13px;">
<div class="footer-column">
<p style="font-size: 15px;">Pages</p>
<a href="/index.html">Home</a><br>
<a href="/projects.html">Projects</a><br>
<a href="/contact.html">Contact</a><br>
<a href="/about.html">About</a>
</div>
<div class="footer-column">
<p>Projects</p>
<a href="/projects/mastermind.html">Mastermind</a><br>
<a href="/projects/simon.html">Simon</a><br>
<a href="/projects/trivia.html">Trivia</a><br>
</div>
<div class="footer-column">
<p>Column 3</p>
</div>
<div class="footer-column">
<p>Column 4</p>
</div>
</div>
<p style="color: white; text-align: center; font-family: monospace;">© 2022 Jake Poyer</p>
</div>
我正在尝试向我的网站添加页脚。我使用了 W3schools 四列布局:linked here。当我尝试添加调整大小时它不起作用。我试图将它从影响宽度更改为颜色,并且成功了,所以我知道识别屏幕尺寸或任何具有不正确 class/id 名称的东西都不是问题。
.footer {
padding-top: 10px;
padding-bottom: 10px;
width: 100%;
background-color: #1F363D;
text-align: center;
color: white;
}
.footer-column {
float: left;
width: 20%;
height: 100%;
}
@media screen and (max-width: 600px) {
.footer-column {
width: 100%;
}
}
.footer a:link {
color: white;
font-size: 12px;
}
.footer a:visited {
color: white;
}
.footer a:hover {
color: white;
}
.footer a:active {
color: white;
}
<div class="footer">
<div style="width:100%; display: flex; justify-content: space-evenly; align-text: center; font-size: 13px;">
<div class="footer-column">
<p style="font-size: 15px;">Pages</p>
<a href="/index.html">Home</a><br>
<a href="/projects.html">Projects</a><br>
<a href="/contact.html">Contact</a><br>
<a href="/about.html">About</a>
</div>
<div class="footer-column">
<p>Projects</p>
<a href="/projects/mastermind.html">Mastermind</a><br>
<a href="/projects/simon.html">Simon</a><br>
<a href="/projects/trivia.html">Trivia</a><br>
</div>
<div class="footer-column">
<p>Column 3</p>
</div>
<div class="footer-column">
<p>Column 4</p>
</div>
</div>
<p style="color: white; text-align: center; font-family: monospace;">© 2022 Jake Poyer</p>
</div>
删除具有内联样式的第二个父项并将 flex
设置到主父项 .footer
上。然后使用媒体查询将 .footer-column
宽度设置为 100%
,您还可以指示浏览器在同一断点处从默认 flex-row
更改为 flex-direction: column;
,以便它使用全部可用 space.
.footer {
padding-top: 10px;
padding-bottom: 10px;
width: 100%;
background-color: #1F363D;
text-align: center;
color: white;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.footer-column {
width: calc(100%/4);
height: 100%;
}
@media screen and (max-width: 600px) {
.footer-column {
width: 100%;
}
.footer {
flex-direction: column;
}
}
.footer a:link {
color: white;
font-size: 12px;
}
.footer a:visited {
color: white;
}
.footer a:hover {
color: white;
}
.footer a:active {
color: white;
}
<div class="footer">
<div class="footer-column">
<p style="font-size: 15px;">Pages</p>
<a href="/index.html">Home</a><br>
<a href="/projects.html">Projects</a><br>
<a href="/contact.html">Contact</a><br>
<a href="/about.html">About</a>
</div>
<div class="footer-column">
<p>Projects</p>
<a href="/projects/mastermind.html">Mastermind</a><br>
<a href="/projects/simon.html">Simon</a><br>
<a href="/projects/trivia.html">Trivia</a><br>
</div>
<div class="footer-column">
<p>Column 3</p>
</div>
<div class="footer-column">
<p>Column 4</p>
</div>
<p style="color: white; text-align: center; font-family: monospace; width: 100%;">© 2022 Jake Poyer</p>
</div>
将 flex-wrap: wrap
添加到 div 和 display: flex
。也不需要 float: left
for .footer-column
:
.footer {
padding-top: 10px;
padding-bottom: 10px;
width: 100%;
background-color: #1F363D;
text-align: center;
color: white;
}
.footer-column {
width: 20%;
height: 100%;
}
@media screen and (max-width: 600px) {
.footer-column {
width: 100%;
}
}
.footer a:link {
color: white;
font-size: 12px;
}
.footer a:visited {
color: white;
}
.footer a:hover {
color: white;
}
.footer a:active {
color: white;
}
<div class="footer">
<div style="width:100%; display: flex; flex-wrap: wrap; justify-content: space-evenly; align-text: center; font-size: 13px;">
<div class="footer-column">
<p style="font-size: 15px;">Pages</p>
<a href="/index.html">Home</a><br>
<a href="/projects.html">Projects</a><br>
<a href="/contact.html">Contact</a><br>
<a href="/about.html">About</a>
</div>
<div class="footer-column">
<p>Projects</p>
<a href="/projects/mastermind.html">Mastermind</a><br>
<a href="/projects/simon.html">Simon</a><br>
<a href="/projects/trivia.html">Trivia</a><br>
</div>
<div class="footer-column">
<p>Column 3</p>
</div>
<div class="footer-column">
<p>Column 4</p>
</div>
</div>
<p style="color: white; text-align: center; font-family: monospace;">© 2022 Jake Poyer</p>
</div>