我的布局有问题。我试图创建一个简单,响应两列的布局。这很困难,因为我想要结合常量和百分比宽度。
工作布局代码如下:
<html>
<head>
<style>
body {
margin: 0;
padding: 0;
}
#leftBar {
width: 20px;
height: 100%;
float: left;
background: red;
}
#topBar {
width: calc(100% - 20px);
height: 30px;
float: left;
background: green;
}
#map {
width: calc(100% - 20px);
height: calc(100% - 30px);
float: left;
background: yellow;
}
</style>
</head>
<body>
<div id="leftBar"></div>
<div id="topBar"></div>
<div id="map"></div>
</body>
</html>
如何创建适用于旧浏览器的相同布局?
答案 0 :(得分:0)
您可以使用绝对布局和顶部,右侧,左侧和底部属性。 这是一个与您的网站匹配的示例(我无法找到#map的意义所以,现在它是一个响应式内容框):
#body {
margin: 0;
padding: 0;
}
#leftBar {
position: absolute;
left: 0px;
top: 0px;
width: 20px;
height: 100%;
background-color: red;
}
#topBar {
position: absolute;
left: 20px;
top: 0px;
right: 0px;
height: 30px;
background-color: green;
}
#map {
position: absolute;
left: 20px;
right: 0px;
top: 30px;
height: auto;
background-color: yellow;
}
这将解决calc()问题,其他属性应该可以在任何浏览器中使用...