Bootstrap 页脚列未对齐
Posted
技术标签:
【中文标题】Bootstrap 页脚列未对齐【英文标题】:Bootstrap Footer columns not aligning 【发布时间】:2018-10-31 23:57:42 【问题描述】:我正在尝试使用col-sm-3
使每个标题在各自的列中对齐,但是我似乎没有任何运气。
这是一个类似于显示我要实现的目标的页脚图像:
.footer
margin-top: 100px;
margin-bottom: 100px;
background-color: #34495e;
.footer-title h6
font-family: 'Open sans', sans-serif;
color: #ffffff;
a:hover a:link
text-decoration: none;
<!doctype html>
<html lang="en">
<head>
<title>Home </title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="shortcut icon" href="img/favicon_head.ico" />
<!-- Google fonts-->
<link href="https://fonts.googleapis.com/css?family=Lato|Open+Sans" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<!--NAVIGATION-->
<div class="container-bg-signup">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="signup">
<div class="signup text-center">
<h4>JOIN OUR MAILING LIST!</h4>
<div class="input-group justify-content-center">
<input type="email" id="myEmail" value="enter your email">
<button onclick="myFunction()" class="btn btn-light-orange btn-sign">SUBSCRIBE</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<footer class="container-fluid footer">
<div class="row">
<div class="col-sm-3">
<div class="footer">
<div id="cat-1">
<h6 class="footer-title">About
<h6>
<ul>
<a href="###">
<li>About Company</li><a/>
<a href="###">
<li>Vison & Mission</li><a/>
<a href="###">
<li>Parnters</li><a/>
<a href="###">
<li>Policy</li><a/>
</ul>
</div>
</div>
<div class="col-sm-3">
<div id="cat-2">
<h6 class="footer-title">Useful Links</h6>
<ul>
<a href="###">
<li>Help</li> <a/>
<a href="###">
<li>testimonials</li><a/>
<a href="###">
<li>Store Location</li><a/>
<a href="###">
<li>Trade Account</li><a/>
<a href="###">
<li>Site Map</li><a/>
</ul>
</div>
</div>
<div class="col-sm-3">
<div id="cat-3">
<h6 class="footer-title">Customers</h6>
<ul>
<a href="###">
<li>Our Prices</li><a/>
<a href="###">
<li>Returns</li><a/>
<a href="###">
<li>Sizes</li><a/>
<a href="###">
<li>Regster</li><a/>
</ul>
</div>
</div>
<div class="col-sm-3">
<div id="cat-4">
<h6 class="footer-title">Documentation</h6>
<ul>
<a href="###">
<li>RISQS Certificate</li><a/>
<a href="###">
<li>Insurance</li><a/>
<a href="###">
<li>Libray</li><a/>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</footer>
<!-- Optional javascript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.4.5/js/mdb.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
小提琴:https://jsfiddle.net/WebiSS/tbo2h5cy/
【问题讨论】:
【参考方案1】:如果我正确理解了您的问题,并且您希望页脚标记中的所有四个 col-sm-3 列对齐?然后删除您在代码中添加的额外 <div class="footer">
,因为您已经在顶部 div 中调用了 .footer
类。像这样:<footer class="container-fluid footer">
原始代码:
<footer class="container-fluid footer">
<div class="row">
<div class="col-sm-3">
<!-- REMOVE --> <div class="footer">
<div id="cat-1">
<h6 class="footer-title">About
<h6>
<ul>
<a href="###">
<li>About Company</li><a/>
<a href="###">
<li>Vison & Mission</li><a/>
<a href="###">
<li>Parnters</li><a/>
<a href="###">
<li>Policy</li><a/>
</ul>
</div>
</div>
<div class="col-sm-3">
<div id="cat-2">
<h6 class="footer-title">Useful Links</h6>
<ul>
<a href="###">
<li>Help</li> <a/>
<a href="###">
<li>testimonials</li><a/>
<a href="###">
<li>Store Location</li><a/>
<a href="###">
<li>Trade Account</li><a/>
<a href="###">
<li>Site Map</li><a/>
</ul>
</div>
</div>
<div class="col-sm-3">
<div id="cat-3">
<h6 class="footer-title">Customers</h6>
<ul>
<a href="###">
<li>Our Prices</li><a/>
<a href="###">
<li>Returns</li><a/>
<a href="###">
<li>Sizes</li><a/>
<a href="###">
<li>Regster</li><a/>
</ul>
</div>
</div>
<div class="col-sm-3">
<div id="cat-4">
<h6 class="footer-title">Documentation</h6>
<ul>
<a href="###">
<li>RISQS Certificate</li><a/>
<a href="###">
<li>Insurance</li><a/>
<a href="###">
<li>Libray</li><a/>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</footer>
新代码:
<footer class="container-fluid footer">
<div class="row">
<div class="col-sm-3">
<div id="cat-1">
<h6 class="footer-title">About
<h6>
<ul>
<a href="###">
<li>About Company</li><a/>
<a href="###">
<li>Vison & Mission</li><a/>
<a href="###">
<li>Parnters</li><a/>
<a href="###">
<li>Policy</li><a/>
</ul>
</div>
</div>
<div class="col-sm-3">
<div id="cat-2">
<h6 class="footer-title">Useful Links</h6>
<ul>
<a href="###">
<li>Help</li> <a/>
<a href="###">
<li>testimonials</li><a/>
<a href="###">
<li>Store Location</li><a/>
<a href="###">
<li>Trade Account</li><a/>
<a href="###">
<li>Site Map</li><a/>
</ul>
</div>
</div>
<div class="col-sm-3">
<div id="cat-3">
<h6 class="footer-title">Customers</h6>
<ul>
<a href="###">
<li>Our Prices</li><a/>
<a href="###">
<li>Returns</li><a/>
<a href="###">
<li>Sizes</li><a/>
<a href="###">
<li>Regster</li><a/>
</ul>
</div>
</div>
<div class="col-sm-3">
<div id="cat-4">
<h6 class="footer-title">Documentation</h6>
<ul>
<a href="###">
<li>RISQS Certificate</li><a/>
<a href="###">
<li>Insurance</li><a/>
<a href="###">
<li>Libray</li><a/>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</footer>
【讨论】:
感谢工作!这可能听起来有点愚蠢,但如果我想开始设置页脚样式,我应该选择哪个类? 取决于你想设计哪一部分?如果它是整个页脚而不是 .footer 类将起作用,即 这就是我尝试过的,但我没有得到任何结果 只是背景色 好的,要更改背景,您需要编辑此部分:.footer background-color: /* 此处的背景颜色*/以上是关于Bootstrap 页脚列未对齐的主要内容,如果未能解决你的问题,请参考以下文章