Reputation: 4169
Is there an easy way to overlap borders on div
s?
Say you have this:
.box {
border: 1px solid #ccc;
width: 50px;
height: 50px;
}
<div class='box'></div>
<div class='box'></div>
<div class='box'></div>
<div class='box'></div>
You can see a "double border" where the div
s meetup.
I want to show only a single 1px
border between div
s.
I know you can set different classes, but was wondering about an easier solution.
why is my question different
well I dont have a container wrapped arounf the divs. So according to that answer the border-collapse:collapse
have to be applied to the parent or wrapper element.
Upvotes: 1
Views: 410
Reputation: 1855
Try this code
<div class="container">
<div class='box'></div>
<div class='box'></div>
<div class='box'></div>
<div class='box'></div>
</div>
.box {
border: 1px solid #ccc;
width: 50px;
height: 50px;
margin-bottom: -1px;
}
.box:last-child {
margin-bottom: 0;
}
live demo - https://jsfiddle.net/8cc8hoxf/
Upvotes: 2
Reputation: 169
You have a couple of options via CSS. You could do this:
.box + .box {
margin-top: -1px;
}
Or
.box + .box {
border-top-width: 0px;
}
Upvotes: 6