[Day5] CSS 5 [11/16]
[๋กค์ค๋ฒํจ๊ณผ]
<button>๋ง์ฐ์ค ๋กค์ค๋ฒํจ๊ณผ</button>
<button>๋ง์ฐ์ค ๋กค์ค๋ฒํจ๊ณผ</button>
<button>๋ง์ฐ์ค ๋กค์ค๋ฒํจ๊ณผ</button>
js
//1. js ๋ก ๋ชจ๋ button ์์ ์ป์ด์์ผ ๋๋ค.
//var btns = document.getElementsByTagName("button");
//alert( btns.length );
var btns = document.querySelectorAll("button");
// alert( "๋ฒํผ ์ : " + btns.length );
// 2. ๋ง์ฐ์ค๋ฅผ ์ฌ๋ฆด๋( mouseover ) ๋ฐฐ๊ฒฝ์ - ํ๋ js ์ฝ๋ฉ.
for (var i = 0; i < btns.length; i++) {
btns[i].onmouseover = function (){
// console.log( "btn mouseover ์ด๋ฒคํธ ๋ฐ์.");
// ์ด๋ฒคํธ๋ฅผ ๋ฐ์ ๋ฒํผ ๊ฐ์ฒด ?
event.srcElement.style.backgroundColor = "blue";
}
btns[i].onmouseout = function (){
this.style.backgroundColor = "red";
}
} // for
jquery
/*
$("button").mouseover(function() {
$(this).css("background-color", "blue");
});
$("button").mouseout(function() {
$(this).css("background-color", "red");
});
*/
// ์ฒด์ด๋
/*
$("button")
.mouseover(function() {
$(this).css("background-color", "blue");
})
.mouseout(function() {
$(this).css("background-color", "red");
});
*/
// jquery method - hover() ๋ฉ์๋
$("button").hover(
function (){ // mouseover
$(this).css("background-color", "blue");
} ,
function (){ // mouseout
$(this).css("background-color", "red");
}
);
css ๋๋กญ๋ค์ด ์ด๋ฏธ์ง
- ๋๋กญ๋ค์ด ์์ ์์ ์ด๋ฏธ์ง ๋ฐ ๊ธฐํ ์ฝํ ์ธ ๋ฅผ ์ถ๊ฐํ๋ ๋ฐฉ๋ฒ.
- ๋ง์ฐ์ค ์ด๋ฏธ์ง ์๋ก ์ฌ๋ฆด ๋.. ์ฒ๋ฆฌ
<style>
.dropdown{
position: relative;
display: inline-block;
left: 200px;
}
.dropdown-contnt{
display: none;
position: absolute;
z-index: 1;
background-color: #f9f9f9;
min-width: 160px;
box-shadow:0 8px 16px 0 rgba(0,0,0,0.2);
padding:12px 16px;
}
.dropdown:hover .dropdown-contnt{
display: block;
}
</style>
<!-- .dropdown>span+.dropdown-contnt -->
<div class="dropdown">
<img src="../images/img_5terre.jpg" alt="" style="width: 100px;height:50px">
<div class="dropdown-contnt">
<img src="../images/img_5terre.jpg" alt="" style="width: 300px;height:150px">
<div class="desc">์ด๋ฏธ์ง ์ค๋ช
</div>
</div>
</div>
๋ฉ๋ด๋ฐ(nav bar) + ๋๋กญ๋ค์ด ๋ฉ๋ด 2๊ฐ
<style>
ul{
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li{
float: left;
}
li a, .dropbtn{
color:white;
display: inline-block;
padding: 14px 16px;
text-decoration: none;
text-align: center;
}
li a:hover, .dropbtn:hover{
background-color: red;
}
</style>
<style>
li.dropdown{
display: inline-block;
}
li.dropdown .dropdown-content{
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
padding: 12px 16px;
z-index:1;
}
li.dropdown:hover .dropdown-content{
display: block;
}
</style>
<style>
.dropdown-content a{
display: block;
text-decoration: none;
color:black;
padding: 12px 16px;
text-align: left;
}
.dropdown-content a:hover{
background-color: #f1f1f1;
}
</style>
<ul>
<li><a href="#">Home</a></li>
<li class="dropdown">
<a href="#" class="dropbtn">News</a>
<div class="dropdown-content">
<!-- a[href="#"]*3>{Link $} -->
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</li>
<li class="dropdown">
<a href="#" class="dropbtn">DropDown</a>
<div class="dropdown-content">
<!-- a[href="#"]*3>{Link $} -->
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</li>
</ul>
<h3>Lorem ipsum dolor sit.</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Suscipit quis autem laboriosam corporis fugiat dicta reiciendis optio rerum facere nobis officia nemo fugit adipisci sint dolores temporibus dolore consectetur maxime.</p>
timeline
<style>
* {
box-sizing: border-box;
}
body {
background-color: #474e5d;
font-family: Helvetica, sans-serif;
}
/* The actual timeline (the vertical ruler) */
.timeline {
position: relative;
max-width:600px;
margin: 0 auto;
}
/* The actual timeline (the vertical ruler) */
.timeline::after {
content: '';
position: absolute;
width: 6px;
background-color: white;
top: 0;
bottom: 0;
left: 50%;
margin-left: -3px;
}
/* Container around content */
.container {
padding: 10px 40px;
position: relative;
background-color: inherit;
width: 50%;
}
/* The circles on the timeline */
.container::after {
content: '';
position: absolute;
width: 25px;
height: 25px;
right: -17px;
background-color: white;
border: 4px solid #FF9F55;
top: 15px;
border-radius: 50%;
z-index: 1;
}
/* Place the container to the left */
.left {
left: 0;
}
/* Place the container to the right */
.right {
left: 50%;
}
/* Add arrows to the left container (pointing right) */
.left::before {
content: " ";
height: 0;
position: absolute;
top: 22px;
width: 0;
z-index: 1;
right: 30px;
border: medium solid white;
border-width: 10px 0 10px 10px;
/* transparent ํฌ๋ช
*/
border-color: transparent transparent transparent white;
}
/* Add arrows to the right container (pointing left) */
.right::before {
content: " ";
height: 0;
position: absolute;
top: 22px;
width: 0;
z-index: 1;
left: 30px;
border: medium solid white;
border-width: 10px 10px 10px 0;
border-color: transparent white transparent transparent;
}
/* Fix the circle for containers on the right side */
.right::after {
left: -16px;
}
/* The actual content */
.content {
padding: 20px 30px;
background-color: white;
position: relative;
border-radius: 6px;
}
/* Media queries - Responsive timeline on screens less than 600px wide */
@media screen and (max-width: 600px) {
/* Place the timelime to the left */
.timeline::after {
left: 31px;
}
/* Full-width containers */
.container {
width: 100%;
padding-left: 70px;
padding-right: 25px;
}
/* Make sure that all arrows are pointing leftwards */
.container::before {
left: 60px;
border: medium solid white;
border-width: 10px 10px 10px 0;
border-color: transparent white transparent transparent;
}
/* Make sure all circles are at the same spot */
.left::after, .right::after {
left: 15px;
}
/* Make all right containers behave like the left ones */
.right {
left: 0%;
}
}
</style>
<div class="timeline">
<div class="container right">
<div class="content">
<h2>2021</h2>
<p>Lorem ipsum dolor sit amet, quo ei simul congue exerci, ad nec admodum perfecto mnesarchum, vim ea mazim fierent detracto. Ea quis iuvaret expetendis his, te elit voluptua dignissim per, habeo iusto primis ea eam.</p>
</div>
</div>
<div class="container right">
<div class="content">
<h2>2020</h2>
<p>Lorem ipsum dolor sit amet, quo ei simul congue exerci, ad nec admodum perfecto mnesarchum, vim ea mazim fierent detracto. Ea quis iuvaret expetendis his, te elit voluptua dignissim per, habeo iusto primis ea eam.</p>
</div>
</div>
<div class="container left">
<div class="content">
<h2>2019</h2>
<p>Lorem ipsum dolor sit amet, quo ei simul congue exerci, ad nec admodum perfecto mnesarchum, vim ea mazim fierent detracto. Ea quis iuvaret expetendis his, te elit voluptua dignissim per, habeo iusto primis ea eam.</p>
</div>
</div>
<div class="container right">
<div class="content">
<h2>2012</h2>
<p>Lorem ipsum dolor sit amet, quo ei simul congue exerci, ad nec admodum perfecto mnesarchum, vim ea mazim fierent detracto. Ea quis iuvaret expetendis his, te elit voluptua dignissim per, habeo iusto primis ea eam.</p>
</div>
</div>
<div class="container left">
<div class="content">
<h2>2011</h2>
<p>Lorem ipsum dolor sit amet, quo ei simul congue exerci, ad nec admodum perfecto mnesarchum, vim ea mazim fierent detracto. Ea quis iuvaret expetendis his, te elit voluptua dignissim per, habeo iusto primis ea eam.</p>
</div>
</div>
<div class="container right">
<div class="content">
<h2>2007</h2>
<p>Lorem ipsum dolor sit amet, quo ei simul congue exerci, ad nec admodum perfecto mnesarchum, vim ea mazim fierent detracto. Ea quis iuvaret expetendis his, te elit voluptua dignissim per, habeo iusto primis ea eam.</p>
</div>
</div>
</div>
css ์ด๋ฏธ์ง ๊ฐค๋ฌ๋ฆฌ + ๋ฐ์ํ์น
<style>
*{
box-sizing: border-box;
}
div.gallery{
border: 1px solid #ccc;
width: 180px;
margin:5px;
float: left;
}
div.gallery:hover{
border: 1px solid #777;
}
div.gallery img{
width: 100%;
height: auto;
}
div.gallery div.desc{
padding: 15px;
text-align: center;
}
.clearfix::after{
content: "";
clear: both;
display: table;
}
</style>
<style>
@media only screen and ( max-width:700px ){
div.gallery{
width:48%;
}
}
@media only screen and ( max-width:500px ){
div.gallery{
width:100%;
}
}
</style>
<!-- .gallery*4>a[target=_blank]>img^.desc>{Add a description of the image here} -->
<div class="gallery">
<a href="../images/img_5terre.jpg" target="_blank"><img src="../images/img_5terre.jpg" alt="" /></a>
<div class="desc">Add a description of the image here</div>
</div>
<div class="gallery">
<a href="../images/img_forest.jpg" target="_blank"><img src="../images/img_forest.jpg" alt="" /></a>
<div class="desc">Add a description of the image here</div>
</div>
<div class="gallery">
<a href="../images/img_lights.jpg" target="_blank"><img src="../images/img_lights.jpg" alt="" /></a>
<div class="desc">Add a description of the image here</div>
</div>
<div class="gallery">
<a href="../images/img_mountains.jpg" target="_blank"><img src="../images/img_mountains.jpg" alt="" /></a>
<div class="desc">Add a description of the image here</div>
</div>
<div class="clearfix"></div>
<div style="padding:6px;">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Cupiditate recusandae quibusdam odit nulla excepturi laboriosam
veritatis aspernatur ab officiis voluptatibus deleniti rerum nemo
neque sit non nihil totam. Architecto quae.
</p>
</div>
์ด๋ฏธ์ง ์คํ๋ผ์ดํธ(image sprites)
์ด๋ฏธ์ง ์คํ๋ผ์ดํธ : ๋จ์ผ ์ด๋ฏธ์ง์ ํฌํจ๋ ์ด๋ฏธ์ง ๋ชจ์.
์น ํ์ด์ง์ ๋ง์ ์ด๋ฏธ์ง๊ฐ ์ฌ์ฉ๋๋ ๊ฒฝ์ฐ ์นํ์ด์ง ๋ก๋ํ๋ ๋ฐ ์๊ฐ์ด ์ค๋ ๊ฑธ๋ฆฐ๋ค.
์ฌ๋ฌ ์๋ฒ ์์ฒญ ์ผ์ด๋๋ค.
๋จ์ผ์ด๋ฏธ์ง : ../images/img_navsprites_hover.gif
<style>
#navlist{
position: relative;
}
#navlist li{
position: absolute;
top:0;
margin: 0;
padding: 0;
list-style-type: none;
}
#navlist li, #navlist li a{
height: 44px;
width: 43px;
display: block;
}
li#home{
left:0;
background: url('../images/img_navsprites_hover.gif') 0 0;
}
li#prev{
left:63px;
background: url('../images/img_navsprites_hover.gif') -47px 0;
}
li#next{
left:129px;
background: url('../images/img_navsprites_hover.gif') -91px 0;
}
</style>
<style>
li#home:hover{
background-position: 0 -45px;
}
li#prev:hover{
background-position: -47px -45px;
}
li#next:hover{
background-position: -91px -45px;
}
/* js li + background-position: -91px -45px; */
</style>
<!-- ul#navlist>li[id]*3>a[href=#] -->
<ul id="navlist">
<li id="home"><a href="#"></a></li>
<li id="prev"><a href="#"></a></li>
<li id="next"><a href="#"></a></li>
</ul>
css ์์ฑ selector (์ ํ์)
--> 1. [์์ฑ๋ช ] ์์ฑ๊ฐ์ ์๊ด์์ด ์์ฑ๋ช ๋ง ์์ผ๋ฉด
--> 2. [์์ฑ๋ช =์์ฑ๊ฐ]
--> 3. [์์ฑ๋ช ^=์์ฑ๊ฐ]
--> 4. [์์ฑ๋ช $=์์ฑ๊ฐ]
--> 5. [์์ฑ๋ช *=์์ฑ๊ฐ]
--> 6. [์์ฑ๋ช ~=์์ฑ๊ฐ]
7. [์์ฑ๋ช |=์์ฑ๊ฐ] X
<style>
/* 1. input{ */
/* 2. input[type]{ */
input[type=text]{
width:200px;
border:1px solid red;
}
</style>
<style>
/* a[title='flower']{ == where title = 'flower' */
/* where title LIKE 'flower%' */
/* a[title^='flower']{ */
/* where title LIKE '%flower' */
/* a[title$='flower']{ */
/* where title LIKE '%flower%' */
/* a[title*='flower']{ */
/* flower ๋จ์ด */
a[title~='flower']{
color:red;
background-color: yellow;
}
</style>
<!-- a[href=#][title]*5 -->
<a href="#" title="klematis flower">naver</a><br>
<a href="#" title="flower">daum</a><br>
<a href="#" title="kbsflower">sist</a><br>
<a href="#" title="kbs-flower">taeyo</a><br>
<a href="#" title="flowers">admin</a><br>
<hr>
<input><br>
<input><br>
<input type="text" ><br>
<input type="text" ><br>
<input type="text" ><br>
<input type="submit" ><br>
<input type="reset" ><br>
first-child,last-child,nth-child(n) / ~ first-of-type
<style>
/*
li{
color:red;
}
*/
/*
li:first-child{
color:red;
}
*/
/*
li:first-of-type{
color:green;
}
*/
/*
li:nth-child(2){
color:red;
}
*/
/*
li:nth-of-type(2){
color:red;
}
*/
/*
li:nth-child(odd){
color:red;
}
*/
/*
li:last-child{
color:red;
}
*/
li:last-of-type{
color:red;
}
</style>
<div>
<!-- ul>li*5>lorem1 -->
<ul>
<li>Lorem.</li>
<li>Rerum.</li>
<li>Autem?</li>
<li>Cupiditate.</li>
<li>Obcaecati.</li>
</ul>
</div>
/* ์ด๋ค ์์์ ์ฒซ ๋ฒ์งธ ์์ == p */
/* p:first-child{ */
/* p:first-of-type{ */
/* p:last-child{ */
/* p:last-of-type{ */
/* p:nth-child(5){ */
p:nth-of-type(2){
color:red;
<div>div1</div>
<div>div2</div>
<!-- p*5>lorem5 -->
<p>Lorem ipsum dolor sit amet.</p>
<dvi>div3</dvi>
<p>*** Impedit maxime distinctio iure voluptatum?</p>
<p>Sint corporis sequi voluptatum commodi.</p>
<p>Maiores illo molestiae dicta sequi!</p>
<p>Reprehenderit blanditiis temporibus eveniet ab.</p>
* first-child : ์ด๋ค ์์์ ์ฒซ๋ฒ์งธ ์์์ด -> p๋ฉด O
* p:first-of-type : ์ฒซ๋ฒ์งธ pํ๊ทธ (์ฒ์์ค๋ p)
๊ฒ์ ์คํ์ผ ์ง์
<style>
input[type=text]{
width: 30%;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
border: 2px solid #ccc;
background: white url('../images/searchicon.png') no-repeat 10px center;
padding-left: 40px;
/* ์ ํ */
transition:width 0.5s ease;
}
input[type=text]:hover{
width: 100%;
}
</style>
<form action="">
<input type="text" name="search" placeholder="Search...">
</form>
ํ ์ด๋ธ ์ฒดํฌ
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
table{
width: 100%;
border:1px solid #ddd;
border-spacing: 0;
border-collapse: collapse;
}
th, td{
text-align: center;
padding: 16px;
}
th:first-child, td:first-child{
text-align: left;
}
tr:nth-child(even){
background-color: #f2f2f2;
}
.fa-check{ color:green }
.fa-remove{ color:red }
</style>
<table>
<tr>
<th>Lorem.</th>
<th>Quod?</th>
<th>Laudantium.</th>
</tr>
<tr>
<td>Sample text</td>
<td><i class="fa fa-remove"></i></td>
<td><i class="fa fa-check"></i></td>
</tr>
<tr>
<td>Sample text</td>
<td><i class="fa fa-check"></i></td>
<td><i class="fa fa-check"></i></td>
</tr>
<tr>
<td>Sample text</td>
<td><i class="fa fa-remove"></i></td>
<td><i class="fa fa-check"></i></td>
</tr>
<tr>
<td>Sample text</td>
<td><i class="fa fa-check"></i></td>
<td><i class="fa fa-check"></i></td>
</tr>
<tr>
<td>Sample text</td>
<td><i class="fa fa-remove"></i></td>
<td><i class="fa fa-check"></i></td>
</tr>
</table>
ํ์
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
.checked{
color:orange;
}
span.fa{
font-size: 25px;
}
span.heading{
font-size: 25px;
margin-right: 25px;
}
</style>
<span class="heading">ํ์ : </span>
<span class="fa fa-star checked"></span>
<span class="fa fa-star checked"></span>
<span class="fa fa-star checked"></span>
<span class="fa fa-star "></span>
<span class="fa fa-star"></span>
css ํน์ด์ฑ(ํน์์ฑ)
- ๋์ผํ ์์(a)๋ฅผ css ์ ํ์๋ก ์ฌ์ฉํ ๋ ์ฐ์ ์์
[ํน์ด์ฑ ์์ค์ ๋ํ๋ด๋ ์ ์]
1. inline css ์ ์ฉ๋ฐฉ๋ฒ ( 1000์ ) > Internal, External css ์ ์ฉ๋ฐฉ๋ฒ 2. * : 0์ ํ๊ทธ๋ช , ์์ฌ์์ : 1์ ํด๋์ค๋ช , ์์ฌํด๋์ค๋ช , ์์ฑ ์ ํ์ : 10์ ์์ด๋์์ฑ : 100์ ์) #navbvar p#demo{} 100+1+100=201 #demo{} 100 3. ์์ธ !important ๊ท์น ํด๋น ์์์ ํน์ ์์ฑ์ ๋ํ ๋ชจ๋ ์ด์ ์คํ์ผ์ ์๋ก ์ฌ์ ์ํ๋ค. |
<style>
div#mydiv p > a{ /* 1์ + 100์ + 1์ + 1์ = 103์ */
}
#mydiv p > a { /* 100์ + 1์ + 1์ =102์ */
color:navy;
}
p > a.button{ /* 1์ + 1์ + 10์ = 12์ */
color:blue;
}
a{ /* 1์ */
color:yellow;
}
p > a{ /* 2์ */
color:green;
}
</style>
<style>
a{ /* 1์ */
color:red !important;
}
</style>
๋ง๋ ๊ทธ๋ํ
<style>
*{ /* 0์ */
box-sizing: border-box;
}
body{
font-family: Arial;
border:1px solid red;
padding:20px;
max-width: 800px;
margin: 0 auto;
height: 100%;
}
/* 10+1=11 */
.row::after{
content:"";
clear:both;
display: table;
}
.side{
float: left;
width:15%;
margin-top:10px;
}
.middle{
float: left;
width:70%;
margin-top:10px;
}
.middle .bar-container{
width: 100%;
background-color: #f1f1f1;
text-align: center;
color:white;
}
.right{
text-align: right;
}
/* ๋งํจ ๊ทธ๋ํ */
/* <div class="bar-1"></div> */
.bar-1 {
background-color: #f44336;
height: 18px;
width: 20%;
}
.bar-2{
background-color: #3296F3;
height: 18px;
width: 15%;
}
.bar-3 {
background-color: #00BCD4;
height: 18px;
width: 75%;
}
.bar-4 {
background-color: #FF9800;
height: 18px;
width: 86%;
}
.bar-5 {
background-color: #4caf50;
height: 18px;
width: 40%;
}
</style>
<div class="row">
<!-- bar start -->
<div class="side">
<div>1 star</div>
</div>
<!-- ๋ง๋๊ทธ๋ํ -->
<div class="middle">
<div class="bar-container">
<div class="bar-1"></div>
</div>
</div>
<div class="side right">
<div>20</div>
</div>
<!-- bar end -->
<!-- bar start -->
<div class="side">
<div>2 star</div>
</div>
<!-- ๋ง๋๊ทธ๋ํ -->
<div class="middle">
<div class="bar-container">
<div class="bar-2"></div>
</div>
</div>
<div class="side right">
<div>15</div>
</div>
<!-- bar end -->
<!-- bar start -->
<div class="side">
<div>3 star</div>
</div>
<!-- ๋ง๋๊ทธ๋ํ -->
<div class="middle">
<div class="bar-container">
<div class="bar-3"></div>
</div>
</div>
<div class="side right">
<div>75</div>
</div>
<!-- bar end -->
<!-- bar start -->
<div class="side">
<div>4 star</div>
</div>
<!-- ๋ง๋๊ทธ๋ํ -->
<div class="middle">
<div class="bar-container">
<div class="bar-4"></div>
</div>
</div>
<div class="side right">
<div>86</div>
</div>
<!-- bar end -->
<!-- bar start -->
<div class="side">
<div>5 star</div>
</div>
<!-- ๋ง๋๊ทธ๋ํ -->
<div class="middle">
<div class="bar-container">
<div class="bar-5"></div>
</div>
</div>
<div class="side right">
<div>40</div>
</div>
<!-- bar end -->
</div>
ํ๋กํ
<style>
.card{
width: 30%;
box-shadow: 0 4px 8px 0 rgba(0,0,0, 0.2);
border-radius: 5px;
display: inline-block;
}
.card:hover{
box-shadow: 0 4px 16px 0 rgba(0,0,0, 0.2);
}
.card img{
width: 100%;
border-radius: 5px 5px 0 0;
}
.container{
padding: 2px 16px;
text-align: center;
}
</style>
<!-- .card>img+.container>h4>b^p -->
<div class="card">
<img src="../images/img_avatar.png" alt="" />
<div class="container">
<h4><b>Hong Gil Dong</b></h4>
<p>Java Developer</p>
</div>
</div>
<div class="card">
<img src="../images/img_avatar.png" alt="" />
<div class="container">
<h4><b>Hong Gil Dong</b></h4>
<p>Java Developer</p>
</div>
</div>
<div class="card">
<img src="../images/img_avatar.png" alt="" />
<div class="container">
<h4><b>Hong Gil Dong</b></h4>
<p>Java Developer</p>
</div>
</div>
<div class="card">
<img src="../images/img_avatar.png" alt="" />
<div class="container">
<h4><b>Hong Gil Dong</b></h4>
<p>Java Developer</p>
</div>
</div>
<div class="card">
<img src="../images/img_avatar.png" alt="" />
<div class="container">
<h4><b>Hong Gil Dong</b></h4>
<p>Java Developer</p>
</div>
</div>
<div class="card">
<img src="../images/img_avatar.png" alt="" />
<div class="container">
<h4><b>Hong Gil Dong</b></h4>
<p>Java Developer</p>
</div>
</div>
<div class="card">
<img src="../images/img_avatar.png" alt="" />
<div class="container">
<h4><b>Hong Gil Dong</b></h4>
<p>Java Developer</p>
</div>
</div>
๋ฅ๊ทผ๋ชจ์๋ฆฌ
border-radius ์์ฑ
<style>
p{
width: 200px;
height: 200px;
border:1px solid green;
padding:20px;
}
p:first-of-type{
background-color: red;
border-radius: 15px 50px 30px 5px;
}
p:nth-of-type(2){
background:url('../images/paper.gif') left top repeat;
border-radius: 0 50%;
}
p:last-of-type{
border:2px solid #73da21;
border-top-left-radius: 15px;
border-bottom-right-radius: 15px;
}
</style>
<p>Lorem ipsum dolor.</p>
<p>Sapiente consequatur natus.</p>
<p>Voluptatem nulla tempore.</p>
๋ค์ค ๋ฐฐ๊ฒฝ์ด๋ฏธ์ง
์ฌ๋ฌ ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง๋ฅผ ์ถ๊ฐ
1. background-size ์์ฑ
2. background-origin ์์ฑ
3. backgroud-clip ์์ฑ
background-image ์์ฑ : url(), url(), url() ... ๋ฐฐ๊ฒฝ์ด๋ฏธ์ง ์๋ก ์์ ์์ธ๋ค.
์ฒซ ๋ฒ์งธ ๋ฐฐ๊ฒฝ์ด๋ฏธ์ง ์ฌ๋์๊ฒ ๊ฐ์ฅ ๊ฐ๊น๊ฒ ๋ณด์ธ๋ค.
/* #demo{ 100์ */
div#demo{ /* 101์ */
/*
background-image: url('../images/img_flwr.gif'), url('../images/paper.gif');
background-repeat: no-repeat, repeat;
background-position: right bottom, left top;
*/
/* ๋ฐฐ๊ฒฝ์ด๋ฏธ์ง ์ฝ์ ์์ฑ */
background: url('../images/img_flwr.gif') no-repeat right bottom
, url('../images/paper.gif') repeat left top;
}
<!-- #demo>(h1>lorem4)+p*2>lorem -->
<div id="demo">
<h1>Lorem ipsum dolor sit.</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Commodi quibusdam voluptate consectetur porro assumenda praesentium explicabo molestiae voluptatem illo laborum vitae repellat nihil pariatur eos ducimus illum possimus rem hic?</p>
<p>Tempore repellat deserunt tenetur odit quisquam recusandae cumque perferendis eum illo error ducimus voluptatibus aliquid aliquam temporibus ut nam in eaque quam fuga aspernatur officiis accusamus enim porro explicabo debitis.</p>
</div>
background-size ์์ฑ
- ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง์ ํฌ๊ธฐ๋ฅผ ์ง์ ํ ์ ์๋ค.
- ํฌ๊ธฐ ๋จ์ : ๊ธธ์ด, % + contain ๋๋ cover ๋ ํค์๋๋ฅผ ์ฌ์ฉํ ์ ์๋ค.
<style>
div{ /* 1์ */
border: 1px solid;
padding:15px;
background: url('../images/img_flwr.gif') no-repeat;
}
#demo1{ /* 100์ */
background-size: 100px 80px;
}
</style>
<img src="../images/img_flwr.gif">
<!-- #demo$*2>h1>lorem3^p*2>lorem -->
<div id="demo1">
<h1>Lorem ipsum dolor.</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sint commodi dolor amet quia aperiam totam quibusdam impedit reiciendis consequuntur magnam assumenda iure inventore magni eveniet quaerat modi officia eos eum!</p>
<p>Reprehenderit enim sit sapiente perferendis magnam nobis omnis dolorem commodi architecto porro debitis vero saepe distinctio voluptates at minus animi vel ratione sint ea sequi possimus cum repellat tempora obcaecati!</p>
</div>
<div id="demo2">
<h1>Magnam cum pariatur!</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsum vel nihil corrupti dignissimos dolores laudantium nostrum cumque doloremque fugiat itaque quasi quo libero quis voluptatem eligendi maxime harum sunt iste!</p>
<p>Perspiciatis tempora veniam dolorum laboriosam odio velit enim ullam suscipit adipisci inventore corporis itaque aliquam tempore molestiae aliquid fugiat molestias ab nam. Minima optio odio veritatis illo obcaecati dolorem iusto?</p>
background-size:contain or cover
- contain : ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง๋ฅผ ์ต๋ํ ํฌ๊ฒ ์กฐ์ ํ๋ค. ( ๋จ, ๋๋น์ ๋์ด๊ฐ ๋ชจ๋ ์ฝํ ์ธ ์์ญ์ ๋ง์์ผํจ.)
- cover : ์ฝํ ์ธ ์์ญ์ด ์์ ํ ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง์ ํฌํจ๋๋๋ก ์ฒ๋ฆฌํ๋ค.
๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง์ ์ผ๋ถ๋ ๋ฐฐ๊ฒฝ ์์น ์ง์ ์์ญ์์ ๋ณด์ด์ง ์์ ์๋ ์๋ค.
<style>
div{
width: 150px;
height: 120px;
border:1px solid;
background: url('../images/img_flwr.gif') no-repeat;
}
#div2{
background-size: contain;
}
#div3{
background-size: cover;
}
</style>
<img src="../images/img_flwr.gif" alt="" >
<!-- h3+#div1>p>lorem5 -->
<h3>contain, cover X</h3>
<div id="div1">
<p>Lorem ipsum dolor sit amet.</p>
</div>
<h3>contain</h3>
<div id="div2">
<p>Lorem ipsum dolor sit amet.</p>
</div>
<h3>cover</h3>
<div id="div3">
<p>Lorem ipsum dolor sit amet.</p>
</div>
background-size cover ํ์ฉ)
<style>
body{
margin: 0;
font-family: Arial;
}
.hero-image{
height: 500px;
background: url('../images/img_man.jpg') no-repeat;
background-size: cover; /* */
position: relative;
}
.hero-text{
position: absolute;
left:50%;
top:50%;
text-align: center;
color:white;
transform:translate(-50%, -50%);
}
</style>
<div class="hero-image">
<div class="hero-text">
<h1>I am Sam</h1>
<h3>Lorem ipsum dolor sit.</h3>
<button>Hire me</button>
</div>
</div>
<p>Lorem ipsum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Facilis culpa amet accusantium doloremque veritatis autem
excepturi odio eum dicta eaque.</p>
html ์ฌ๋ฌ ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง ์ค์ + ํฌ๊ธฐ ์ค์ (์ฌ์ด์ฆ ๊ฐ๊ฐ ์กฐ์ )
#demo1{
background: url(../images/img_tree.gif) left top no-repeat
, url(../images/img_flwr.gif) right bottom no-repeat
, url(../images/paper.gif) left top repeat;
background-size: 50px 150px, 130px, auto;
}
<!-- h3+#demo1>p>lorem5^p*2>lorem15 -->
<div id="demo1">
<p>Lorem ipsum dolor sit amet.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minus eveniet optio necessitatibus nihil alias voluptatem autem animi vitae reprehenderit quo inventore soluta. Nam beatae rerum officiis animi molestiae molestias nihil.</p>
<p>Voluptates autem impedit consequuntur suscipit placeat ducimus amet repudiandae minus velit doloribus. Recusandae earum quod ut facilis quidem cumque asperiores aperiam in culpa laborum quo fuga veniam maxime nostrum consequuntur!</p>
</div>
background-origin ์์ฑ
background-clip ์์ฑ
background-clip : [๋ฐฐ๊ฒฝ์์ด ๊ทธ๋ ค์ง ์์น]๋ฅผ ์ง์ ํ๋ ์์ฑ
padding-box ( ๊ธฐ๋ณธ๊ฐ )
border-box
content-box
1) background-position ์์ฑ : [๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง์ ์์น]๋ฅผ ์ง์ ํ๋ ์์ฑ
์) left top, 10px 150px, 50% 50% ๋ฑ๋ฑ
2) background-origin ์์ฑ : ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง์ ์์น๋ฅผ ์ง์ ํ๋ ์์ฑ
1)๊ณผ ์ฐจ์ด์ ?
border-box, ํ ๋๋ฆฌ ์ผ์ชฝ ์๋จ
padding-box , (๊ธฐ๋ณธ๊ฐ) ํจ๋ฉ ์ผ์ชฝ ์๋จ
content-box ์ฝํ ์ธ ์ผ์ชฝ ์๋จ
์์ฑ๊ฐ์ ์ฌ์ฉ.
div{
border: 10px dotted black;
padding:35px;
background: yellow url('../images/img_flwr.gif') no-repeat;
}
#demo1{
background-origin: padding-box; /* ๊ธฐ๋ณธ๊ฐ */
background-clip: padding-box; /* ๊ธฐ๋ณธ๊ฐ*/
}
#demo2{
background-origin: border-box;
background-clip: border-box;
}
#demo3{
background-origin: content-box;
background-clip: content-box;
}
<!-- (#demo$>h1>lorem5^p>lorem15)*3 -->
<div id="demo1">
<h1>Lorem ipsum dolor sit amet.</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nihil porro vel quis dicta inventore minima!</p>
</div>
<div id="demo2">
<h1>Lorem ipsum dolor sit amet.</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nihil porro vel quis dicta inventore minima!</p>
</div>
<div id="demo3">
<h1>Lorem ipsum dolor sit amet.</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nihil porro vel quis dicta inventore minima!</p>
</div>
parallax == ์ฌ์ ์ ์๋ฏธ ( ์์ฐจ )
์์ฐจ == ๊ด์ธก ์์น์ ๋ฐ๋ผ ๋ฌผ์ฒด์ ์์น๋ ๋ฐฉํฅ์ด ์ฐจ์ด
html, body{
/* border:1px solid red; */
height: 100%;
margin: 0;
padding: 0;
}
.parallax{
border: 1px solid green;
height: 100%;
background: url(../images/img_parallax.jpg) no-repeat center fixed;
background-size: cover;
}
<div class="parallax"></div>
<div style="height:500px;background: fuchsia;font-size: 20px;">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Recusandae deleniti
dignissimos similique nulla repellendus consequatur alias voluptate distinctio
aperiam eum quaerat nisi ipsum sequi sit quidem quae officia molestiae
soluta.
</div>
<div class="parallax"></div>
๊ทธ๋ผ๋์ธํธ(gradient) ํจ๊ณผ
๊ทธ๋ฆผ์ ํจ๊ณผ
1. ๋ฐ์ค ๊ทธ๋ฆผ์ ํจ๊ณผ( box-shadow)
2. ํ ์คํธ ๊ทธ๋ฆผ์ ํจ๊ณผ( text-shadow)
์ต๊ทผ๋๊ธ