How to create "collapsed" borders around flex items and their container?

how to create a website for free
how to create a website free of cost
how to create a website pdf
how to create a website on google
creating a website for your business
how to create a web page
how to create a website using html
how to build a website from scratch

I have the following layout:

#limited-width {
  width: 100%;
  max-width: 200px;
  margin: 0 auto;
  font-size: 18px;
}
ul {
  display: flex;
  flex-flow: row wrap;
  list-style: none;
  padding: 0;
  margin: 20px;
}
ul > li {
  display: block;
  text-align: center;
  flex: 1 0 auto;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 4px 7px;
  border: 2px solid rgba(0,0,0,.3);
  background-color: rgba(0,0,0,.03);
}
<div id="limited-width">
  <ul>
    <li>Apple</li>
    <li>Orange</li>
    <li>Pineapple</li>
    <li>Banana</li>
    <li>Tomato</li>
    <li>Pear</li>
    <li>Lemon</li>
  </ul>
</div>

Create a free website with Wix.com. Choose a stunning template and customize anything with the Wix website builder—no coding skills needed. Create yours  Before You Start, Read This: STEP 1 Get Web Hosting and Register a Domain Name. STEP 2 Set Up Your Website. Once you’ve bought your domain name and set up your hosting, STEP 3 Design Your Website. Once you have successfully installed WordPress to your domain, STEP 4 Add Content To Your

I had same question, but I made this(see demo below). I add to each block negative 'margin-left' and negative 'margin-top' equal to the width of the border. Then I add the same but positive 'padding-left' and 'padding-top' to the container, to compensate for the offset. Woo-a-la! Now we get "collapsed" borders around flex items and their container.

.catalog-list {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  padding-top: 1px;
  padding-left: 1px;
  box-sizing: border-box;
  max-width: 800px;
  margin: auto;
  box-shadow: inset 0 0 0 1px #8c8c8c;
}

.catalog-item {
  width: calc(25% + 1px);
  margin-top: -1px;
  margin-left: -1px;
  padding: 20px;
  border: 1px solid #8c8c8c;
  box-sizing: border-box;
  transition: all 0.2s;
  box-sizing: border-box;
}

.catalog-item:hover {
  border-color: transparent;
  box-shadow: 0 0 15px -2px #8c8c8c;
}
<div class="catalog-list">
  <div class="catalog-item"></div>
  <div class="catalog-item"></div>
  <div class="catalog-item"></div>
  <div class="catalog-item"></div>
  <div class="catalog-item"></div>
  <div class="catalog-item"></div>
</div>

A step-by-step guide to creating a great business website, from setting-up an e-​commerce system to marketing your business on the Web. How to create a new Microsoft account. Go to account.microsoft.com , select Sign in , and then choose Create one! If you'd rather create a new email address, choose Get a new email address , choose Next , and then follow the instructions.

In my case, the borders need to be 1px which makes it more difficult. I found a solution at https://codepen.io/Hawkun/pen/rsIEp/ which uses shadows to simulate borders, which actually works well.

Here is the code in action. It doesn't use flexbox but if you apply the shadow to your flex content, you're good to go.

body {
  font-family: sans-serif;
  background-color: #eee;
  padding: 20px;
}

.info {
  color: darkred;
  font-weight: bolder;
}

.container {
  background-color: white;
  float: left; /* Makes the container height the same as its children. */
  padding: 10px;
  margin-bottom: 40px;
}

.container div {
  padding: 20px;
  float: left;
  background-color: #def;
  
  
  /* And here comed the trick: */

  box-shadow: 
1px 0 0 0 #888, 
0 1px 0 0 #888, 
1px 1px 0 0 #888,   /* Just to fix the corner */
1px 0 0 0 #888 inset, 
0 1px 0 0 #888 inset;

}

#container1 {
  width: 100%;
}

#container2 {
  width: 50%;
}

#container2 div {
  width: 70%;
}
<p>The first container:</p>

<div id="container1" class="container">
  <div>Hello, this is the first floated div</div>
  <div>And this is the second</div>
  <div>And finally the third one</div>
</div>

<p>The second container:</p>

<div id="container2" class="container">
  <div>Hello, this is the first floated div</div>
  <div>And this is the second</div>
  <div>And finally the third one</div>
</div>

Create a professional website for free with the Website.com website builder. Domain names, web hosting, website templates, and ecommerce solutions  What is GoDaddy Website Builder? GoDaddy Website Builder is an online editing and publishing tool that helps you create a website, regardless of your technical skill level. Just create an account, pick a design and use the built-in editor to add your own images and text. You can make your website as simple or complex as you’d like.

Here's another idea I had that will keep borders "collapsed" when flex boxes wrap. It uses background color for top and left and borders for right and bottom. It might be hard to make it work over a background image.

.container {
  display: flex;
  flex-flow: row wrap;
  border-style: solid;
  border-width: 0 2px 2px 0;
  border-color: black;
  background-color: black;
}

.container>div {
  flex: 1 0 auto;
  margin: 2px 0 0 2px;
  background-color: white;
}
<div class="container">
  <div>Eh?</div>
  <div>Bee.</div>
  <div>This div contains a whole bunch of stuff.</div>
  <div>This div contains a whole bunch of stuff.</div>
  <div>This div contains a whole bunch of stuff.</div>
  <div>Sea!</div>
  <div>This div contains a whole bunch of stuff.</div>
  <div>This div contains a whole bunch of stuff.</div>
  <div>This div contains a whole bunch of stuff.</div>
</div>

This site teaches you how to make a website in just 3 easy to follow steps. There's also lots of really useful resources to help you build traffic in  Register your domain name (.com, .net, etc.) and officially create the home of your website. Sign up with a web host and install WordPress on your domain to begin creating your website. DOWNLOAD YOUR FREE DIY WEBSITE GUIDE! Creating and customizing your first WordPress website on your own is not as intimidating as people make it out to be. Grab

With :last-of-type you can "collapse" the last border. Maybe adding a box-sizing:border-box;

How to Build a Website: the Step-by-Step Guide to Easy Setup. We'll look at how to make a website with both a website builder and WordPress,  When creating a new website with Wix, you can use Artificial Design Intelligence (ADI) to create a one-of-a-kind site. This option is great for beginners or anyone who needs to create a website quickly. Answer a few questions and get a fully customizable site complete with images, text and the business solutions you need.

Before you jump straight into building your site, take a few minutes to make sure you're using the right method to build it. If you get this decision  To sign up for Gmail, create a Google Account. You can use the username and password to sign in to Gmail and other Google products like YouTube, Google Play, and Google Drive. Go to the Google Account creation page. Follow the steps on the screen to set up your account. Use the account you created to sign in to Gmail.

You can use an online service to create web pages, or build it offline using a desktop software tool. Or, if you're a coding dynamo, use a plain text editor to create a  A single username and password gets you into everything Google (Gmail, Chrome, YouTube, Google Maps). Set up your profile and preferences just the way you like.

It is always wise to draw a layout draft of the page design before building a website. Having a "Layout Draft" will make it a lot easier to create a web site: Navigation  Create a YouTube channel for a Brand Account that you already manage by choosing the Brand Account from the list. If this Brand Account already has a channel, you can't create a new one—you'll just be switched over to that channel if you select the Brand Account from the list.

Comments
  • Worked beautifully, thanks... was trying to get border-collapse to work with no luck.
  • This is just what I needed. Thanks!
  • What if you want one of the items to have a different background and border colour, e.g. in its active state? This model falls short here. My workaround: jsbin.com/kageqe/5/edit?html,css,output
  • nice trick, i find this solution best
  • This answer has nothing to do with Flexbox.