center with "flex"

重éģž

/* CSS reset */
:root {
    box-sizing: border-box;
}

* {
    padding: 0;
    margin: 0;
    box-sizing: inherit;
}

/* body */
body {

    /* flex */
    display: flex;
    justify-content: center;    /* â­ī¸ æ°´åšŗįŊŽä¸­ */
    align-items: center;        /* â­ī¸ åž‚į›´įŊŽä¸­ */
    
    min-height: 100vh;          /* â­ī¸ åŧˇčŋĢäŊŋį”¨å…¨éƒ¨é̘åēĻ */
}

å¯Ļ例

åƒč€ƒ

Last updated

Was this helpful?