<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="css/css.css" />
<title>niday</title>
</head>
<body>
<div class="bg">
<div class="left">
<img src="img/10.jpg" />
</div>
</div>
</body>
</html>
html,body,.bg{ //此处一定要加HTML,不加会出现下底白边
margin: 0px;
padding: 0px;
width: 100%;
height: 100%;
}
.left{
height: 100%;
width: 100%;
overflow: hidden;
position: relative;
}
.bg .left img{
width: 100%;
height:100%;
}
接下来看看CSS不加HTML元素的,出现下底白边:
常见工作站:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="css/css.css" />
<title>niday</title>
</head>
<body>
<div class="bg">
<div class="left">
<img src="img/10.jpg" />
</div>
</div>
</body>
</html>
CSS:
html,body,.bg{
margin: 0px;
padding: 0px;
width: 100%;
height: 100%;
}
.left{
height: 100%;
width: 50%;
overflow: hidden;
position: relative;
}
.bg .left img{
width: 100%;
height:100%;
}
如果CSS不写还HTML,出现白边: