How can I make my image in the center of the image?
I have put red boxes where I'd like the text to go, as shown in this image:
Here's my current code in a JSFiddle
HTML
<img src="http://media.steampowered.com/steamcommunity/public/images/avatars/ef/ef866067efc58dc49c7de0a39622eb5d7b6532bd_medium.jpg" />
<span class="target">
<b> <a href="#"/>'Mouse'</a></b> - ' . Mouse . '<br />
</span>
CSS
span.target{
display:inline;
}
Use vertical-align
HTML
<p>
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/85/Smiley.svg/64px-Smiley.svg.png" />
Curabitur ligula non lectus.
</p>
<p>
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/85/Smiley.svg/64px-Smiley.svg.png" />
Curabitur ligula non lectus.
</p>
CSS
img {
vertical-align: middle;
}
IN CSS
=================
.comtent img
{
height:200px;
width:200px;
float:left;
margin-right:20px;
}
.comtent p
{
height: 200px;
width:200px;
margin: 0;
display: table-cell;
vertical-align: middle;
}
IN HTML
==================
<div class="comtent">
<img src="image/App_Sec2.jpg" alt=""/>
<p>
text to be sit in the middle
text to be sit in the middle
</p>
</div>
You could use style="vertical-align:middle;"
on Image and Text. You may need to set the line-height too.
this should work
<img src=".gif" align="middle"> //The align attribute is deprecated in HTML 4, and is not supported in HTML5. Use CSS instead)
<img src=".gif" style="vertical-align:middle;"> //css
try this.. make your html like this.
<img src="http://media.steampowered.com/steamcommunity/public/images/avatars/ef/ef866067efc58dc49c7de0a39622eb5d7b6532bd_medium.jpg" />
<span class="target">
<b> <a href="#">'Mouse'</a></b> - ' . Mouse . '<br />
</span>
make your css like this
span.target{
display:inline;
}
img{vertical-align:middle;}
Assuming the size of the picture is constant, you could try:
<div class="item">
<img src="..." alt=""/>
<p>
text to be sit in the middle
</p>
</div>
CSS:
.item img
{
height:100px;
width:100px;
float:left;
}
.item p
{
display: table-cell;
height: 100px;
margin: 0;
vertical-align: middle;
}
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.