I’m not quite why the two blocks below (section.structure and section.specificity) are not lining up. When I reduce the width (past a certain number, not sure exactly what number this is) they line up.
I need the width around 500px (or each block taking up approximately half the width of the screen) but when I do this they stack on top of each other. Any ideas?
HTML
<main>
<section class= "structure">
</section>
<section class= "specificity">
</section>
CSS
section.structure {
border-radius: 20px;
height: 500px;
width: 500px;
background-color: rgb(255, 255, 255);
margin: 10px;
border: rgb(245,245, 245);
display: inline-block;
}
section.specificity {
border-radius: 20px;
height: 500px;
width: 500px;
background-color: rgb(255, 255, 255);
margin: 10px;
border: rgb(245,245, 245);
display: inline-block;
}
Changing width measurements, vertical-align. No change.
2
Answers
If you are not restricted to using
display: inline-block
you can use flexbox.If you need to create space between the two elements you can use the
gap
property. Also I’d advise against setting fixedheight
andwidth
in pixels as you can have problems with the layout being responsiveHTML:
How about something like this? It also uses flexbox like the previous answer. I use https://suiq.jp/flex-layout-generator/ for reference.