Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have two div of col-md-6 spread over entire width page , I want to create gap between them of desired distance between them please help me how to do that??

HTML
<div class=" col-lg-6  col-md-6 col-sm-12 col-xs-12 Usage">
</div>

<div class=" col-lg-6  col-md-6 col-sm-12 col-xs-12 BillPayment">
</div>


What I have tried is offset, Putting them in a class margin, padding unsuccessfully.

thanks in advance
Posted
Updated 28-Jan-16 3:05am
v2
Comments
Sinisa Hajnal 28-Jan-16 2:42am    
Show relevant markup and CSS, margin should do the trick if there is space for the elements and they are not inline. Try setting display: inline-block.
Richard Deeming 28-Jan-16 9:06am    
I've fixed your code formatting. Code blocks need to be enclosed in <pre>...</pre> tags, and the tags need to be HTML-encoded - &lt; instead of <, &gt; instead of >, etc.

1 solution

Using Bootstrap, you have 12 "units" in the page width. This means that if you have 2 columns of md-6 (which is half the screen width on a display of 992px+), you will never have a gap between them.

If you need the whitespace on a medium+ display, introduce a column between them and change their widths, like so:
HTML
<div class="col-md-5"></div><!--Content Element -->
<div class="col-md-2"></div><!--Spacing Element -->
<div class="col-md-5"></div><!--Content Element -->


With this we still have our 12 column units, but with a responsive gap between.

For more information about the Bootstrap grid system, get it from the horses mouth at:
CSS &middot; Bootstrap[^]
 
Share this answer
 
Comments
Member 12139960 28-Jan-16 8:17am    
Thanks for solution
I have tried this but it gives too much space between two div
Nathan Minier 28-Jan-16 8:51am    
In that case, you can create a custom css class to handle the spacing div based on the col-md classes but with a different width percentage.

For instance:
col-md-spacer{
position: relative;
min-height: 1px;
padding-right: 15px;
padding-left: 15px;
float: left;
width: 10%; /* Tweak this as needed */
}

Bear in mind, your screen is just your screen, and it will look different on user computers, tablets, and phones. The entire point of the Bootstrap grid system is to lend some consistency to design and layout, regardless of screen differences. Using a custom layout class like this breaks that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900