我是新手,我试图在bootstraps页脚中居中三个div,但它们似乎在左边居中。我将离开Twitter Bootstrap框架,仍在学习绳索,所以如果我遗漏了任何东西,请告诉我。谢谢!
HTML
<footer>
<div class="footer">
<div class="container narrow row-fluid">
<div class="span3">
<h3>Contact Us!</h3>
<p>Have a question or comment? We can help you!</p>
<br>by phone: 555-555-5555
<br>by mail: info@website.com
<br>or by our: <a href="contact.htm">Contact Page</a>
</div>
<div class="span3">
<a class="brand" href="index.htm"><img src="images/logo.png" alt="South Shore Bicycle and Fitness" align="middle"> </a>
</div>
<div class="span3">
<h3>Newsletter</h3>
<p>Subscribe to our newsletter and get the latest news!</p>
<form action="php/mail.php" id="subscribe-form" method="post">
<input type="text" name="email" id="email" placeholder="Your Email Address">
<button type="submit" class="btn btn-primary">Sign Up</button>
</form>
</div>
</div>
</div>
</footer>
CSS
.modal-footer { padding: 14px 15px 15px;
margin-bottom: 0;
background-color: #f5f5f5;
border-top: 1px solid #ddd;
-webkit-border-radius: 0 0 6px 6px;
-moz-border-radius: 0 0 6px 6px;
border-radius: 0 0 6px 6px;
-webkit-box-shadow: inset 0 1px 0 #ffffff;
-moz-box-shadow: inset 0 1px 0 #ffffff;
box-shadow: inset 0 1px 0 #ffffff;
*zoom: 1;
vertical-align: middle;
}
.modal-footer:before, .modal-footer:after {
display: table;
content: "";
vertical-align: middle
}
.modal-footer:after {
clear: both;
vertical-align: middle
}
.modal-footer .btn {
float: right;
margin-left: 5px;
margin-bottom: 0;
vertical-align: middle
}
.span3 {
width: 166px;
}
答案 0 :(得分:0)
你可以使用margin:0 auto;中心元素。尝试将此规则添加到CSS:
.span3{
margin: 0 auto
}
然后,还给出一个包含span3宽度的div:
.container{
width: 515px /* The actual width may need to be higher or lower than this */
}