css

개발자 macan·2022년 4월 6일
0

개발 - 공부

목록 보기
15/28

css에 대해 알아보자

전시간의 퀴즈 코드에서 css를 활용하여 꾸며보자.
css는

  • padding과 margin의 차이
  • padding은 내 지정공간 안으로 여백을 둔다.
  • margin은 내 지정공간 밖으로 여백을 둔다.
    • html은 글속성과 박스속성이 있다.
    • 박스는 글과 달리 가로세로 개념이 존재
    • 따라서 글을 박스로 강제로 묶어야한다.
    • 그 방법이 바로 display: block;
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>로그인페이지</title>
        <style>
            .wrap {
                width: 250px;
                margin: auto;
            }
            .mytitle {
                background-color: green;
    
                width: 300px;
                height: 200px;
    
                color: white;
                text-align: center;
    
                background-image: url("https://www.ancient-origins.net/sites/default/files/field/image/Agesilaus-II-cover.jpg");
                background-size: cover;
                background-position: center;
    
                border-radius: 10px;
    
                padding-top: 20px;
            }
    
            .mybtn {
                width: 100px;
                margin: auto;
                display: block;
            }
    
            .red-font {
                color: red;
                font-size: 16px;
            }
        </style><!--div 태그에서 명찰을 지정한 class에 대해 스타일 지정-->
    
    </head>
    <body>
    <div class="wrap">
        <div class="mytitle">
            <h1>로그인 페이지</h1>
            <h5>아이디, 패스워드를 입력해주세요</h5>
        </div>
    
        <p>ID: <input type="text"/></p>
        <p>PW: <input type="password"></p>
        <button class="mybtn red-font">로그인하기</button>
    </div>
    
    
    </body>
    </html>
    
    

    *주석은 ctrl + /를 하면 된다

    파일 분리법
    css파일로 기존 html파일의 style 코드를 가져온다.
    그 후에 html파일에 < link rel="stylesheet" type="text/css" href = "mystyle.css" > 하면 된다.

    profile
    개발자로 첫걸음

    0개의 댓글