开发者

How do I get these to align side by side horizontally using css?

开发者 https://www.devze.com 2023-02-02 10:07 出处:网络
When i display below, the text \'Here is some text\' is below the image - i want it to show to the right of the image?

When i display below, the text 'Here is some text' is below the image - i want it to show to the right of the image?

<div st开发者_运维问答yle="width:50px;">
  <img src="http://assets.devx.com/MS_Azure/azuremcau.jpg" alt="blah" width="70" height="70" />
</div>

<div style="width:150px;">
  <h2>Here is some text</h2>
</div>


<div style="width:50px; display: inline-block;">
<img src="http://assets.devx.com/MS_Azure/azuremcau.jpg" alt="blah" width="70" height="70" />
</div>

<div style="width:150px; display: inline-block">
    <h2>Here is some text</h2>
</div>

changed float:left to display:inline-block. This is a better solution because it doesn't remove items from the document flow. Make sure you specify a width for every one though.


<div style="float: left; margin-right: 10px;">
    <img src="http://assets.devx.com/MS_Azure/azuremcau.jpg" alt="blah" width="70" height="70" />
</div>
<div style="width: 300px;">
    <h2>Here is some text</h2>
</div>
<br style="clear: both;" />

This should work.

0

精彩评论

暂无评论...
验证码 换一张
取 消