html - 如何使用 HTML 和 CSS 正确设置网页页脚部分的文本对齐格式
问题描述
我正在尝试格式化网页的页脚部分,以便地址及其相应信息与联系信息平行。基本上,所有地址信息都在左侧,联系信息在右侧,并且理想情况下统一对齐。我尝试更改一些参数并添加参数以尝试更正格式。
这是我得到的输出。
关于如何纠正这个问题的任何建议?这是上下文的代码。
HTML
<!DOCTYPE html>
<html>
<div class="footer-row">
<div class="footer-left">
<h1>Address</h1>
<p><strong>Name of place</strong><br>
<em>at the intersection of such and such</em><br>
111 address st <br>
City Name, State 12345 <br>
</p>
</div>
<div class="footer-right"></div>
<h1>Contact</h1>
<p>
111-222-3333 <br>
email@email.com<br>
</p>
</div>
</div>
</html>
CSS
.footer-row{
width: 80%;
margin: 0 auto;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.footer-left,.footer-right{
flex-basis: 45%;
padding: 10px;
margin-bottom:20px;
}
.footer-right{
text-align: right;
}
.footer-row h1{
margin: 10px 0;
}
.footer-row p{
line-height: 25px;
}
解决方案
添加flex-direction: column
; 并删除 div 结束标签
<div class="footer-right"></div>
.footer-row{
width: 80%;
margin: 0 auto;
display: flex;
justify-content: space-between;
flex-direction: row;
}
.footer-left,.footer-right{
flex-basis: 45%;
padding: 10px;
margin-bottom:20px;
}
.footer-right{
text-align: right;
}
.footer-row h1{
margin: 10px 0;
}
.footer-row p{
line-height: 25px;
}
<div class="footer-row">
<div class="footer-left">
<h1>Address</h1>
<p><strong>Name of place</strong><br>
<em>at the intersection of such and such</em><br>
111 address st <br>
City Name, State 12345 <br>
</p>
</div>
<div class="footer-right">
<h1>Contact</h1>
<p>
111-222-3333 <br>
email@email.com<br>
</p>
</div>
</div>
推荐阅读
- typescript - 我想在 angular 对象中添加一个新方法,但我使用@types/angular,如何扩展 angular.d.ts?
- excel - 在 Excel 中制作唯一的动态列表
- c++ - 在动态库中使用 Poco::JSON::Object 时堆栈粉碎
- php - 为 WHERE 条件选择相等数量的记录
- python - 在 Windows 上安装 Python RAWPY 包的问题
- php - 以这样的方式排列记录,D 类别总是在前,然后是 E & F,它将按照 1:1 的比例排列
- android - 为什么我的应用无法与 firebase 成功同步
- angular - 以热图比例显示值(以单位为单位)(泳道/ngx 图表)
- google-apps-script - 称为值的边框和排序公式
- java - 记录器的 Junit 测试用例