[Day4] CSS 4 [11/15]
[overflow]
1. ์์์ ์ฝํ ์ธ (๋ด์ฉ)๊ฐ ๋๋ฌด ์ปค์ ์ง์ ๋ ์์ญ์ ๋ง์ง ์์ ๋ ์ฝํ ์ธ (๋ด์ฉ)์ ์๋ฅผ์ง ๋๋ ์คํฌ๋กค๋ฐ๋ฅผ ์ถ๊ฐํ ์ง ์ฌ๋ถ๋ฅผ ๊ฒฐ์ ํ๋ ์์ฑ
2. li, a ์ธ๋ผ์ธ๋ชจ๋ ๋ฉ๋ด : float:left overflow:auto+๋ค์์์..
- auto : ์๋. ์ฝํ ์ธ ๊ฐ ๋์น๋ ๊ฒฝ์ฐ์๋ง ์คํฌ๋กค๋ฐ ์ถ๊ฐ.
- visible(๊ธฐ๋ณธ๊ฐ) : ์์ญ ์ธ๋ถ์ ๋์น๋ ์ฝํ ์ธ ๊ฐ ์ถ๋ ฅ(๋๋๋ง) ๋์ด์ง๋ค.
- hidden : ์ฝํ ์ธ ๊ฐ ๋์น๋ ๋ถ๋ถ์ ์๋ผ๋ฒ๋ฆฐ๋ค. ๋ณด์ด์ง ์๋๋ก ํ๋ค.
- scroll : ์ฝํ ์ธ ๊ฐ ๋์น๋ ์ง์ ๋ํ ์ฌ๋ถ์ ์๊ด์์ด ๋ฌด์กฐ๊ฑด ์คํฌ๋กค๋ฐ ์ถ๊ฐ.
div{
/* block๋ชจ๋ */
/* ๋์ด ์ง์ */
background-color: coral; /* ์ฐํธ์ */
border:1px solid;
width:300px;
height:600px;
/* height:65px; */
/* overflow:visible; */
/* overflow:hidden; */
/* overflow:scroll; */
/* overflow-x:scroll; */
/* overflow-y:scroll; */
overflow:auto;
}
(์ฐธ๊ณ ์ฌํญ) overflow ์์ฑ์ [๋์ด๊ฐ ์ค์ ๋] [block ๋ชจ๋]์์๋ง ์ ์ฉ๋๋ค.
[float]
1. ์ฌ์ ์ ์๋ฏธ : ๋ฅ๋ฅ ๋ ๋ค๋๋ค.
2. ์์๊ฐ ๋ ๋ค๋๋ ๋ฐฉ๋ฒ์ ์ง์ ํ๋ ์์ฑ
3. ์ฝํ ์ธ ๋ฅผ ๋ฐฐ์นํ๊ณ ํ์์ ์ง์ ํ๋๋ฐ ์ฌ์ฉ
4. ์ด๋ฏธ์ง ์ปจํ ์ด๋์ ํ ์คํธ ์ผ์ชฝ, ์ค๋ฅธ์ชฝ ๋ฐฐ์น( ๋ ์๊ฒ ํ๋ค. )
5. ์์ฑ๊ฐ : left, right, none(๊ธฐ๋ณธ๊ฐ), inherit - (๋ถ๋ชจ์์์ float ๊ฐ์ ์์)
<style>
p{
border:3px solid #4caf50;
padding:5px;
/* overflow:auto; */ /* 1๋ฒ. */
}
/*
.clearfix{
overflow:auoto;
}
*/
/* :์์ฌํด๋์ค */
/* ::์์ฌ์์ */
/* p::after{ */
.clearfix::after{
content:"";
clear:both;
display:table;
}
p img{
width:170px;
float:left;
}
</style>
<p class="clearfix">
<img src="../images/pineapple.jpg" alt="ํ์ธ์ ํ">
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Ut ipsum ipsam quae veritatis assumenda cumque dicta
libero minus laboriosam in quaerat neque inventore a
ducimus doloribus magni fuga eos qui.
</p>
<style>
.clearfix div{
padding:15px;
border:1px solid;
float:left;
}
</style>
<div class="clearfix">
<div class="box1">box1</div>
<div class="box2">box2</div>
<div class="box3" style="float:right">box3</div>
</div>
* ์์ฌํด๋์ค ์์ฌ์์ : https://velog.io/@chyori/CSS-%EC%9D%98%EC%82%AC-%ED%81%B4%EB%9E%98%EC%8A%A4
[clear] : https://ofcourse.kr/css-course/clear-%EC%86%8D%EC%84%B1
1. float ์์ ์์ ์๋ ์์์ ์ด๋ค ์ผ์ด ๋ฐ์ํด์ผ ํ๋์ง๋ฅผ ์ง์ ํ๋ ์์ฑ.
2. none(๊ธฐ๋ณธ๊ฐ)
3. left : ์ผ์ชฝ float์์์ ์๋๋ก ์ถ๋ ฅ
4. right : ์ค๋ฅธ์ชฝ float์์์ ์๋๋ก ์ถ๋ ฅ
5. both : ์ผ์ชฝ + ์ค๋ฅธ์ชฝ float ์์์ ์๋๋ก ์ถ๋ ฅ
6. inherit : ์์
ํ์ (popup) ํผ(form)
<style>
body{
font-family:Arial, Verdana, sans-serif;
}
*{
box-sizing:border-box;
}
.open-button{
background-color: #555;
color:white;
padding:16px 20px;
border:none;
cursor:pointer;
opacity:0.8;
position:fixed;
right:28px;
bottom:23px;
width:280px;
}
.form-popup{
display:none;
border:3px solid #f1f1f1;
position:fixed;
bottom:0;
right:15px;
z-index:9;
}
.form-container{
max-width:300px;
padding:10px;
background-color: white;
}
.form-container input[type=text], .form-container input[type=password]{
width:100%;
margin:5px 0 22px 0;
border:none;
background-color: #f1f1f1;
padding:15px;
}
.form-container input[type=text]:focus
, .form-container input[type=password]:focus{
background-color: #ddd;
outline:none; /* border ๋ฐ */
}
.form-container .btn{
background-color: #4caf50;
color:white;
padding:16px 20px;
border:none;
cursor:pointer;
width:100%;
margin-bottom:10px;
opacity:0.8;
}
.form-container .btn:hover, open-button:hover{
opacity:1;
}
.form-container .cancel{
background-color: red;
}
</style>
<div class="form-popup" id="myForm">
<form action="" class="form-container">
<h1>Login</h1>
<label for="email"><b>Email</b></label>
<input type="text" placeholder="Enter Email" name="email" required>
<label for="psw"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" required>
<button type="submit" class="btn">Login</button>
<button type="button" class="btn cancel">Close</button>
</form>
</div>
* outline : border ๋ฐ๊นฅ
1) Open Form์ ํด๋ฆญํ๋ฉด ์จ๊ฒจ์ง form-popup div ๋ณด์ด๋๋ก js & jquery ์ฝ๋ฉ.
document.querySelector("button.open-button").onclick=function(){
// alert("!!");
// document.getElementById("myForm").setAttribute(); /getAttribute();
document.querySelector("#myForm").style.display="block";
document.querySelector("#myForm input[name=email]").focus();
}
$("button.open-button").click( function (){
// alert("!!");
$("#myForm").show();
$("#myForm input[name=email]").focus();
});
2) ๋ซ๊ธฐ ๋ฒํผ์ ํด๋ฆญํ๋ฉด ๋ณด์ฌ์ง form-popup div ์จ๊ธฐ๋๋ก js & jquery ์ฝ๋ฉ.
document.querySelector("button.btn.cancel").onclick=function(){
// alert("!!");
// document.getElementById("myForm").setAttribute(); /getAttribute();
document.querySelector("#myForm").style.display="none";
document.querySelector("#myForm input[name=email]").value="";
document.querySelector("#myForm input[name=psw]").value="";
$("button.btn.cancel").click(function(){
// alert("!!");
$("#myForm").hide();
$("#myForm input[name=email]").val("");
$("#myForm input[name=psw]").val("");
});
๋ฐ์ํ(Responsive) ํผ(Form)
<style>
*{
box-sizing:border-box;
}
input[type=text], select, textarea{
width:100%;
padding:12px;
border:1px solid #ccc;
border-radius: 4px;
}
.row label{
display:inline-block;
padding:12px 12px 12px 0;
}
input[type=submit]{
background-color: #4caf50;
color:white;
padding:12px 20px;
border:none;
border-radius:4px;
cursor:pointer;
float:right;
}
input[type=submit]:hover{
background-color: #45a049;
}
.container{
border-radius:5px;
background-color: #f2f2f2;
padding:20px;
}
.col-25{
float:left;
width:25%;
margin-top:6px;
}
.col-75{
float:left;
width:75%;
margin-top:6px;
}
.row::after{
content:"";
clear:both;
display:table;
}
</style>
<style>
/* ๋ฏธ๋์ด์ฟผ๋ฆฌ + ์กฐ๊ฑด */
@media only screen and (max-width:600px){
.col-25, .col-75, input[type=submit]{
width:100%;
margin-top:0;
}
}
</style>
* row ๋ก ๊ตฌ๋ถ ์ ๋๋ก ํด์ฃผ๊ธฐ์ํด .row::after ์ถ๊ฐ
<div class="container">
<form action="">
<div class="row">
<div class="col-25">
<label for="fname">First Name</label>
</div>
<div class="col-75">
<input type="text" id="fname" name="firstname" placeholder="Your name..">
</div>
</div>
<div class="row">
<div class="col-25">
<label for="lname">Last Name</label>
</div>
<div class="col-75">
<input type="text" id="lname" name="lastname" placeholder="Your last name..">
</div>
</div>
<div class="row">
<div class="col-25">
<label for="country">Country</label>
</div>
<div class="col-75">
<select id="country" name="country">
<option value="australia">Australia</option>
<option value="canada">Canada</option>
<option value="usa">USA</option>
</select>
</div>
</div>
<div class="row">
<div class="col-25">
<label for="subject">Subject</label>
</div>
<div class="col-75">
<textarea id="subject" name="subject" placeholder="Write something.." style="height:200px"></textarea>
</div>
</div>
<div class="row">
<input type="submit" value="Submit">
</div>
</form>
</div>
[display ์์ฑ]
1. inline ๋ชจ๋
๋๋น์ ๋์ด ์ค์ ์ ๋ถ๊ฐ๋ฅํ๋ค.
2. block ๋ชจ๋
๋๋น์ ๋์ด ์ค์ ์ด ๊ฐ๋ฅํ๋ค.
but ๋ฌธ์ ์ ) ์๋ ๊ฐํ..
3.inline-block ๋ชจ๋
๋๋น์ ๋์ด ์ค์ ์ด ๊ฐ๋ฅํ๋ค. ์๋ ๊ฐํ X.
top, bottom ์ฌ๋ฐฑ/ํจ๋ฉ ์ ์ฉ๋ ๊ฐ๋ฅํ๋ค.
<style>
span.a{
/* inline */
display:inline; /* span ์์์ ๊ธฐ๋ณธ๊ฐ */
border:1px solid blue;
background-color: yellow;
padding:5px; /* ์ ์ฉ๋จ. */
/* ๋๋น, ๋์ด */
width:150px;
height:100px;
}
span.b{
/* block */
display:block; /* span ์์์ ๊ธฐ๋ณธ๊ฐ */
border:1px solid blue;
background-color: yellow;
padding:5px; /* ์ ์ฉ๋จ. */
/* ๋๋น, ๋์ด */
width:150px;
height:100px;
}
span.c{
/* inline-block */
display:inline-block; /* span ์์์ ๊ธฐ๋ณธ๊ฐ */
border:1px solid blue;
background-color: yellow;
padding:5px; /* ์ ์ฉ๋จ. */
/* ๋๋น, ๋์ด */
width:150px;
height:100px;
}
</style>
<h3>display:inline</h3>
<div>
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Rem ipsam dicta nam <span class="a">aliquam</span>
<span class="a">eum</span> distinctio expedita delectus
repellendus veniam dolor fugiat suscipit quas nihil libero
architecto iusto odit itaque adipisci!
</div>
<h3>display:block</h3>
<div>
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Rem ipsam dicta nam <span class="b">aliquam</span>
<span class="b">eum</span> distinctio expedita delectus
repellendus veniam dolor fugiat suscipit quas nihil libero
architecto iusto odit itaque adipisci!
</div>
<h3>display:inline-block</h3>
<div>
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Rem ipsam dicta nam <span class="c">aliquam</span>
<span class="c">eum</span> distinctio expedita delectus
repellendus veniam dolor fugiat suscipit quas nihil libero
architecto iusto odit itaque adipisci!
</div>
Previous & Next ๋ฒํผ
<style>
a{
text-decoration: none;
padding:8px 16px;
display:inline-block; /* ๋๋น, ๋์ด ์ง์ */
}
a:hover{
background-color: #ddd;
color:black;
}
.prev{
background-color: #f1f1f1;
color:black;
float:left;
}
.next{
background-color: #4caf50;
color:white;
float:rigth;
}
</style>
<style>
.round{
border-radius:50%;
}
</style>
<a href="#" class="prev">«Previous</a>
<a href="#" class="next">Next»</a>
<a href="#" class="prev round">‹</a>
<a href="#" class="next round">›</a>
๋ ์ด์์(๋ฐฐ์น):[์ํ ์ ๋ ฌ], ์์ง ์ ๋ ฌ
1.๋ธ๋ญ๋ชจ๋(div)๋ฅผ ๊ฐ๋ก๋ก ์ค์์ ๋ฐฐ์น
.center{
width:50%;
border:3px solid green;
text-align:center; /* ์์ ๋ด๋ถ์ ํ
์คํธ๋ฅผ ์ค์์ ๋ฐฐ์น */
padding:10px;
margin:0 auto; /* ์์ ์์ฒด๋ฅผ ์ค์ ๋ฐฐ์น */
}
<!-- .center>p>{Hello World!} -->
<div class="center">
<p>Hello World!</p>
</div>
2. ์ธ๋ผ์ธ๋ชจ๋(img)๋ฅผ ๊ฐ๋ก๋ก ์ค์์ ๋ฐฐ์น
img{
width:30%;
display:block;
margin:0 auto; /* ์ธ๋ผ์ธ๋ชจ๋์ด๊ธฐ ๋๋ฌธ์ ์ ์ฉ์ด ๋์ง ์๋๋ค. */
}
<img src="../images/paris.jpg" alt="paris">
3. ์ฐ์ธก์ ๋ฐฐ์น
1) position:absolute
2) float:right
#demo{
width:50%;
border:3px solid #73ad21;
padding:3px;
position:absolute;
right:0;
/* float:right; */
}
<div id="demo">
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Totam pariatur maxime voluptatibus nobis aliquid cupiditate
possimus similique ducimus eligendi quis eaque corporis
dignissimos debitis eum expedita repellat cumque inventore itaque.
</div>
๋ ์ด์์(๋ฐฐ์น):์ํ ์ ๋ ฌ, [์์ง ์ ๋ ฌ]
<style>
.center{
width:50%;
border:3px solid green;
margin: 0 auto;
text-align:center;
/*
height:200px;
*/
/* 1. padding ์์ฑ ์ฌ์ฉ : top/bottom ์ค์ . ๋์ด ์ค์ X. */
/* padding:70px 0 70px 0; */
/* padding: 70px 0; */
/* 2. ํ(ํธ๋ฆญ) : ๋์ด ์์ฑ๊ณผ line-height ์์ฑ๊ฐ์ ๋์ผํ๊ฒ ์ค์ ํ๋ฉด -> ์ค์ */
/* line-height : ๋ผ์ธ๊ณผ ๋ผ์ธ ๊ฐ๊ฒฉ
height:200px;
line-height:200px;
*/
/* 3. transform ์์ฑ ์ฌ์ฉ : ๋ณํ์ํค๋ ์์
*/
height:200px;
position:relative; /* ๊ฐ์ฅ ๊ฐ๊น์ด ๊ธฐ์ค์ด ๋๋ ๋ถ๋ชจ ์์ */
}
.center p{
margin:0;
padding:0;
position:absolute;
left:50%;
top:50%;
border:1px solid red;
/* 3. */
transform:translate(-50%, -50%); /* ๋๋น, ๋์ด */
-ms-transform:translate(-50%, -50%); /* IE */
}
</style>
<div class="center">
<p>Hello World!</p>
</div>
* -ms-transform : explorer
* ์ ํ(transition) ๋ณํ(transform) : https://velog.io/@wlrhkd49/CSS-%EC%86%8D%EC%84%B1-%EC%A0%84%ED%99%98-%EB%B3%80%ED%99%98
+ 4) flex
<style>
.center{
width:400px;
height:200px;
border:3px solid green;
margin: 0 auto;
text-align:center;
/* 4. flexbox๋ฅผ ์ฌ์ฉํด์ ์ฌ๋ฌผ์ ์ค์์ ๋ฐฐ์น */
/* IE10 ๋ฐ ์ด์ ๋ฒ์ ์์๋ ์ง์๋์ง ์๋๋ค. */
display:flex; /* flex:๊ตด๊ณก์ง๋ค. */
justify-content: center;
align-items: center;
}
.center p{
}
</style>
[ css 4๊ฐ์ง ๊ฒฐํฉ์(์ฐ์ฐ์) ]
- ์ ํ์ ๊ฐ์ ๊ด๊ณ๋ฅผ ์ค๋ช ํ๋ ๊ฒ
1) ์ ํ์ ์ ํ์ : ํ์ ํฌํจ
2) ์ ํ์ > ์ ํ์ : ์ง๊ณ์์๋ง
3) ์ ํ์ + ์ ํ์ : div + p = div์ ์ธ์ ํ p (๋ฐ๋ก ๋ค)
4) ์ ํ์ ~ ์ ํ์ : div ~ p = div์ ๋ฐ๋ผ์ค๋ ๋ชจ๋ ํ์ p
[:์์ฌํด๋์ค]
1. ์์์ ํน์ํ ์ํ๋ฅผ ์ ์ํ ๋ ์ฌ์ฉํ๋ค.
1) :link, :visited, :hover, :active
2) :focus
3) :first-child
4) :first-letter
5) :not(selector)
:checked, :empty, :first-of-type, :invalid, :in-range,
:land(language), :last-child, :last-of-type, :nth-child(n),
:nth-last-child(n), :only-child, :optional,
:out-of-range, :read-only, :read-write, :required,
:root, :target, :valid
[::์์ฌ์์] ex08
1. ์์์ ์ง์ ๋ ๋ถ๋ถ์ ์คํ์ผ์ ์ง์ ํ ๋ ์ฌ์ฉํ๋ค.
2. ์์์ ์ฒซ ๊ธ์(::first-letter), ์์์ ์ฒซ ๋ผ์ธ(::first-line)
3. ์์ ์ฝํ ์ธ ๋ค์ ์ฝ์ ::after
4. ์์ ์ฝํ ์ธ ์์ ์ฝ์ ::before
5. ๋ชฉ๋ก ํญ๋ชฉ์ ๋ง์ปค๋ฅผ ์ ํ ::marker
6. ์ฌ์ฉ์์ ์ํด์ ์ ํ๋ ์์์ ์ผ๋ถ ::selection
color, background, cursor, outline ์์ฑ ์ ์ฉ
1) ::after
2) ::first-letter
::first-line
::before, ::selection
<์์ฌ์์ ์์ >
1. css counter : css ์๋๋ฒํธ๋งค๊ธฐ๊ธฐ
1) section ์นด์ดํฐ ๋ณ์ ์ ์ธ == ์นด์ดํฐ ์์ฑ ๋๋ ์ฌ์ค์ + ์ด๊ธฐํ(0)
counter-reset:section;
2) ์นด์ดํฐ ๋ณ์ 1์ฉ ์ฆ๊ฐ
counter-increment:section;
3) ์์ฑ๋ ์นด์ดํฐ ์ฝ์ .
๋ด์ฉ : counter() / counters() ์์์ ์นด์ดํธ ์ถ๊ฐ
content:counter(section);
<style>
body{
counter-reset:section;
}
div::before{
counter-increment:section;
content:counter(section);
background-color: black;
color:white;
padding: 1px 10px;
margin-right:16px;
border-radius:50%;
}
</style>
<div>Java</div> <div>Jsp</div> <div>Oracle</div> <div>JDBC</div> <div>html5</div> <div>css3</div>
*counter-reset : ์๋ ๋ฒํธ
css ๋ถํฌ๋ช ๋/ํฌ๋ช ๋ ์ง์
img == ์ธ๋ผ์ธ๋ชจ๋
1) opacity ์์ฑ
2) rgb[a] == alpha ์์(ํ์)์์์ ํฌ๋ช ๋๋ ์์๋์ง ์๋๋ค.
img{
width:170px;
height:100px;
opacity:0.5;
}
img:hover{
opacity:0.8;
}
<img src="../images/img_forest.jpg" alt="">
<img src="../images/img_mountains.jpg" alt="">
<img src="../images/img_5terre.jpg" alt="">
ํ์๋ชจ๋ฌ
1. ๋ค๋น๊ฒ์ด์ ๋ฐ(๋ฉ๋ด๋ฐ, ํ์ํ์์ค)
์ฌ์ฉํ๊ธฐ ์ฌ์ด ํ์ ๊ธฐ๋ฅ - ๋ชจ๋ ์น ์ฌ์ดํธ์์ ์ค์ํ๋ค!
2. ul>li>a
<style>
body{
transition:0.5s ease;
}
div#main{
padding: 16px;
transition:0.5s ease;
}
.sidenav{
background-color: #111;
position:fixed; /* width:100% -> inline๋ชจ๋์ฒ๋ผ ๋ด์ฉ ๋๋น. */
left:0;
top:0;
height:100%;
/* ์์ง ๋ค๋น๊ฒ์ด์
๋ฉ๋ด๋ฐ : ์จ๊น */
width:0;
overflow-x:hidden;
transition:0.5s ease;
}
.sidenav a{
display:block;
color:#818181;
padding:8px 8px 8px 32px;
font-size:25px;
text-decoration: none;
transition:0.5s ease;
}
.sidenav a:hover{
color:#f1f1f1;
}
</style>
<!-- #mySidenav.sidenav>a[href="#"]*5 -->
<div id="mySidenav" class="sidenav">
<a href="#" class="closebtn">×</a>
<a href="#">About</a>
<a href="#">Services</a>
<a href="#">Clients</a>
<a href="#">Contact</a>
</div>
<!-- #main>h2>lorem3^p>lorem20^span -->
<div id="main">
<h2>Lorem ipsum dolor.</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minus inventore aspernatur laudantium neque autem esse ipsam nostrum repellat ad iure?</p>
<span style="cursor: pointer;font-size: 30px;" onclick="openNav()">☰</span>
</div>
<script>
function openNav(){
// width:0; -> ๋๋น ์ค์
// *** ๊ผญ ๋ฌธ์์ด๋ก ์ค์ผํ๋ฉฐ ๋จ์๋ ์ค์ผํ๋ค!! ***
// *** margin-left -> marginLeft ***
document.getElementById("mySidenav").style.width="250px";
document.getElementById("main").style.marginLeft="250px";
documnet.body.style.backgroundColor="rgba(0, 0, 0, 0.4)";
}
document.querySelector("#mySidenav>a.closebtn").onclick = function(){
// alert("!!");
// ์ด๋ฒคํธ ๋ฒ๋ธ๋ง
document.getElementById("mySidenav").style.width="0";
document.getElementById("main").style.marginLeft="0";
documnet.body.style.backgroundColor="white";
}
</script>
๋๋กญ๋ค์ด(dropdown) from_ex07.html : ํดํ (ํ์๋ฉ๋ด)
.dropdown{
position:relative; /* *** */
display:inline-block; /* ์ด๋ ๊ฒ ์ค์ ํด์ผ ํ๋ค.*** */
left:300px;
}
.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;
}
/* ex07.html ํดํ */
.dropdown:hover .dropdown-content{
display:block;
}
<div class="dropdown">
<span>Mouse Over Me</span>
<div class="dropdown-content">
<p>Hello World!</p>
</div>
</div>
<br>
js<br>
css<br>
* ๋ถ๋ชจ relative ์์ absolute ์ค์!
ex2)
.dropdown{
position:relative;
display:inline-block;
}
.dropdown-content{
display:none;
position:absolute;
right:0;
background-color: #f9f9f9;
min-width:160px;
box-shadow:9px 8px 16px 0 rgba(0, 0, 0, 0.2);
z-index:1;
}
.dropdown-content a{
display:block; /* ์์ผ๋ฉด ์์ผ๋ก ์ถ๋ ฅ๋๋ค. */
padding:12px 16px;
text-decoration: none;
color:block;
}
.dropdown-content a:hover{
background-color: #f1f1f1;
}
.dropbtn{
background-color: #4caf50;
color:white;
padding:16px;
font-size:16px;
border:none;
cursor:pointer;
}
.dropdown:hover .dropdown-content{
display:block;
}
<!-- .dropdown>button.dropbtn+.dropdown-content>a[href="#"]*3>{Link $} -->
<div class="dropdown" style="float: left">
<button class="dropbtn">Left</button>
<div class="dropdown-content" style="left:0">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</div>
<div class="dropdown" style="float:right">
<button class="dropbtn">Right</button>
<div class="dropdown-content">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</div>
์ต๊ทผ๋๊ธ