Reputation: 2866
As you can see from the image the white border
is hanging over the green body
.
I want the white border
to hide behind the green background
so that panels touch the edge of column on both left/right side with no whitespace.
Code
body {
background-color: green;
margin: 0;
}
.home-panels {
font-size: 0;
margin-left: -2.5px;
margin-right: -2.5px;
margin-top: 2.5px;
margin-bottom: 2.5px;
}
.panel-default {
box-sizing: border-box;
border-style: none;
position: relative;
width: 50%;
padding-bottom: 40%;
overflow: hidden;
background-color: #446CB3;
border-radius: 0;
display: inline-block;
margin-bottom: 0px;
border: 2.5px white solid;
}
.panel-body {
color: white;
width: 100%;
height: 100%;
text-align: center;
position: absolute;
font-size: 12px;
justify-content: center;
align-items: center;
display: flex;
}
<div class="home-panels">
<a href="/inspirations/25-asdf-asdf">
<div class="panel panel-default">
<div class="panel-body">
<div class="white-link">asdf asdf</div>
</div>
</div>
</a>
<a href="/inspirations/4-to-to-to-to-to-to-to-to-to-to-to-to">
<div class="panel panel-default">
<div class="panel-body">
<div class="white-link">to to to to to to to to to to to to</div>
</div>
</div>
</a>
<a href="/inspirations/24-asd">
<div class="panel panel-default">
<div class="panel-body">
<div class="white-link">asd</div>
</div>
</div>
</a>
<a href="/inspirations/8-test">
<div class="panel panel-default">
<div class="panel-body">
<div class="white-link">test</div>
</div>
</div>
</a>
</div>
Upvotes: 0
Views: 578
Reputation: 60563
remove extra margin
from .home-panels
and it is element body
not class .body
in CSS.
and you need to add
.home-panels a:nth-child(odd) .panel-default {
border-left: 0
}
.home-panels a:nth-child(even) .panel-default {
border-right: 0
}
Note that I added box-sizing:border-box
to the wildcard selector *
so it will apply to every selectors.
*,
*:before,
*:after {
box-sizing: border-box;
}
body {
background-color: green;
margin: 0;
}
.home-panels {
font-size: 0;
}
.panel-default {
border-style: none;
position: relative;
width: 50%;
padding-bottom: 40%;
overflow: hidden;
background-color: #446CB3;
border-radius: 0;
display: inline-block;
margin-bottom: 0px;
border: 2.5px white solid;
}
.home-panels a:nth-child(odd) .panel-default {
border-left: 0
}
.home-panels a:nth-child(even) .panel-default {
border-right: 0
}
.panel-body {
color: white;
width: 100%;
height: 100%;
text-align: center;
position: absolute;
font-size: 12px;
justify-content: center;
align-items: center;
display: flex;
}
<div class="home-panels">
<a href="/inspirations/25-asdf-asdf">
<div class="panel panel-default">
<div class="panel-body">
<div class="white-link">asdf asdf</div>
</div>
</div>
</a>
<a href="/inspirations/4-to-to-to-to-to-to-to-to-to-to-to-to">
<div class="panel panel-default">
<div class="panel-body">
<div class="white-link">to to to to to to to to to to to to</div>
</div>
</div>
</a>
<a href="/inspirations/24-asd">
<div class="panel panel-default">
<div class="panel-body">
<div class="white-link">test</div>
</div>
</div>
</a>
<a href="/inspirations/8-test">
<div class="panel panel-default">
<div class="panel-body">
<div class="white-link">test</div>
</div>
</div>
</a>
</div>
Upvotes: 1