定宽和自适应布局的配合

来源:互联网 发布:sev18软件下载 编辑:程序博客网 时间:2024/06/06 07:05

方法一:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
.container{
height: 500px;
border: 1px solid black;
position: relative;
}
.left{
position: absolute;
left: 0;
width: 200px;
height: 100%;
background-color: greenyellow;
}
.right{
margin-left: 200px;
height: 100%;
background-color: red;
}
</style>
</head>
<body>
<div class="container">
<div class="left"></div>
<div class="right"></div>
</div>
</body>
</html>


//方法二:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
.container{
height: 500px;
border: 1px solid black;
display: flex;
}
.left{
width: 200px;
height: 100%;
background-color: greenyellow;
}
.right{
flex: 1;
height: 100%;
background-color: red;
}
</style>
</head>
<body>
<div class="container">
<div class="left"></div>
<div class="right"></div>
</div>
</body>
</html>

原创粉丝点击