Box align with other boxes [duplicate] - html

This question already has answers here:
How to Create Grid/Tile View? [duplicate]
(8 answers)
Closed 5 years ago.
As you can see, that box has less height and I wanted the bottom one to stack with it, is it possible to do it? Any help will be appreciated.
This is the css I have:
<style>
div{
display: inline-block;
margin:0;
position:relative;
top:0;
border:1px solid black;
}
</style>

Just use flex's rule align-items: center.
See this article for more details.

Related

Margin collapse [duplicate]

This question already has answers here:
How do I uncollapse a margin? [duplicate]
(5 answers)
Closed 4 years ago.
How can I disable margin collapse and get 200px margin without changing the HTML?
code:
<style>
div{
font-size: 100px;
border: 10px solid black;
padding: 20px;
margin: 100px;
</style>
<body>
<div>AAAA</div>
<div>AAAA</div>
</body>
Thanks, :D.
Try adding a padding of 0.1px to the body tag, or any parent tag that will include these 2 divs.
This old trick used to disable collision for most cases.
You may want to see an explanation and other solutions here:
How to disable margin-collapsing?

css multiple div does not seem to work together [duplicate]

This question already has answers here:
What is the best way to clear the CSS style "float"?
(14 answers)
Why doesn't the height of a container element increase if it contains floated elements?
(7 answers)
What methods of ‘clearfix’ can I use?
(29 answers)
Closed 4 years ago.
I have this in my css file and html file.
.prodhome-boxshadow{
padding: 10px;
box-shadow: 5px 10px 18px #888888;
}
.prodhome-category {
width:22%;
float:left;
margin:0 1.65% 3.55%;
}
.prodhome-category img {
max-width:60%;
height:auto;
margin:0 5%;
align-content: center;
}
<div class="prodhome-boxshadow">
<div class="prodhome-category">
<h1>Product-title</h1>
<img src="" />
</div>
</div>
<div class="clearrow"></div>
what I get is the box shadow does not encompass the product title and image. Instead I get the box shadow display above where the products are and ends before the Producttiles are displayed. How can I accomplish this?

How to remove space between two div element [duplicate]

This question already has answers here:
Display: Inline block - What is that space? [duplicate]
(5 answers)
Closed 8 years ago.
I got two divs
<div>abc</div>
<div>def</div>
with css as this
div{
display:inline-block;
padding:0px;
margin:0px;
}
body{
padding:0px;
margin:0px;
}
how can i remove the gap/space between first and second div
link for the same http://cssdeck.com/labs/i5oysgmt
Remove the spacing at the code level.
Write like this.
<div>abc</div><div>def</div>
div{
display:inline-block;
padding:0px;
margin-left:-4px;
}
Demo
That is because of the white space in inline-block elements
html
<div>abc</div><div>def</div>
You can read here more

Stop inline-block div contents from forcing other divs out of line. [duplicate]

This question already has answers here:
Why is this inline-block element pushed downward?
(8 answers)
Closed 8 years ago.
I have some divs lined up horizontally and the content in the div is pushing it out of line with the others. How can I make them line up regardless the amount of content? I intend to add overflow:hidden so large content will not destroy the layout. No javascript involved. Needs to work in IE9+ and chrome.
MARKUP
<div class="panels">1</div>
<div class="panels">2</div>
<div class="panels"><img src='\images\img.png' height='64px'></div>
<div class="panels">4</div>
CSS
.panels {
/*line-height:200px; */
display: inline-block;
width:22%;
height: 200px;
margin:5px;
border: 1px solid blue;
}
I have a fiddle
Another saturday stolen by work. :(
Use vertical-align: top on .panels.
http://jsfiddle.net/y9pEV/2/

How to horizontally center a div-block containing images? [duplicate]

This question already has answers here:
How can I horizontally center an element?
(133 answers)
Closed 9 years ago.
I'm trying to horizontally center a div-block containing images (playing cards placed there by Javascript), but somehow it doesn't work (images are still left-aligned). Here's the HTML:
<div id="dealerarea">
<div id="dealercards">
<!--Images by Javascript-->
</div>
</div>
And here's the CSS:
#dealerarea{
position:absolute;
width:100%;
height:96px;
top:15px;
}
#dealercards{
display: block;
margin-left: auto;
margin-right: auto;
}
What i'm doing wrong? Thanks in advance!
Edit: I can't give a fixed "width" to inner div, because it changes every time (depending on the number of card images).
You need to give your #dealercards a width and margin:0 auto ;
#dealercards
{
display: block;
margin:0 auto;width:200px;
}
DEMO HERE