目标:保持 div 适合视口大小的内容,尽量减少垂直或水平样式列表。
这 CSS/HTML 是不是太 hack 了?我希望它是最好的,也是最少的(写作量):
.phosphor .vical {
width:0; /* width 0 means we have a vertical list */
}
.phosphor .hical {
width:auto; /* auto width means we get a responsive horizontal list */
}
.phosphor .vical a {
display:inline-block;
}
.phorphor .hical a {
display:inline-block;
}
<div class='phosphor'>
<div class="vical">
<a href="#V1">V1</a>
<a href="#V2">V2</a>
<a href="#V3">V3</a>
<a href="#V4">V4</a>
</div>
<a href="#H1">H1</a>
<a href="#H2">H1</a>
</div>
其余代码和演示在这里:http: //jsfiddle.net/SaZUW/1/