html - 1px border around uneven amount of divs -


i'm trying solve issue has plagued me long. i'm attempting create following css:

https://gyazo.com/c8ae39ebc4795027ba7c1067a08d3420

there uneven amount of divs have styled so:

.box{     background-color: grey;     float: left;     width: 33.33%;     border: 1px solid black; } 

i attempting re-style divs in middle using nth-child it's making divs go weird orders , feels messy. there easier way?

codepen i'm trying do:

http://codepen.io/anon/pen/rrqnzm

thanks.

there no standard way this, simple trick use border on right , bottom of .box , top , left on wrapping element. way, give illusion borders collapse.

.box,  .wrapper {    border: 1px solid red;  }  .box {    border-top: none;    border-left: none;    box-sizing: border-box;    width: 33.33333333%;    float: left;    height: 45px;  }  .wrapper {    border-right: none;    border-bottom: none;    overflow: hidden;  }
<div class="wrapper">    <div class="box"></div>    <div class="box"></div>    <div class="box"></div>    <div class="box"></div>    <div class="box"></div>  </div>


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -