Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove extra margin space generated by inline blocks? [duplicate]

Tags:

css

I am using this css to format two columns but I am still getting margin space between two. I can eliminate it with use of margin-left: -4px; or some such. Is there a more elegant way to do this or is there something wrong with the CSS code?

div.col1{   display: inline-block;   min-height: 900px;   height: 100%;   width 300px;   margin: 0px;   background-color: #272727;   overflow: hidden;   border: 1px dotted red; }  div.col2{   display: inline-block;   min-height: 900px;   height: 100%;    width: 620px;   margin: 0px;    vertical-align: top;   border: 1px dotted red;   overflow: hidden; } 
like image 594
Pavel Zaitsev Avatar asked Nov 26 '09 04:11

Pavel Zaitsev


People also ask

How do I get rid of extra space in HTML?

Approach 1: We can remove space between any two tags by simply using margin-bottom property. The margin-bottom property sets the bottom margin of an element. We will assign a negative value to the margin-bottom of a particular tag to eliminate the extra space between the tags as shown.


2 Answers

Perhaps you have:

<div class="col1">     Stuff 1 </div> <div class="col2">     Stuff 2 </div> 

? If so then this is probably a whitespace problem (it turns out whitespace does matter in html). This should fix it:

<div class="col1">     Stuff 1 </div><div class="col2">     Stuff 2 </div> 
like image 129
Caleb Avatar answered Sep 28 '22 04:09

Caleb


A simple font-size:0 to the parent element will work.

like image 21
Shahen Avatar answered Sep 28 '22 05:09

Shahen