I want to create a division with text on the left and an image on the right. The div is about 300px height. I'm trying out different ways but would prefer to follow standards for this kind of format. Thank you.
HTML
<div id="early">
<h3> Napoleon's Origins </h3>
<br>
<br>
<p>Napoleon Bonaparte was born in his family's ancestral home on August 15, 1769.</p>
</div>
CSS
#early {
margin-right: 250px;
height: 250px;
background: url(../images/Napoleon_23yrs.jpg);
background-repeat: no-repeat;
background-position: right;
background-size: 160px 225px;
line-height: 3px;
}
Create a div and apply display:inline-block to the paragraph tag. The image following will automatically align to the right of the text.
HTML:
<div class="content">
<p>Napoleon Bonaparte was born in his family's ancestral home on August 15, 1769.</p>
<img src="DD1_mini.jpg"></img>
CSS:
.content {height:300px; width:auto; }
.content p {display:inline-block; vertical-align:top;}
3+4 = 7 and also 5+2=7 Things are depends how simply you implement. I always use this method -
<p>Lorem ipsum <img src="image.jpg" class="right"></p>
Where css will be
.right { display: inline-block; float: right }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.