color 2
<style>
body{
background: #222;
}
.text1{color: rgb(255, 255, 255);}
/* 투명도 0.8 */
/* 0: 완전투명, 1:불투명 */
.text2{color: rgb(255, 255, 255, 0.8);}
.text3{color: rgb(255, 255, 255, 0.5);}
/* .text4{color: rgb(255, 255, 255 0.2);} */
/* 소수점 0을 생략 가능 */
.text4{color: rgb(255, 255, 255, .2);}
</style>
</head>
<body>
<h1 class="text1">HTML+CSS3</h1>
<h1 class="text2">HTML+CSS3</h1>
<h1 class="text3">HTML+CSS3</h1>
<h1 class="text4">HTML+CSS3</h1>
</body>
bg-color
<title>Document</title>
<style>
body{
/* background-color: #0099ff; */
/* 중복 생략 */
background-color: #09ff;
}
div{
background-color: white;
width: 90%;
padding: 15px;
border: 1px solid black;
}
p{line-height: 30px;}
</style>
</head>
<body>
<div>
<h1>초콜릿(Chocolate)</h1>
<p>
초콜릿은 카카오 콩을 재료로 가공한 식품이다.
초콜릿은 카카오 콩을 재료로 가공한 식품이다.
초콜릿은 카카오 콩을 재료로 가공한 식품이다.
초콜릿은 카카오 콩을 재료로 가공한 식품이다.
초콜릿은 카카오 콩을 재료로 가공한 식품이다.
</p>
</div>
</body>
bg-clip
<style>
div{
width: 300px;
border: 5px dotted #222;
background: skyblue;
padding: 35px;
/* 테두리 아래 여백 : 20px */
margin-bottom: 20px;
}
.bg1{
/* 배경색이 테두리까지 */
background-clip: border-box;
}
.bg2{
/* 배경색이 테두리전, 패딩까지 */
background-clip: padding-box;
}
.bg3{
/* 배경색이 패딩전, 내용까지 */
background-clip: content-box;
}
</style>
</head>
<body>
<div class="bg1">
<p>
<strong>토마토:</strong>
토마토는 비타민 A,C가 풍부할 뿐 아니라 희귀한 성분이 비타민 H와 P까지 포함된 과일이다.
토마토는 비타민 A,C가 풍부할 뿐 아니라 희귀한 성분이 비타민 H와 P까지 포함된 과일이다.
토마토는 비타민 A,C가 풍부할 뿐 아니라 희귀한 성분이 비타민 H와 P까지 포함된 과일이다.
토마토는 비타민 A,C가 풍부할 뿐 아니라 희귀한 성분이 비타민 H와 P까지 포함된 과일이다.
</p>
</div>
<div class="bg2">
<p>
<strong>토마토:</strong>
토마토는 비타민 A,C가 풍부할 뿐 아니라 희귀한 성분이 비타민 H와 P까지 포함된 과일이다.
토마토는 비타민 A,C가 풍부할 뿐 아니라 희귀한 성분이 비타민 H와 P까지 포함된 과일이다.
토마토는 비타민 A,C가 풍부할 뿐 아니라 희귀한 성분이 비타민 H와 P까지 포함된 과일이다.
토마토는 비타민 A,C가 풍부할 뿐 아니라 희귀한 성분이 비타민 H와 P까지 포함된 과일이다.
</p>
</div>
<div class="bg3">
<p>
<strong>토마토:</strong>
토마토는 비타민 A,C가 풍부할 뿐 아니라 희귀한 성분이 비타민 H와 P까지 포함된 과일이다.
토마토는 비타민 A,C가 풍부할 뿐 아니라 희귀한 성분이 비타민 H와 P까지 포함된 과일이다.
토마토는 비타민 A,C가 풍부할 뿐 아니라 희귀한 성분이 비타민 H와 P까지 포함된 과일이다.
토마토는 비타민 A,C가 풍부할 뿐 아니라 희귀한 성분이 비타민 H와 P까지 포함된 과일이다.
</p>
</div>
</body>
bg-img
<style>
body{
background-image: url(images/bg1.png);
}
</style>
</head>
<body>
</body>
bg-size
<style>
div{
width: 500px;
height: 500px;
margin-bottom: 20px;
/* double 이중실선 */
border: 2px double black;
}
.bg1{
background: url(images/bg4.jpg);
/* auto : 기본값 */
background-size: auto;
}
.bg2{
/* 기본은 이미지 반복 */
/* background-image: url(images/bg4.jpg); */
/* no-repeat : 반복안함 */
background: url(images/bg4.jpg) no-repeat;
background-size: 200px 150px;
}
.bg3{
background: url(images/bg4.jpg) no-repeat;
background-size: 60% 40%;
}
.bg4{
background: url(images/bg4.jpg) no-repeat;
/* 원본 이미지가 가로가 길어서 아래 여백이 생김 */
background-size: contain;
}
.bg5{
background: url(images/bg4.jpg) no-repeat;
/* 여백을 늘리면서 채워서 오른쪽이 짤림 */
background-size: cover;
}
.bg6{
background: url(images/bg4.jpg) no-repeat;
/*억지로 비율을 맞추면서 세로로 홀쭉해짐 */
background-size: 100% 100%;
}
</style>
</head>
<body>
<div class="bg1"></div>
<div class="bg2"></div>
<div class="bg3"></div>
<div class="bg4"></div>
<div class="bg5"></div>
<div class="bg6"></div>
</body>
bg-position
<style>
div{margin-bottom: 20px;}
button{
width: 140px;
height: 50px;
background-color: rgb(0, 110, 255);
border: 1px solid rgb(0, 110, 255);
color: #fff;
font-weight: bold;
/* 테두리 꼭지점 부분을 둥글게 처리 */
border-radius: 8px;
}
#bg1{
background-image:url(images/light.png);
background-repeat: no-repeat;
/* 가로 세로 px 만큼 배치 */
background-position: 5px 7px;
}
#bg2{
background-image:url(images/light.png);
background-repeat: no-repeat;
/* 수평은 오른쪽, 수직은 가운데 */
background-position: right center;
}
</style>
</head>
<body>
<div>
<button id="bg1">
IDEA
</button>
</div>
<div>
<button id="bg2">
IDEA
</button>
</div>
</body>
bg-origin
<style>
div{
border: 15px solid #ccc;
width: 400px;
height: 200px;
margin-bottom: 20px;
padding: 35px
}
.bg1{
background: url(images/bg3.jpg) no-repeat;
/* padding-box 는 기본값 */
/* 패딩까지 적용 */
background-origin: padding-box;
}
.bg2{
background: url(images/bg3.jpg) no-repeat;
/* 테두리까지 이미지가 표시하므로, 보이지 않는 부분이 발생 */
background-origin: border-box;
}
.bg3{
background: url(images/bg3.jpg) no-repeat;
/* 패딩을 제외한 내용까지 적용 */
background-origin: content-box;
}
</style>
</head>
<body>
<div class="bg1"></div>
<div class="bg2"></div>
<div class="bg3"></div>
</body>
bg-attachment
<style>
body{
background-image: url(images/bottom-bg.jpg);
background-repeat: no-repeat;
background-position: center bottom;
background-attachment: fixed;
}
div{
width: 300px;
padding: 20px;
/* top:20px right:auto bottom:20px left:auto */
/* margin: 20px auto 20px auto; */
/* 바라보는 쪽 대비해서 생략 가능 */
margin: 20px auto ;
}
h1{
background-color: #222;
color: white;
text-align: center;
padding: 10px;
}
</style>
</head>
<body>
<div>
<h1>HTML</h1>
<P>
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Tenetur doloremque rerum ducimus maiores nobis?Consectetur pariatur voluptatibus provident repellat commodi explicabo rem et quas non, quasi maiores. Minus, magni dolorum.
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Tenetur doloremque rerum ducimus maiores nobis?Consectetur pariatur voluptatibus provident repellat commodi explicabo rem et quas non, quasi maiores. Minus, magni dolorum.
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Tenetur doloremque rerum ducimus maiores nobis?Consectetur pariatur voluptatibus provident repellat commodi explicabo rem et quas non, quasi maiores. Minus, magni dolorum.
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Tenetur doloremque rerum ducimus maiores nobis?Consectetur pariatur voluptatibus provident repellat commodi explicabo rem et quas non, quasi maiores. Minus, magni dolorum.
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Tenetur doloremque rerum ducimus maiores nobis?Consectetur pariatur voluptatibus provident repellat commodi explicabo rem et quas non, quasi maiores. Minus, magni dolorum.
</P>
</div>
<div>
<h1>CSS3</h1>
<P>
Lorem ipsum dolor sit amet consectetur adipisicing elit.
이하 생략
</P>
</div>
<div>
<h1>Javascript</h1>
<P>
Lorem ipsum dolor sit amet consectetur adipisicing elit.
이하 생략
</P>
</div>
</body>
linear-position
<style>
div{
width: 500px;
height: 300px;
}
.grad{
/* 그라데이션 : 오른쪽 아래로, 파란색에서 흰색으로 */
background: linear-gradient(to right bottom, blue, white);
}
</style>
</head>
<body>
<div class="grad"></div>
</body>
linear-degree
<style>
div{
width: 500px;
height: 300px;
border-radius: 10px;
}
.grad{
/* 그라데이션 : 42도로 빨간색에서 흰색으로 */
background: linear-gradient(45deg, red, #ffffff);
}
</style>
</head>
<body>
<div class="grad"></div>
colorstop
<style>
div{
width: 500px;
height: 300px;
border-radius: 10px;
}
.grad{
/* 그라데이션 : 30% 지점에서흰색으로 중지점 */
background: linear-gradient(to bottom, #06f, white 30%, #06f);
}
</style>
</head>
<body>
<div class="grad"></div>
</body>
redial-default
<style>
div{
width: 500px;
height: 300px;
border-radius: 10px;
margin: 10px;
}
.grad1{
/* 그라데이션 : 타원형으로 중심점이 흰색에서 노란색으로 */
background: radial-gradient(white, yellow, red);
}
.grad2{
/* 그라데이션 : 원형으로 중심점이 흰색에서 노란색으로 */
background: radial-gradient(circle, white, yellow, red, blue);
}
</style>
</head>
<body>
<div class="grad1"></div>
<div class="grad2"></div>
</body>
radial-position
<style>
div{
width: 500px;
height: 300px;
border-radius: 10px;
margin: 10px;
}
.grad1{
/* 그라데이션 : 원형으로 중심점이 가로세로 10% 지점에서 시작해서
흰색에서 파란색으로 */
background: radial-gradient(circle at 10% 10%, white, blue);
}
</style>
</head>
<body>
<div class="grad1"></div>
<div class="grad2"></div>
</body>
repeat-gradient
<style>
div{
width: 500px;
height: 300px;
border-radius: 10px;
margin: 10px;
}
.grad1{
/* 노란색으로 시작해서 20px까지, 그 지점에서
빨간색으로 시작해서 40px까지 */
background: repeating-linear-gradient(yellow, yellow 20px, red 20px, red 40px);
}
</style>
</head>
<body>
<div class="grad1"></div>
<div class="grad2"></div>
</body>
수업자료
'HTML CSS' 카테고리의 다른 글
CSS-레이아웃 (0) | 2024.04.12 |
---|---|
CSS_박스모델 (0) | 2024.04.12 |
CSS - 텍스트 관련 스타일 (1) | 2024.04.12 |
HTML - CSS기초 (0) | 2024.04.10 |
HTML - form 태그 관련 (0) | 2024.04.10 |