나의 생각을 끄적이는 공간

블로그 이미지

Wooni0477

카테고리

  • 분류 전체보기 (118)
    • 프로그래밍 정리 (102)
      • Front (5)
      • Java (2)
      • JSP, Servlet, DB(oracle) (33)
      • JavaScript (0)
      • Spring (22)
      • Oracle (28)
      • Vue (1)
      • API (1)
      • err (5)
      • ERD (1)
      • etc.. (4)
    • BoostCourse (15)
      • HTML/CSS (7)
      • JavaScript (4)
      • JSP (4)
    • 공부 자료들.. (0)
    • 기타 (0)
    • --------------------------- (0)
    • 끄적이는공간.. (0)
      • 이벤트 (0)
      • 여행 (0)

    최근...

  • 포스트
  • 댓글
  • 트랙백
  • 더 보기

CSS - 기본4 (레이아웃, Margin, Border, Padding)

BoostCourse/HTML/CSS 2019. 11. 13. 19:37
반응형


CSS - 기본4 (레이아웃)


1. Margin, Border, Padding 조절



기본적인 범위는 위 그림과 같다.

-auto는 글씨나 콘텐츠 등

-auto는 내용물 사이즈에 따라 자동



-아래 사이트에서 직접 테스트 해볼수 있다.
https://www.w3schools.com/css/tryit.asp?filename=trycss_boxmodel




1) margin 배치

element간의 간격을 조절한다.


예제

test.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
    <link rel="stylesheet" href="test.css"/>

<div class="left">left</div>
<div class="bottom">bottom</div>

</body>
</html>

test.css

.bottom{
    margin-bottom: 100px;
    margin-top: 100px;
}



Output

2) border 배치

해당 태그에 테두리를 그린다.


test.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  
  <link rel="stylesheet" href="test.css"/>
 
  <div class="wrap">
    <div class="static">static</div>
    <div class="relative">relative</div>
    <div class="absolute">absolute</div>
    <div class="fixed">fixed</div>
  </div>
 
</body>
</html>



test.css

.wrap > div{
    border : 1px solid gray;
}



Output



3) Padding 배치


테두리와 내부 값(위 그림 auto) 사이 공백 조절




test.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  
  <link rel="stylesheet" href="test.css"/>
 
  <div class="wrap">
    <div class="static">TEST</div>
   
  </div>
 
</body>
</html>


test.css


.wrap > div{
    padding: 10px;
}




Output









반응형
저작자표시 비영리 변경금지 (새창열림)

'BoostCourse > HTML/CSS' 카테고리의 다른 글

CSS - 기본6 (간단한 메인화면 만들기)  (0) 2019.11.14
css - 기본5 (float, box-sizing)  (0) 2019.11.13
CSS - 기본3 (레이아웃 종류, 블록 엘리먼트)  (0) 2019.11.13
CSS - 기본2 (font)  (0) 2019.11.13
CSS - 기본1 (css 구조, 우선순위, 상속)  (0) 2019.11.13
Posted by Wooni0477
방명록 : 관리자 : 글쓰기
Wooni0477's Blog is powered by daumkakao
Skin info material T Mark3 by 뭐하라
favicon

나의 생각을 끄적이는 공간

  • 태그
  • 링크 추가
  • 방명록

관리자 메뉴

  • 관리자 모드
  • 글쓰기
  • 분류 전체보기 (118)
    • 프로그래밍 정리 (102)
      • Front (5)
      • Java (2)
      • JSP, Servlet, DB(oracle) (33)
      • JavaScript (0)
      • Spring (22)
      • Oracle (28)
      • Vue (1)
      • API (1)
      • err (5)
      • ERD (1)
      • etc.. (4)
    • BoostCourse (15)
      • HTML/CSS (7)
      • JavaScript (4)
      • JSP (4)
    • 공부 자료들.. (0)
    • 기타 (0)
    • --------------------------- (0)
    • 끄적이는공간.. (0)
      • 이벤트 (0)
      • 여행 (0)

카테고리

PC화면 보기 티스토리 Daum

티스토리툴바