Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
42 lines (38 sloc) 1.05 KB
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>法1:元素宽度未知,且所有元素都在一个容器</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.container {
display: flex;
width: 391px;
padding: 10px;
margin: 150px auto;
flex-wrap: wrap;
border: 2px solid rgb(240, 103, 103);
justify-content: space-between;
}
.item {
margin-bottom: 20px;
padding: 5px 10px;
font-size: 20px;
border-radius: 5px / 5px;
background: rgb(103, 164, 243);
}
</style>
</head>
<body>
<div class='container'>
<div class='item'>两个可以成一行</div>
<div class='item'>两个可以成一行</div>
<div class='item'>这三个字</div>
<div class='item'>四个</div>
<div class='item'>独成一行呀独成一行呀独成一行呀独成</div>
<div class='item'>两个才能成一行呀</div>
<div class='item'>四个</div>
</div>
</body>
</html>