<!doctype html>
<html>
<head>
<title>如何裁減多餘顯示</title>
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css">
.box1{
width: 200px;
height: 200px;
background-color: tomato;
float: left;
}
.box2{
width: 200px;
height: 200px;
background-color: orange;
margin: auto;
overflow: hidden;
\\因box2沒有設定float所以 h1會超出內容元素,用overflow將h1元素回到原本位置
}
.img-container{
width: 33.33%;
float: left;
padding: 5px;
box-sizing: border-box;
height: 250px;
overflow: hidden;
/*需設定高度後才能使用overflow*/
}
.clearfix{
clear:both;
}
</style>
</head>
<body>
<div>
<h1>Example Domain</h1>
<div class="box1">
<h1>Title1</h1>
</div>
<div class="box2">
<h1>Title2</h1>
</div>
<div class="clearfix">
<div class="img-container">
<img src="Image/earth.png" alt="first imagee" style="width:100%;">
</div>
<div class="img-container">
<img src="Image/flat.png" alt="second imagee" style="width:100%;">
</div>
<div class="img-container">
<img src="Image/woody.jpeg" alt="third imagee" style="width:100%;">
</div>
</div>
</div>
</body>
</html>