HTML CSS

KokoaTalk Clone Coding: CSS padding 2

jane.dev 2021. 5. 2. 16:41
반응형

<html>

    <head>

        <style>

              html {

                   background-color: gray;

              }

              body {

                   margin: 0;

                   padding: 20px;

                   background-color: steelblue;

              }

             div {

                   height: 200px;

                   width: 200px;

                   padding: 30px;

               }

               #first { element id="first"

                          ids have to be unique, one element have to have one id

                          the name of id have to be same with html's id

                   background-color: rebeccapurple;

               }

               #second {

                   background-color: olive;

               }

               #third {

                   background-color: peru;

               }

               #fourth {

                   background-color: teal;

               }

        </style>

    </head>

    <body>

        <div id="first">

            <div id="second">

                <div id="third">

                    <div id="fourth"></div>

                </div>

            </div>

        </div>

    </body>

</html>

body padding: 20px, div padding: 30px

 

<html>

    <head>

        <style>

              html {

                   background-color: gray;

              }

              body {

                   margin: 0;

                   padding: 20px;

                   background-color: steelblue;

              }

             div {

                  height: 200px;

                   width: 200px;

                   padding: 30px;

               }

               #first {

                   background-color: rebeccapurple;

                   height: 150px;

                   width: 150px;

               }

               #second {

                   background-color: olive;

                   height: 100px;

                   width: 100px;

               }

               #third {

                   background-color: peru;

                   height: 50px;

                   width: 50px;

               }

               #fourth {

                   background-color: teal;

                   height: 25px;

                   width: 25px;

               }

        </style>

    </head>

    <body>

        <div id="first">

            <div id="second">

                <div id="third">

                    <div id="fourth"></div>

                </div>

            </div>

        </div>

    </body>

</html>

change the width, height each div's ids