I have the following HTML:
<div class="mega_parent">
<div class="parent">
<div class="holder">
<span class="holder_under">Left heading</span>
<div class="holder_options">
<span class="holder_options_1">Option 1</span>
<span class="holder_options_2">Option 2</span>
<span class="holder_options_3">Option 3</span>
</div>
</div>
</div>
</div>
and the following CSS:
.holder {
background-color: blue;
padding: 10px;
}
.holder_under {
padding-left: 10px;
font-size: 16px;
color: #999;
}
.parent {
float: left;
margin-right: 20px;
width: 600px;
}
.mega_parent {
background-color: blue;
margin: 130px auto;
min-height: 320px;
height: 100% auto;
overflow: auto;
width: 940px;
padding: 0px 10px;
}
Question:
How do I make the div with the class holder_options
align in the same line as the span with the class .holder_under
?
Here's what it looks like currently in jsFiddle.
In the wrapping div you should have: display: flex; align-items: center; and remove the display property from both elements.
To get all elements to appear on one line the easiest way is to: Set white-space property to nowrap on a parent element; Have display: inline-block set on all child elements.
As all phrasing content is flow content, it means phrasing element can be used in all of flow content. The phrasing elements can only contain other phrasing elements, for example, you can't put div inside span.
Use a p or div rather than a span. Text is an inline element and so is a span. For text-align to work, it must be used on a block level element (p, div, etc.) to center the inline content.
Div's are by default block level elements. Please read up more about block level elements here.
"Block level elements - Their most significant characteristic is that they typically are formatted with a line break before and after the element (thereby creating a stand-alone block of content)."
Set it to display:inline-block;
.holder_options {
display:inline-block;
}
Working jsFiddle here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With