Use CSS3 to center my div layer

Source: Internet
Author: User

<! DOCTYPE html>
<html>    <head>        <meta charset="UTF-8">        <title>Edith Academy Small example</title>    </head>    <style type="Text/css">/ * Full-frequency transparent div*/of this style settingDiv { position: Absolute ; z-index: 1 ; width: 100% ;/ * The benefit of pressing the% ratio by the available width of the body is that it can be changed with the window size * / height: 100% ;/ * Press the body's available height * /Left : 0% ; top: 0% ; background-color: #000000 ; opacity: 0.3 ;}Div Div{ position: Absolute ; width: 300px ; height: 300px ;Left : 50% ; top: 50% ; transform: translate(-50%,-50%) ;/ * Here is a big part of the main is to set the div will be in accordance with the 50% 50%-way coordinate settings so forget to subtract the height and width of the div display the effect is not in the middle should be translated window 50% of the mouth is equivalent to the width or height divided by 2*/ background-color: White; opacity: 1 ;}Div Div P{ line-height: 200px;             text-align: center;             color: red;             opacity: 1;         font-size: 50px; } </style>    <body>        <div>            <div>                <p>Edith Academy</P>            </div>        </div>    </Body>
</html>

Use CSS3 to center my div layer

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.