CSS selector: how to make 2 spans each fill 50% of their parent's width? -
this doesn't works:
given html such:
<body> <div class="list"> <span class=" level">hello</span> <span class="logic-english">world!</span> </div> <div class="list"> <span class=" level">or should</span> <span class="logic-english">i say....</span> </div> <div class="list"> <span class=" level">something else</span> <span class="logic-english">such as...</span> </div> <div class="list"> <span class=" level">goodbye</span> <span class="logic-english">world!</span> </div> </body>
a css such:
body { width: 100%; } .list { border: 1px solid #333; margin: 3px; } .list { font-size: 0.8em; min-width: 50% ; display: inline; } .list:nth-child(4n+3), .list:nth-child(4n+4) { background: #ffaaaa; width: 100%; }
also, how make 2 spans each fill 50% of parent's width ?
set elements display:inline-block
, reduce width account margins. may want move more fixed width using pixels make .list
elements take half container.
css
.list { font-size: 0.8em; min-width: 47% ; display: inline-block; } .list:nth-child(4n+3), .list:nth-child(4n+4) { background: #ffaaaa; width: 47%; }
working example http://jsfiddle.net/4zddx/11/
Comments
Post a Comment