Reputation: 33
I need to create white space between the border and background color.
Example
Okay so, | = border, # = background color
Above example would be drawn like |#####| and I need | ##### |
How would I go about doing that?
Code I have for the example in the picture is (below)
CSS
.nav-justified > .active > a, .nav-justified > .active > a:hover, .nav-justified > active > a:focus {
background-color: #F0F0F0;
background-image: none;
color: #8f1b1f;
left: 0;
width: 100%;
margin-top: -17px;
padding-bottom: 20px;
padding-top: 20px;
padding-right: 20px;
padding-left: 20px;
}
.nav-justified > li > a {
border-left: 1px solid #d5d5d5;
line-height: 2px;
}
HTML
<ul class="nav nav-justified" id="tableButtons">
<li class='active'><a href="#">Text here</a></li>
</ul>
Upvotes: 3
Views: 23273
Reputation: 1488
If you have background on that element, then, adding padding would be useless.
So, in this case, you can use background-clip: content-box; or outline-offset
Explanation: If you use wrapper, then it would be simple to separate the background from border. But if you want to style the same element, which has a background, no matter how much padding you would add, there would be no space between background and border, unless you use background-clip or outline-offset
Upvotes: 2
Reputation: 1181
UPDATE: Your scenario JSFIddle example.
You could use margin to show white background through. JSFiddle example here.
HTML:
<div class="outer"><div class="inner">Name And Address Details</div></div>
CSS
.outer {
display: inline-block;
border-left: 1px solid #d5d5d5;
}
.outer .inner {
padding: 5px 10px;
background: #ddd;
margin-left: 1px;
}
In your example li would be outer and a inner.
Upvotes: 1
Reputation: 4882
Set the border on the list element, background colour & padding on the anchor tag (not the list element), and then apply a margin to the anchor tag.
For example:
ul {
list-style:none;
}
li {
width:250px;
text-align:center;
border-left:1px solid #d5d5d5;
border-right:1px solid #d5d5d5;
}
li a {
color: #8f1b1f;
background-color: #F0F0F0;
text-decoration:none;
padding:10px;
display:block;
margin:0 2px;
}
Fiddle: http://jsfiddle.net/RCwE6/2/
Upvotes: 3