html: 3 列,居中必须固定宽度

标签 html css

我需要在一行中有 3 列。中间的列是固定宽度的,但左右列必须是可变的。我还需要用 Android 和 IE8 打开这个页面。所以它应该适用于旧浏览器。

我需要: enter image description here

我的尝试,但没有成功:

.left {
    float: left;
    width: 100%;
    margin-left: -50%;
    height: 230px;
    background: url('left.png') no-repeat right top;
}
.center {
    float: left;
    margin-left: -62px;
    background: #FDE95E;
    width:123px;
    height:123px;
    background: url('center.png');
}
.right {
    float: left;
    width: 50%;
    height:230px;
    background: url('right.png') no-repeat left top;
}

HTML:

<div class="left"><br></div>
<div class="center"><br></div>
<div class="right"><br></div>
<div style="clear: both;"></div>

最佳答案

CSS

.left {
    background: red;
    float: left;
    height: 500px;
    width: calc(50% - 50px);

}
.center {
    background: gray;
    height: 500px;
    width: 100px;
    margin: auto;
}
.right {
    background: red;
    float: right;
    height: 500px;
    width: calc(50% - 50px);
}

html

<div class="left">Left</div>
<div class="right">Right</div>
<div class="center">Center</div>
<div style="clear: both;"></div>

http://jsfiddle.net/usb9sbje/

关于html: 3 列,居中必须固定宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26566618/

相关文章:

html - 什么是最小宽度 : 100%; width: auto actually do?

html - 3 列模板修复的问题

php - 向后移动 2 个目录不起作用?

html - 使 div 扩展到全高 - 30px

javascript - 聊天机器人应答/响应时间 js 中的代码

html - 对齐框上的文本

javascript - IE 中的冒泡事件

html - CSS 将元素的高度设置为自动高度的%

html - 如何修复表格溢出以使其自动滚动?

asp.net - 使用 VB 在根页面 ASP.NET 上检测当前页面