Notice
Recent Posts
Recent Comments
Link
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

WON.dev

chapter20 : position 본문

WEB.CSS

chapter20 : position

GAWON 2023. 5. 18. 10:21
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
	/*
		position : absolute;

		1. 기준 위치에서 원하는 위치를 직접 지정(top, bottom, left, right)
		2. 기준 위치
			1) 가장 가까운 부모중에 position : relative; 인 요소
			2) 1) 요소가 없으면 화면 전체로 이해
	 */

	.container{
		width: 500px;
		height: 500px;
		margin: 50px;
		border: 1px solid black;
		position: relative;
	}
	.box{
		width: 100px;
		height: 100px;
		position: absolute;
	}
	.red{
		background-color: red;
		top: 0;
		left: 0;
	}
	.orange{
		background-color: orange;
		top: 0;
		right: 0;
	}
	.yellow{
		background-color: yellow;
		bottom: 0;
		left: 0;
	}
	.green{
		background-color: green;
		bottom : 0;
		right: 0;
	}

</style>
</head>
<body>
	<div class="container">
		<div class="box red">빨강 박스</div>
		<div class="box orange">주황 박스</div>
		<div class="box yellow">노랑 박스</div>
		<div class="box green">초록 박스</div>
	</div>
</body>
</html>

'WEB.CSS' 카테고리의 다른 글

chapter22 : z-index  (0) 2023.05.18
chapter21 : position  (0) 2023.05.18
chapter19 : position  (0) 2023.05.18
chapter18 : overflow  (0) 2023.05.18
chapter17 : clear  (0) 2023.05.18