你可以这样做:http ://codepen.io/pageaffairs/pen/svxLg
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
.float, .boxes div {background: #f7f7f7; }
.wrap {width: 1000px; margin: 0 auto; padding: 20px 0; background: #30353b;}
.float {float: left; width: 476px; height: 440px; margin: 0 23px 23px 0;}
.boxes {text-align: justify;}
.boxes div {width: 238px; height: 238px; display: inline-block;}
.boxes:after {content: ''; width: 100%; display: inline-block;}
</style>
</head>
<body>
<div class="wrap">
<div class="float"></div>
<div class="boxes">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
</body>
</html>
前几天我从另一个对话中得到了这个解决方案,其中引用了这个非常方便的设置inline-block
元素的技巧text-align: justify
:http ://www.barrelny.com/blog/text-align-justify-and-rwd/
这是另一个大小不同的版本:http: //codepen.io/pageaffairs/pen/JrqIf
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
.float {background: #ccc;}
.boxes div {background: #f7f7f7; }
.wrap {width: 1000px; margin: 0 auto; padding: 20px 0; background: #30353b;}
.float {float: left; width: 318px; height: 400px; margin: 0 23px 23px 0;}
.boxes {text-align: justify;}
.boxes div {width: 318px; height: 200px; margin-bottom: 23px; display: inline-block;}
.boxes:after {content: ''; width: 100%; display: inline-block;}
</style>
</head>
<body>
<div class="wrap">
<div class="float"></div>
<div class="boxes">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
</body>
</html>
编辑:我看到您现在发布了一个示例,所以这是应用于您的代码的示例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
#main {
width:1000px;
position:relative;
background-color:rgb(88, 88, 88);
}
#welcometext {
float: left;
width:318px;
margin-right:23px;
}
#welcometext p {
width:100%;
margin-top:30px;
}
.navelement {
width:318px;
height:189px;
overflow:hidden;
margin-top:40px;
border-radius:10px;
background-color:white;
display: inline-block;
}
.nav-wrap {text-align: justify;}
.nav-wrap:after {content: ''; width: 100%; display: inline-block;}
</style>
</head>
<body>
<div id="main">
<div id="welcometext">
<p>aximinctus incte pa idis sequati velit exero to tem si disci- enderi doloressit odi reptatum dolorrum et et autet aliti- assi rerio corum hitius am quidelibus. 318 px giatemporro esequam, eicias arum doleni vidis pre pa do- lupti orerum qui doluptatiam, voluptae conseritaque sita [...] imuscimin ne niendit.</p>
</div>
<div class="nav-wrap">
<div class="navelement">
</div>
<div class="navelement">
</div>
<div class="navelement">
</div>
</div>
</div>
</body>
</html>