html - Align elements with different heights on the same row -
i trying display multiple circles on same horizontal axis different width , height. problem circles shrinked.
body, html { height: 100%; margin: 0; padding: 0; } .circles-container { display: table; border-spacing: 40px; } .row { display: table-row; } .circle { width: 100px; height: 100px; border: 1px solid #000; border-radius: 50%; text-align: center; vertical-align: middle; display: table-cell; } .cell { display: table-cell; } .big-circle { width: 300px; height: 300px; }
<div class="circles-container"> <div class="row"> <div class="cell"> <div class="circle"> <span>text</span> </div> </div> <div class="cell"> <div class="circle"> <span>text</span> </div> </div> <div class="cell"> <div class="big-circle circle"> <span>text</span> </div> </div> <div class="cell"> <div class="circle"> <span>text</span> </div> </div> <div class="cell"> <div class="big-circle circle"> <span>text</span> </div> </div> </div> </div>
jsfiddle: https://jsfiddle.net/cxuxgy0u/
you should not use table layout this. html not semantically represent table, table
element worng use.
what want can achieved flexbox.
article { display: flex; align-items: center; } article > div + div { margin-left: 1rem; } article > div { flex-shrink: 0; height: 4rem; width: 4rem; border-radius: 50%; border: solid 1px black; display: flex; justify-content: center; align-items: center; } article > div:nth-child(2) { height: 6rem; width: 6rem; }
<article> <div><span>text</span></div> <div><span>text</span></div> <div><span>text</span></div> <div><span>text</span></div> <div><span>text</span></div> <div><span>text</span></div> <div><span>text</span></div> <div><span>text</span></div> <div><span>text</span></div> </article>
you might want read more flexbox on mdn.
Comments
Post a Comment