【发布时间】:2019-06-12 14:11:18
【问题描述】:
我有不同的行。每个都有一个 div 在左边和一个在右边。他们必须有 50 像素。在中心,我需要一个必须响应的 div,它应该适应窗口的宽度。我用 flex 解决了,但我担心旧的浏览器。有没有其他方法可以达到这种效果?
这种结构对于理解我的项目至关重要,对于使用旧浏览器的人来说,我不能退缩。那些人什么也看不见。
这是条件:
- div left 和 div right 应该有 50px
- div center应该是响应式的,用左右10px的边距填充剩余空间
这是我尝试过的,或多或少有效,但仅适用于新浏览器:
#wrap {
position: relative;
margin: 20px auto;
width: 80%;
background-color: red;
}
.row {
position: relative;
height: 30px;
margin-bottom: 10px;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
background-color: lightgray;
}
.left {
width: 50px; height: 30px; line-height: 30px;
display: inline-block;
text-align: center;
margin-right: 10px;
background-color: grey;
}
.center {
min-height: 30px; line-height: 30px;
text-align: center;
background-color: blue;
flex-grow: 1;
}
.right {
width: 50px; height: 30px; line-height: 30px;
display: inline-block;
text-align: center;
margin-left: 10px;
background-color: grey;
}
<div id="wrap">
<div class="row">
<div class="left">left</div>
<div class="center">center</div>
<div class="right">right</div>
</div>
<div class="row">
<div class="left">left</div>
<div class="center">center</div>
<div class="right">right</div>
</div>
</div>
【问题讨论】:
标签: html css responsive-design