月关宝箱
据我所知,css中没有colspan,但column-span在不久的将来会有多列布局,但只是CSS3的草案,所以可以在这里确认。 无论如何,您都可以使用类似于div和span的表格显示来创建解决方案。 这将是HTML :
forthesakeoftable-less layout.* /
. table{display:table; 表层布局:固定; width:100px; }
. row{display:table-row; height:10px; }
. cell{display:table-cell; }
/* thisiswherethecolspantricksworks.* /
span{width:100%; }
/* belowisforvisualrecognitiontestpurposesonly.* /
. red{background:red; }
. blue{background:blue; }
. green{background:green; }
.黑屏{ background :黑屏; }
/* thisisthebenefitofusingtabledisplay,itisable
tosetthewidthofit ' schildobjecttofilltherestof
theparentwidthasintable*/
. first{width:20px; }
. last{width:30px; }
. fill{width:100%; }使用此技术的唯一原因是为了受益于table-layout行为。 如果仅将div和span的宽度设置为恒定的百分比不满足设计要求,请使用它。 但是,如果不需要从这种table-layout行为中受益的话,durilai的回答就足够了。