๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๊ฐœ๋ฐœ์–ธ์–ด/JS

[CSS] ํˆฌ๋ช…๋„ ์„ค์ • ํ•˜๋Š”๋ฒ• - opacity / rgba

by yunamom 2022. 4. 10.
728x90
300x250

1. opacity ์†์„ฑ

div{
	background-color : rgb(255,255,255); opacity : 0.5;
}

2. rgba ์†์„ฑ

div{
	background-color : rgb(255,255,255,0.5);
}

div ํƒœ๊ทธ์˜ ํˆฌ๋ช…๋„๋ฅผ 0 ~ 1์˜ ๊ฐ’์œผ๋กœ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋‹ค. 0์— ๊ฐ€๊นŒ์šธ์ˆ˜๋ก ํˆฌ๋ช…ํ•ด์ง„๋‹ค.

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>test</title>
<style>
body{
	background-image: url(img/logo27.png);
}
div{
	margin: 2rem;
	width: 200px;
	height: 200px;
	border: 5px solid #decdad;
	display: inline-block;
	text-align: center;
	font-size: 20px;
}
.test {background-color : rgb(255,255,255,0.1);}
.test2{background-color : rgb(255,255,255,0.2);}
.test3{background-color : rgb(255,255,255,0.4);}
.test4{background-color : rgb(255,255,255,0.6);}
.test5{background-color : rgb(255,255,255,0.8);}
.test6{background-color : rgb(255,255,255,1);}

</style>
</head>
<body>
	<div class = "test">0.1</div>
	<div class = "test2">0.2</div>
	<div class = "test3">0.4</div><br>
	<div class = "test4">0.6</div>
	<div class = "test5">0.8</div>
	<div class = "test6">1</div>

</body>
</html>
728x90
300x250

์ฝ”๋“œ