Search code examples
htmlcssborderstylesheet

CSS - Space between border and background color


I need to create white space between the border and background color.

Example

enter image description here

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>

Solution

  • 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.