Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid double border from the multiple <li>

Tags:

css

How to avoid double border lines from the list style? Please see the following fiddle for clear picture. I want 1px width of each box but they are double when the come together.

http://jsfiddle.net/awaises/4SLPh/1/

HTML :

<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>

CSS :

ul{
     margin:0; padding:0;
     list-style:none;
     }
ul li{
     width:30%; height:200px;
     border:1px solid black;
     float:left;
     }

Thanks

like image 457
Awais Imran Avatar asked Mar 09 '14 11:03

Awais Imran


People also ask

How do you avoid double border in CSS?

Add a border-left and border-top to the parent. Add border-right and border-bottom to each of the children.

How do I get rid of the double border in a table?

You can remove the space between the different borders by using the CSS border-collapse property. You can apply this property against the HTML table element. When you apply this against the table element, you'll notice that the table border simply disappears, or "collapses".

How do I get rid of the double border in HTML?

To avoid having double borders like in the example above, set the CSS border-collapse property to collapse .

How will you handle a multiple borders in CSS?

Multiple borders in CSS can be done by box-shadow property. Generally, we can get a single border with border property. Box-shadow property is not for multiple borders, but still, we are creating multiple borders with box-shadow property.


2 Answers

Try adding margin-right:-1px; margin-bottom:-1px;

like image 97
Niet the Dark Absol Avatar answered Sep 22 '22 18:09

Niet the Dark Absol


It's a matter of applying borders to the ul & li selectively.

JSFiddle Demo

CSS

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

ul{
    margin:10px; padding:0;
    list-style:none;
    border-left:1px solid black;
    border-top:1px solid black;
    overflow:hidden;
}
ul li{
    width:33.3333%; height:200px;
    border-bottom:1px solid black;
    border-right:1px solid black;
    float:left;
}
like image 31
Paulie_D Avatar answered Sep 24 '22 18:09

Paulie_D