我怎么才能让一段文本居中放置在左右浮动的 2 个 div 之间?
我的代码如下
<style type="text/css">
.left {
float:left;
padding-left:10px;
}
.right {
float: right;
padding-right:10px;
}
</style>
<div id="header">
<div class="left">
<p>Stuff on the left</p>
</div>
<span>Center Text or Image/Logo</span>
<div class="right">
<p>Stuff on the right</p>
</div>
</div>
最佳答案
HTML
<div id="header">
<div class="left">
<p>Stuff on the left</p>
</div>
<div class="center">
<p>Stuff in the center</p>
</div>
<div class="right">
<p>Stuff on the right</p>
</div>
</div>
CSS:
.left {
float:left;
width:25%;
}
.right {
float:left;
width:25%;
}
.center {
float:left;
width:49%;
}
关于html - 即使窗口调整大小时,也让文本在左浮动和右浮动 div 之间居中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23661730/