How to make a gap between two DIV within the same column
Please pay attention to the comments after the 2 lines.
.box1 {
display: block;
padding: 10px;
margin-bottom: 100px; /* SIMPLY SET THIS PROPERTY AS MUCH AS YOU WANT. This changes the space below box1 */
text-align: justify;
}
.box2 {
display: block;
padding: 10px;
text-align: justify;
margin-top: 100px; /* OR ADD THIS LINE AND SET YOUR PROPER SPACE as the space above box2 */
}
Space between two divs in the same row
I would recommend setting border-spacing: 10px;
(or any amount that you'd like) on the parent element that is set to display: table;
. This is the most effective way to space elements that are using table properties.
If you need more control over your spacing than border-spacing provides, you may need to consider using something other than table-cell for your layout, so hopefully that works out for you!
Here's an update to your fiddle demonstrating the use of border-spacing:
http://jsfiddle.net/vBngZ/7/
Space between two divs
You can try something like the following:
h1{
margin-bottom:<x>px;
}
div{
margin-bottom:<y>px;
}
div:last-of-type{
margin-bottom:0;
}
or instead of the first h1
rule:
div:first-of-type{
margin-top:<x>px;
}
or even better use the adjacent sibling selector. With the following selector, you could cover your case in one rule:
div + div{
margin-bottom:<y>px;
}
Respectively, h1 + div
would control the first div after your header, giving you additional styling options.
Adding space between two divs
from your snippet it seems you are using bootstrap, if this is the case then you can add space between two horizontal divs in bootstrap as follow:
<div class="row">
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4 col-md-offset-4">.col-md-4 .col-md-offset-4</div>
</div>
where: col-ms-offset-{value}. add space (as specified) to the left of the div. and you should remember that the size of all divs including offsets, must sum to 12 in bootstrap grid system as the above example.
Add gap between two Divs
A couple of points:
- You shouldn't add extra classes to the Bootstrap columns (that's not a hard and fast rule, but a good recommendation)
- You are missing the container wrap.
Make changes using those rules and it looks like this:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"><script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<div class="container"> <div class="row"> <div class="col-md-6"> <div class="row"> <div class="col-md-12"> <div class="well">Left Top Box</div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="well">Left Bottom Box</div> </div> </div> </div> <div class="col-md-6"> <div class="well">Right Box</div> </div> </div></div>
decreasing the space between two divs
In your CSS, add this:
.row {
margin-bottom: -20px;
}
The row you added inside the html, it's margin-bottom can be removed by saying -20px or any other negative number you prefer.
Hope it helps.
Related Topics
Css Absolute Position With X Scrolling
How to Avoid Element from Expanding When Its Content Text Font-Size Gets Bigger
Mp4 Video Is Not Playing on Mobile Devices and Chrome
Wrapping Text Inside Input Type="Text" Element Html/Css
How to Center Text (Horizontally and Vertically) Inside a Div Block
When Flexbox Items Wrap in Column Mode, Container Does Not Grow Its Width
≪Button≫ Vs. ≪Input Type="Button" /≫. Which to Use
Stylesheet Not Loaded Because of Mime-Type
Setting the Width of Inline Elements
How to Embed an External Webpage Without Using Iframe
How to Manually Trigger Click Event in Reactjs
How to Make Flex Box Work in Safari
Html5 Input Type Date Format to Mm/Dd/Yyyy Causing Issue in Chrome
How to Change Bootstrap 4 Drop-Down Colors
Can Multiple Different HTML Elements Have the Same Id If They'Re Different Elements
How to Set the Default Value For an HTML ≪Select≫ Element