CSS to achieve vertical alignment of pictures and text on the same line

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.