728x90
위치
*웹 요소의 위치를 정하는 left, right, top, bottom
left : 기준 위치와 요소 사이에 왼쪽으로 얼마나 떨어져 있는지 지정
right : 기준 위치와 요소 사이에 오른쪽으로 얼마나 떨어져 있는지 지정
top : 기준 위치와 요소 사이에 위쪽으로 얼마나 떨어져 있는지 지정
bottom : 기준 위치와 요소 사이에 위쪽으로 얼마나 떨어져 있는지 지정
*배치 방법을 지정하는 position
position : static; : 문서의 흐름에 맞춰 배치. 기본값
position : relative; : 위치값을 지정할 수 있다는 점을 제외하면 static과 같음
position : absolute; : relative값을 사용한 상위 요소를 기준으로 위치를 지정해 배치
position : fixed : 브라우저 창을 기준으로 위치를 지정해 배치
<style>
#pos1{
position: absolute;
left: 50px;
top: 50px;
width: 200px;
height: 200px;
border: 1px dotted black;
}
#pos2{
position: absolute;
right: 100px;
top: 100px;
width: 200px;
height: 200px;
border: 1px dotted black;
}
#pos3{
position: absolute;
left: 100px;
bottom: 100px;
width: 200px;
height: 200px;
border: 1px dotted black;
}
</style>
</head>
<body>
<p id="pos1">1.본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
</p>
<p id="pos2">2.본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
</p>
<p id="pos3">3.본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
</p>

<style>
#static{
width: 300px;
height: 200px;
border: 1px dotted silver;
position: static;
}
#relative1{
width: 300px;
height: 200px;
border: 1px dotted silver;
position: relative;
}
#relative2{
width: 300px;
height: 200px;
border: 1px dotted silver;
position: relative;
left: 100px;
top: -50px;
}
#fixed{
width: 100px;
height: 100px;
background-color: pink;
position: fixed;
right: 30px;
top: 30px;
}
</style>
</head>
<body>
<p id="static">1.본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
</p>
<p id="relative1">2.본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
</p>
<p id="relative2">3.본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
</p>
<p id="fixed"></p>
</body>

연습1)
<style>
/* id="section" 너비 800px, 왼쪽 오른쪽 가운데 */
#section{
width: 800px;
margin: 0px auto;
}
/* h2 글자크기 1.5em */
h2{
font-size: 1.5em;
}
/* h3 글자크기 1.0em */
h3{
font-size: 1.0em;
}
/* p 글자크기 12px, 줄간격 20px */
p{
font-size: 12px;
line-height: 20px;
}
/* id="footer" 너비 100%, 높이 50px, 배경색 #222 */
#footer{
width: 100%;
height: 50px;
background-color: #222;
clear: left;
}
/* id="footer" 안에 p태그 글자색 #fff, 글자크기 0.9em, 글자 가운데 정렬,
줄간격 50px */
#footer p{
color: #fff;
font-size: 0.9em;
text-align: center;
/* 위아래 가운데 => 줄간격 50px height: 50px; 일치*/
line-height: 50px;
}
#article{
float: left;
width: 350px;
height: 200px;
margin: 10px;
padding: 10px;
border: 1px solid #ccc;
}
</style>
</head>
<body>
<div id="section">
<h2>강아지 용품 준비하기</h2>
<div id="article">
<h3>강아지 집 </h3>
<p>강아지가 편히 쉴 수 있는 포근한 집이 필요합니다. 강아지의 집은 강아지가 다 큰 후에도 계속 쓸 수 있는 집으로 구입하세요.집을 구입하실 때는 박음질이 잘 되어 있는지, 세탁이 간편한 제품인지 꼭 확인하시고 고르시는 것이 좋습니다.</p>
</div>
<div id="article">
<h3>강아지 먹이 </h3>
<p>강아지의 먹이는 꼭 어린 강아지용으로 나와있는 사료를 선택하세요. 강아지들은 사람에 비해 성장속도가 8배정도 빠르답니다. 따라서 강아지에게는 성장속도에 맞는 사료를 급여하셔야 합니다. 사람이 먹는 음식을 먹게 되면 양념과 향신료에 입맛이 익숙해지고, 비만이 될 가능성이 매우 높아집니다. 강아지용 사료는 생후 12개월까지 급여하셔야 합니다.</p>
</div>
<div id="article">
<h3>밥그릇, 물병 </h3>
<p>밥그릇은 쉽게 넘어지지 않도록 바닥이 넓은 것이 좋습니다.물병은 대롱이 달린 것으로 선택하세요. 밥그릇에 물을 주게 되면 입 주변에 털이 모두 젖기 때문에 비위생적이므로 대롱을 통해서 물을 먹을 수 있는 물병을 마련하시는 것이 좋습니다.</p>
</div>
<div id="article">
<h3>이름표, 목줄</h3>
<p>강아지를 잃어버릴 염려가 있으니 산책할 무렵이 되면 이름표를 꼭 목에 걸어주도록 하세요. 그리고 방울이 달린 목걸이를 하고자 하실 때는 신중하셔야 합니다. 움직일 때마다 방울이 딸랑 거리면 신경이 예민한 강아지들에게는 좋지 않은 영향을 끼칠 수 있기 때문입니다.</p>
</div>
<div id="footer">
<p>boxmodel 연습하기</p>
</div>
</div>

배경이미지
*웹 요소에 배경 이미지를 넣는 background-image
background-image : url('이미지 파일 경로')
<style>
body{
background-image: url(cat.jpg);
/* 이미지 반복 repeat , repeat-x , repeat-y */
background-repeat: no-repeat;
/* 수평위치 left center right % px
수직위치 top center bottom % px */
background-position: left bottom;
background-position: right top;
/* 브라우저 기준 고정 fixed, scroll(기본값) */
background-attachment: scroll;
background-size: 200px 100px;
}
</style>
</head>
<body>
<p id="static">1.본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
</p>
<p id="relative1">2.본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
</p>
<p id="relative2">3.본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용본문내용
</p>

연습2)
<style>
/* body 배경색 #02233b */
body{
background-color: #02233b;
}
/* id="container" 왼오른쪽 가운데, 너비 600px, 높이 700px
테두리선 1px 점선 gray , 안여백 20px, 배경색 흰색,
배경이미지 mic.png, 반복하지 않고 , 오른쪽 아래 고정
*/
#container{
margin: 0px auto;
width: 600px;
height: 700px;
border: 1px dotted gray;
padding: 20px;
background-color: white;
background-image: url(mic.png);
background-repeat: no-repeat;
background-position: right bottom;
}
/* h1태그 배경색 #004344, 글자색 흰색, 글자는 가운데 정렬, 안여백 20px*/
h1{
background-color: #004344;
color: white;
text-align: center;
padding: 20px;
}
/* h2태그 글자는 가운데 정렬, 글자 기울임, 아래 밖여백 50px */
h2{
text-align: center;
font-style: italic;
margin-bottom: 50px;
}
/* h3태그 글자색 #cf3b00 */
h3{
color: #cf3b00;
}
/* ul 밖여백 20px, 리스트 스타일 없음 */
ul{
margin: 20px;
list-style:none;
}
/* li 줄간격 30px */
li{
line-height: 30px;
}
</style>
</head>
<body>
<div id="container">
<h1>대학언론사 수습기자 모집</h1>
<h2>신입생 여러분을 기다립니다</h2>
<h3>모집분야</h3>
<ul>
<li>아나운서(0명) : 학내 소식을 라디오 방송으로 보도</li>
<li>오프닝쇼프로듀서(0명) : 라디오 방송 기획, 제작</li>
<li>엔지니어(0명) : 라디오 방송 녹음 및 편집 </li>
</ul>
<h3>혜택</h3>
<ul>
<li>수습기자 활동 중 소정의 활동비 지급</li>
<li>정기자로 진급하면 장학금 지급</li>
</ul>
</div>

728x90
'KDT > WEB' 카테고리의 다른 글
231117 WEB - CSS7 (0) | 2023.11.17 |
---|---|
231116 WEB - CSS6 선택자, 클래스 (0) | 2023.11.17 |
231113 WEB - CSS4 (0) | 2023.11.13 |
231110 WEB - CSS3 (0) | 2023.11.10 |
231109 WEB - CSS2 우선순위 및 텍스트 스타일 (0) | 2023.11.09 |