Remove border between divs

This question seems to have been answered a million times, and it seems to work a million times. Not for me. I would like to combine all divs in

<body> <div class="mainprogress"> <div class="detailprogress" style="height:100%;width:18%"> <div class="done" style="width:58%"></div> <div class="late" style="width:41%"></div> </div> <div class="detailprogress" style="height:35%;width:81%"> <div class="done" style="width:73%"></div> <div class="todo" style="width:26%"></div> </div> </div> </body> 

I use the following CSS for this

 .mainprogress { height:60px; border:2px solid black; } .mainprogress div{ padding:0; margin:0; display:inline-block; } .detailprogress div { height:100%; } .detailprogress .done { background-color:lightgreen; } .detailprogress .donelate { background-color:lightpink; } .detailprogress .late { background-color:red; } .detailprogress .todo { background-color:green } 

(fiddle here: http://jsfiddle.net/uhBW2/5/ ) with a fairly good game with negative margins, it seems like it starts working at some point, but it feels terribly hacky. How to get items to align with each other?

+4
source share
4 answers

Story:

The built-in block inserts the natural space between the elements. In fact, this is, in fact, the width of the space if you hit a space in your content or even typed &nbsp; (html markup space). This space will be smaller or larger depending on your font size .

There are several fixes to this problem, and I personally, like many others, consider this problem a kind of โ€œmistakeโ€ that needs to be fixed. Nevertheless, all corrections for this are very "hacker", so to speak. The decision you choose depends on your personal preferences.

Recommended solution for each specific situation and code:

Just switch to using floats. Instead of setting display: inline-block; do the following:

http://jsfiddle.net/uhBW2/9/

 .mainprogress div{ padding:0; margin:0; float: left; } 

Other solutions:

(Note that in a JDFiddle solution using margin-left first div also moves to the left when it should not. To counteract this problem, you will need to implement a class on this first div and set this value to -4 0 for this div Another solution and my preferred solution would be to use the structural pseudo-class of the :first-child class to select this first div. It is more dynamic and does not require changing the HTML code.

*** Note for other developers: If there are other solutions, please write below and I will add it above. I feel like I'm missing a fifth way to fix this ...

+9
source

Space is created because you set the divs to "display: inline-block".

Read here how to fix it:

http://css-tricks.com/fighting-the-space-between-inline-block-elements/

+2
source

Try using floats instead of the built-in block, broader support and actually works:

http://jsfiddle.net/uhBW2/7/

 .mainprogress { height:60px; border:2px solid black; overflow: hidden; } .mainprogress div{ padding:0; margin:0; float: left; } 
+2
source

You need to add float:left to all the Elements that you need to click together, as shown below:

 .mainprogress { height:60px; border:2px solid black; } .mainprogress div{ padding:0; margin:0; display:inline-block; float:left; } .detailprogress div { height:100%; float:left; } .detailprogress .done { background-color:lightgreen; float:left; } .detailprogress .donelate { background-color:lightpink; float:left; } .detailprogress .late { background-color:red; float:left; } .detailprogress .todo { background-color:green float:left; } 
+1
source

Source: https://habr.com/ru/post/1497804/


All Articles