Three divs side by side with spacing in between
You might be better using a flexbox to achieve what you need. Create a container for the three .box divs, and style it with the following:
display:flex;
justify-content:space-between;
Keep in mind that the width of your .box divs will need to be lowered to achieve the space you want and that you would not require the float:left; in the css.
For more info on flexboxes, click here: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
Three divs side by side but no auto margin between them
Make sure you're using box-sizing
so that the padding
is being calculated properly. You'll also likely want to utilize a media query in order to achieve your goal of their being fewer side-by-side elements on smaller screens.
https://jsfiddle.net/a6ry5m7v/
There are certainly more modern approaches (such as flex
containers) but based on your original comments this seems to be the approach you were expecting
divs side by side with space between
You may need to use float:left
to align two DIVs side by side
<div style="height: 160px; width: 100%; box-sizing:border-box; display:table;">
<div class="introwrapper" style="float:left;margin-right:30px; height:100%; width:25%;display:table-cell;background: pink;box-sizing: border-box;">First Div</div>
<div class="introwrapper" style="float:left;height:100%; width:25%;display:table-cell; background: blue; box-sizing: border-box;">second div</div>
<br style="clear:left" />
</div>
How to make 3 divs side by side
try this one. position: absolute;
.container {
border: 1px solid;
position: relative;
overflow: hidden;
}
.container div {
height: 50px;
width: 50px;
background: red;
display: inline-block;
}
#div1 {
float: left;
}
#div3 {
float: right;
}
#div2 {
position: absolute;
left: 0;
right: 0;
margin: auto;
}
<div class="container">
<div id="div1"></div>
<div id="div2">he</div>
<div id="div3"></div>
</div>
css - align side by side 3 divs of different sizes
Use display: flex;
on my-container
and remove inline-block
from child elements
.my-container {
display: flex;
width: 400px;
height: 50px;
background-color: green;
}
.left {
width: 50px;
height: 50px;
background-color: red;
}
.middle {
width: 300px;
height: 50px;
background-color: blue;
}
.right {
width: 50px;
height: 50px;
background-color: yellow;
}
<div class="my-container">
<div class="left"></div>
<div class="middle"></div>
<div class="right"> </div>
</div>
Related Topics
Change Checkbox Check Image to Custom Image
How to Use the Same Meta Tag for Opengraph and Schema.Org
What's the Difference Between HTML's and CSS's Width Attribute
Understanding Grid Negative Values
How to Save a File from a Website as PDF
How to Apply CSS Stylesheet to Single Specific Element
CSS Not Modifying Link Properties
Making All Images Appear with the Same Height in Bootstrap
Changing the Text Selection Color Using CSS
How to Put a <Style>...</Style> Tag Within the Body of a HTML File to Send in Email
Html.Dropdownlistfor() with Custom Parameter
Border with a Transparent Centred Arrow
How to Render a Field Request Without Refreshing the Page
Aligning Elements in Last Flexbox Row
Make Flex Item Wrap to the Next Row with Following Items Continuing the Flow