cssはブロックレベル要素の水平と垂直の中央を実現する

5322 ワード

     
    <html lang=zh-cn> 
    <head> 
    <meta charset=utf-8> 
    <title>CSS            title> 
    <meta name=description content=CSS            > 
    <meta name=author content=Roc> 
    <meta name=copyright content=Roc> 
    <link rel=shortcut icon href=favicon.ico> 
    <link rel=apple-touch-icon href=custom_icon.png> 
    <meta name=viewport content=width=device-width, user-scalable=no > 
    <link rel=stylesheet href=main.css> 
    <style>
        body{
            background:#aabbcc;
        }

        .loginDiv{
            width:600px;
            border:1px dashed gray;
            border-radius:15px;
            padding:20px;
            position: absolute;
            top: 50%;
            left:50%;
            transform:translateX(-50%) translateY(-50%);
        }
    style>
    <script src=script.js>script> 
    head> 
    <body> 
        <div class="loginDiv">
                   
        div>
    body> 
    HTML>