The example in this article describes how CSS implements the vertical alignment of pictures and text in the same line. Share to everyone for your reference. The specific analysis is as follows:
Some friends will find that if there is text in a line of content, text tends to automatically the bottom of the alignment, affect the beautiful, how to make them relative to the vertical center, very simple, is the picture and text in the line to add CSS attributes: Vertical-align:middle; They are centered vertically on the same line.
The
code is as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml" >
<head>
<title> Align the picture and text within the same line vertically in the center </title>
<meta http-equiv= "Content-type" content= "text/html"; Charset=utf-8 "/>
<style>
body{
font-size:9pt;
}
#buttons *{
Vertical-align:middle;
}
/* If the above is not compatible with Firefox and so on, you can add the following sentence!
#buttons *{
Vertical-align:middle;
}
*/
</style>
</head>
<body>
<div id= "Buttons" >
<img src= "/jscss/demoimg/200902/reg.gif" >
<img src= "/jscss/demoimg/200902/login.gif" >
<a href= "#" > Retrieve password </a>
</div>
top of the picture, the text is not all vertically aligned it?
</body>
</html>
I hope this article will help you with the DIV+CSS web design.