即使窗口调整大小,也可以在浮动左侧和浮动右侧div之间获取文本?

时间:2014-05-14 17:53:34

标签: html css navigation css-float

如何让我得到一段文字在两个左右浮动的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>

1 个答案:

答案 0 :(得分:1)

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%;
}

演示:http://jsfiddle.net/cyR5W/