法一:float
**<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS两列布局</title>
<style>
*{
padding:0px;
margin:0px;
}//chrome浏览器下:body默认margin均为8,但border、padding和其他div的margin、border、padding均为0
.parent{
height:500px;
width:400px;
}
.one{
float: left;
width:200px;
height:100%;
margin-right:10px;
background:red;
}
.two{
position: relative;
left:210px;
right:0px;
height:100%;
background: blue;
}
</style>
</head>
<body>
<div class="parent">
<div class="one"></div>
<div class="two"></div>
</div>
</body>
</html>
法二:子绝父相(子绝对定位,父相对定位)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS两列布局</title>
<style>
.parent{
height:500px;
width:400px;
position: relative;
}
.one{
position: absolute;
width:200px;
height:100%;
margin-right:10px;
background:red;
}
.two{
position: absolute;
left:210px;
right:0;
height:100%;
background:blue;
}
</style>
</head>
<body>
<div class="parent">
<div class="one"></div>
<div class="two"></div>
</div>
</body>
</html>
实现