CSS centering those things

Source: Internet
Author: User

First, CSS Vertical center

1.line-height (for single-line text centering)

Eg:html:<p class= "WORDP" >123</p>-

CSS:. Wordp{width:100px;line-height:50px;background:yellow;color: #fff}

2.:befor+inline-block (vertical centering technique for multiple objects)

Eg:html

                       <div class= "Box3" >    & nbsp                      <div class= "content" >    &nbsp ;                       Amos     see the actual <a href= "http:/ /csscoke.com/2015/07/31/nth-child_rwd_album/"&GT;CSS3 Beautiful album effect </a> effect! Do not forget to drag the window to see the RWD effect Oh!                            </div>                        </div>          &NBS P  css:.box3{width:500px;height:250px;border:1px solid #f00; margin:auto;text-align:center;}. Box3::before{content: ';d isplay:inline-block;height:100%;width:0;vertical-align:middle;}. Box3. Content{width:400px;background: #ccc;d isplay:inline-block;vertical-align:middle;}

CSS centering those things

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.