jjnilton
jjnilton

Reputation: 43

border-collapse changing width of element

Is there a way to use "border-collapse: collapse" without changing the width of the element?

What is happening: When I don't use border-collapse property the right/left borders looks "bold" because they're together.

If I use border-collapse property, it solve this "bold" problem of right/left borders together, but the width of the menu get bigger than other elements of the same width.

body { 
    background-color: #EEEEEE;
    margin: 20px;
    max-width: 1280px;
    min-width: 768px;
}

header {

}

#menu {
    display: table;
    width: 100%;
    border-collapse: collapse;

}

#menu ul {
    display: table-row;



}

#menu li {
    display: table-cell;
    height: inherit;
    border: solid 1px;
    padding: 0;
    margin: 0;




}

#menu li a {
    font-family: sans-serif;
    text-align: center;
    display: block;
    line-height: 1.2em;
    text-decoration: none;
    color: black;
}

#menu li a:visited {
    color:black;
}

#menu li:hover {
    background-color: white;
}

#main {
    background-color: white;
    height: 600px;
    border: 1px solid;
    border-top: none;
    border-bottom: none;
}

footer {
    background-color: white;
    height: 200px;
    border: 1px solid;
}

http://jsfiddle.net/wHDMn/3/ https://i.sstatic.net/UroWQ.png

Upvotes: 0

Views: 2293

Answers (1)

Paul Redmond
Paul Redmond

Reputation: 3296

From what I can see, the table gets one pixel bigger. You can get around this by using the box-sizing: border-box model.

* {
   -webkit-box-sizing: border-box;
   -moz-box-sizing: border-box;
   box-sizing: border-box;
}

http://jsfiddle.net/wHDMn/3/

Upvotes: 1

Related Questions