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; }
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.
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>
A simple font-size:0
to the parent element will work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With