Div 上的文本居中未使文本居中? (推特 Bootstrap 3)
Text-Center on Div not Centering the Text? (Twitter Bootstrap 3)
我目前正在约翰霍普金斯大学 HTML/CSS 和 Javascript 课程上学习 Coursera,使用 Bootstrap 3.6(我知道已经过时了)编写 David Chu's China Bistro 的代码。我遇到了一个问题,即版权行位于第三列下方 (my site screensho) rather than centered at the bottom of the footer (official site screenshot)。这是该页脚部分的代码:
<footer class="panel-footer">
<div class="container">
<div class="row">
<section id="hours" class="col-sm-4">
<span>Hours:</span><br>
Sun-Thurs: 11:15am-10:00pm<br>
Fri: 11:15am - 2:30pm<br>
Saturday collapsed<hr class="visible-xs">
</section>
<section id="address" class="col-sm-4">
<span>Address:</span><br>
7105 Resterstown Road<br>
Baltimore, MD 21215
<p>* Delivery area within 3-4 miles, with minimum order of
plus charge for all deliveries.</p>
<hr class="visible-xs">
</section>
<section id="testimonials" class="col-sm-4">
<p>"The best Chinese restaurant I've been to! And that's saying
a lot, since I've been to many!"</p>
<p>"Amazing food! Great service! Couldn't ask for more! I'll be
back again and again!"</p>
</section>
<div class="text-center">© Copyright David Chu's China Bistro 2016</div>
</div>
</div>
</footer>
现在我明白了它没有居中,因为带版权符号的 div
不应该在带有 class="row"
的 div
内,但无论如何我都不明白为什么div 在第三列下方。根据 Bootstrap 的所有部分都应浮动,这意味着它们已脱离正常文档流。但是,版权声明并没有浮动,那不应该占据整个宽度并居中在页面中间吗?抱歉,我是 HTML/CSS 的新手!
解决方法就是往外移一层,我想就解决了。
<footer class="panel-footer">
<div class="container">
<div class="row">
<section id="hours" class="col-sm-4">
<span>Hours:</span><br>
Sun-Thurs: 11:15am-10:00pm<br>
Fri: 11:15am - 2:30pm<br>
Saturday collapsed<hr class="visible-xs">
</section>
<section id="address" class="col-sm-4">
<span>Address:</span><br>
7105 Resterstown Road<br>
Baltimore, MD 21215
<p>* Delivery area within 3-4 miles, with minimum order of
plus charge for all deliveries.</p>
<hr class="visible-xs">
</section>
<section id="testimonials" class="col-sm-4">
<p>"The best Chinese restaurant I've been to! And that's saying
a lot, since I've been to many!"</p>
<p>"Amazing food! Great service! Couldn't ask for more! I'll be
back again and again!"</p>
</section>
</div>
<div class="text-center">© Copyright David Chu's China Bistro 2016</div>
</div>
</footer>
如果问题仍然存在,请尝试使用 p
版权标签而不是 div
我目前正在约翰霍普金斯大学 HTML/CSS 和 Javascript 课程上学习 Coursera,使用 Bootstrap 3.6(我知道已经过时了)编写 David Chu's China Bistro 的代码。我遇到了一个问题,即版权行位于第三列下方 (my site screensho) rather than centered at the bottom of the footer (official site screenshot)。这是该页脚部分的代码:
<footer class="panel-footer">
<div class="container">
<div class="row">
<section id="hours" class="col-sm-4">
<span>Hours:</span><br>
Sun-Thurs: 11:15am-10:00pm<br>
Fri: 11:15am - 2:30pm<br>
Saturday collapsed<hr class="visible-xs">
</section>
<section id="address" class="col-sm-4">
<span>Address:</span><br>
7105 Resterstown Road<br>
Baltimore, MD 21215
<p>* Delivery area within 3-4 miles, with minimum order of
plus charge for all deliveries.</p>
<hr class="visible-xs">
</section>
<section id="testimonials" class="col-sm-4">
<p>"The best Chinese restaurant I've been to! And that's saying
a lot, since I've been to many!"</p>
<p>"Amazing food! Great service! Couldn't ask for more! I'll be
back again and again!"</p>
</section>
<div class="text-center">© Copyright David Chu's China Bistro 2016</div>
</div>
</div>
</footer>
现在我明白了它没有居中,因为带版权符号的 div
不应该在带有 class="row"
的 div
内,但无论如何我都不明白为什么div 在第三列下方。根据 Bootstrap 的所有部分都应浮动,这意味着它们已脱离正常文档流。但是,版权声明并没有浮动,那不应该占据整个宽度并居中在页面中间吗?抱歉,我是 HTML/CSS 的新手!
解决方法就是往外移一层,我想就解决了。
<footer class="panel-footer">
<div class="container">
<div class="row">
<section id="hours" class="col-sm-4">
<span>Hours:</span><br>
Sun-Thurs: 11:15am-10:00pm<br>
Fri: 11:15am - 2:30pm<br>
Saturday collapsed<hr class="visible-xs">
</section>
<section id="address" class="col-sm-4">
<span>Address:</span><br>
7105 Resterstown Road<br>
Baltimore, MD 21215
<p>* Delivery area within 3-4 miles, with minimum order of
plus charge for all deliveries.</p>
<hr class="visible-xs">
</section>
<section id="testimonials" class="col-sm-4">
<p>"The best Chinese restaurant I've been to! And that's saying
a lot, since I've been to many!"</p>
<p>"Amazing food! Great service! Couldn't ask for more! I'll be
back again and again!"</p>
</section>
</div>
<div class="text-center">© Copyright David Chu's China Bistro 2016</div>
</div>
</footer>
如果问题仍然存在,请尝试使用 p
版权标签而不是 div