任意宽度元素,在固定宽度容器内排列,使多行结果接近对齐
如图所示,元素左对齐,排列之后尽量让每行右侧对齐,且每行尽量占满容器宽度,并保证行数最小
求达人帮忙或告知类似排序算法
异世界执行姬
10 years, 2 months ago
Answers
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8">
<title>demo</title>
</head>
<style>
.container {
width: 300px;
height: 300px;
background-color: #ccc;
}
.clearfix:after {
content: "\200B";
display: block;
height: 0;
clear: both;
}
.clearfix {*zoom:1;}
.container span {
float: left;
background-color: #666;
margin: 5px;
}
</style>
<body>
<div class="container clearfix">
<span>阿道夫</span>
<span>阿道夫</span>
<span>阿道夫</span>
<span>阿道夫奥德赛</span>
<span>阿道夫</span>
<span>阿道夫去外地前端</span>
<span>阿道去外地前端去夫</span>
<span>阿</span>
<span>阿道夫</span>
<span>阿道夫</span>
<span>阿道夫</span>
<span>阿道夫</span>
<span>阿道夫奥德赛</span>
<span>阿道夫</span>
<span>阿道夫去外地前端</span>
<span>阿道去外地前端去夫</span>
<span>阿</span>
<span>阿道夫</span>
</div>
</body>
</html>
是香菜不是香蕉
answered 10 years, 2 months ago