[Day3] CSS 3 [11/14]
JS๋ก ๋์ ๋ฒํผ ์์ฑ - DOM ๋ฉ์๋ ์ฌ์ฉ
// 1. ๋ฒํผ [์์๋ฅผ ์์ฑ] - createElement() ๋ฉ์๋
var btn = document.createElement("button");
// 2. <button>ํ์๊ฐ์
</button> ํ
์คํธ๋
ธ๋
// ์ปฌ๋ ์
ํด๋์ค - LinkedList : node
// var textNode = document.createTextNode("๋ฒํผ - 1");
// btn.appendChild(textNode);
// 2-2. <์์ํ๊ทธ>Content(๋ด์ฉ)</์ข
๋ฃํ๊ทธ>
// <button>๋ฒํผ - 1 innerText ์์ฑ</button>
btn.innerText = "๋ฒํผ - 1";
// 3. ๋์ ์์ฑํ ๋ฒํผ์ ํด๋ฆญ ์ด๋ฒคํธ ์ฒ๋ฆฌ.
btn.onclick = function (){
alert(" ๋ฒํผ - 1 ํด๋ฆญ");
}
// js == java ๋ช
๋ น์ข
๊ฒฐ์ฐ์ฐ์ ; ์ธ๋ฏธ์ฝ๋ก ๋ถ์ธ๋ค. ( ์๋ต ๊ฐ๋ฅ )
// 4. ์์ฑ๋ ๋ฒํผ์ [๋ถ๋ชจ์์ body]์ ์ถ๊ฐ
// document.getElementById(id)
// document.querySelector("body")
document.body.appendChild(btn);
* ๋ง์ง๋ง ์์์์ = script
๋ง์ง๋ง ์์ ์์์ ์ถ๊ฐ -> button ์ถ๊ฐ๋จ (์ด๋ฆ์ด ์๊ธฐ ๋๋ฌธ์ ์๊ฒ ๋์ด)
<button id="btnExec" style="width:150px;">์คํ ๋ฒํผ</button>
<!-- <button id="btnExec" width="150px">์คํ ๋ฒํผ</button> -->
<!-- p#demo -->
<p id="demo">XXX</p>
<script>
// document.getElementById("btnExec");
document.querySelector("#btnExec").onclick = function (){
var pEle = document.querySelector("#demo");
// <p></p>
// button*10, br*10 ๋ชจ๋ ์์ ์์ ์ ๊ฑฐ
pEle.innerText = "";
//alert(" ์ ์ ๋ฉ์ถค ");
// ๋ฒํผ * 10 => p ์ถ๊ฐ
for (var i = 1; i <= 10; i++) {
var btn = document.createElement("button");
// ๋ฒํผ์ ๋๋น : 150px
// js ? style="width:150px;"
// style ์์ฑ "width:150px;" ์์ฑ๊ฐ
// btn.setAttribute(name, value);
// value = btn.getAttribute(name);
// js ์ฝ๋ฉ -> F12 ๋๋ฒ๊น
.
// btn.setAttribute("style", "width:150px;");
btn.style.width = "150px"; // px ๋จ์ ๊ผญ ๋ถ์ด์.
//btn.setAttribute("width", "150px"); // X
//btn.width = "150px;" X
btn.innerText = "๋ฒํผ - "+ i;
btn.onclick = function (){
// [***** js ํด๋ก์ *****]
// *** alert(" ๋ฒํผ - "+i+" ํด๋ฆญ");
// js์์ ์ด๋ฒคํธ๊ฐ ๋ฐ์ํ๋ฉด ๋ชจ๋ ์ด๋ฒคํธ ์ ๋ณด๋ฅผ ์ ์ฅํ๋ ๊ฐ์ฒด : event ๊ฐ์ฒด
alert( event.srcElement.innerText );
};
pEle.appendChild(btn);
// <button> ์ธ๋ผ์ธ ๋ชจ๋
pEle.appendChild( document.createElement("br") );
} // for
};
</script>
* p ํ๊ทธ์ ์์ ์์๋ค ์ง์ด๋ฃ์ด์ผํจ -> document.body.appendChild(btn) -> pEle.appendChild(btn);
* js ํด๋ก์ !!! (์ค์)
-> event ๋ด๊ฒจ์ ธ์์
* button ์์ฑ์ width ์์ฑ์..?
* ์คํ๋ฒํผ ๋๋ฅผ๋๋ง๋ค ๋ฒํผ์๊ธฐ๋๊ฑฐ ์ด๊ธฐํ -> ํด๋ฆญํ ๋ ์ ๊ฑฐํ๊ธฐ
jQuery๋ก ์์
<script>
$("#btnExec").click( function (){
$("#demo").text(""); // js innerText="" ์์ฑ = jquery text("") ๋ฉ์๋ , html() ๋ฉ์๋
for (var i = 1; i <= 10; i++) {
var btn = $("<button>๋ฒํผ - " + i + "</button>");
// style ์์ฑ
// jquery method : css();
btn.css("width", "150px");
// js์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ : jquery
btn.click(function() {
// alert(" ๋ฒํผ ํด๋ฆญ๋จ!! ");
alert( $(this).text() );
// alert( event.srcElement.innerText );
});
//$("#demo").append(btn);
//$("#demo").append($("<br>"));
// ์ฒด์ด๋
$("#demo")
.append(btn)
.append($("<br>"));
} // for
});
</script>
* ex02_02 ์ค์ต ํด๋ณด๊ธฐ
css ํ์ด์ง ์ฒ๋ฆฌ
<style>
*{
box-sizing: border-box;
}
/* ์ ๋ ์ง์ ์ฝ๋ฉ์ ํ๋๋ผ๋ ์ฌ๋ฌ๋ถ๋ค์ ์์ด๋๋ช
, ํด๋์ค๋ช
๋ฑ๋ฑ ๋ณต์ฌ ๋ถ์ด๊ธฐ */
.pagination{
/* background-color: red; */
width: 50%;
margin: 0 auto; /* 0 t/b auto l/r ๊ฐ์ด๋ฐ ์ ๋ ฌ*/
overflow: auto;
}
.pagination a{
color:black;;
text-decoration: none;
/* padding: 5px; */
/* margin: 3px; */
float:left;
width: 8.3%;
text-align: center;
}
.pagination a:hover{
background-color: #ddd;
}
.pagination a.active{
background-color: dodgerblue;
color:white;
}
</style>
<!-- .pagination>a[href=#]*12>{$} -->
<div class="pagination">
<a href="#">1</a>
<a href="#">2</a>
<a href="#">3</a>
<a href="#">4</a>
<a href="#">5</a>
<a href="#">6</a>
<a href="#" class="active">7</a>
<a href="#">8</a>
<a href="#">9</a>
<a href="#">10</a>
<a href="#">></a>
<a href="#">»</a>
</div>
<script>
$(".pagination a").click(function (event){
// not()
$(".pagination a").not(this).removeClass("active");
$(this).addClass("active"); // [ajax( ์์ด์์ค ) ์ฌ์ฉ]
});
</script>
css ๋ชฉ๋ก : ul, ol , li , dl, dd, dt
1)
<style>
ul, ol{
background-color: yellow;
border:1px solid red;
}
ul.first{
/* list-style-type: upper-roman; */
/* ํญ๋ชฉ ๋ง์ปค์ ์์น : li ํ๊ทธ ์์ */
list-style-position: inside;
}
ol.second{
/* list-style-type: disc; */
/* ํญ๋ชฉ ๋ง์ปค์ ์์น : li ํ๊ทธ ๋ฐ์ ( ๊ธฐ๋ณธ ) */
list-style-position: outside;
}
li{
/* background-color: green; */
}
ul, ol{
list-style-type: none;
margin: 0;
padding: 0;
}
</style>
2)
<style>
ul{
/*
list-style-type: upper-roman;
list-style-position: inside;
list-style-image: url();
*/
/* ์ฝ์ ์์ฑ */
/* list-style: type postion image; */
list-style-image: url('../images/arr.gif');
}
ul li{
border-bottom: 1px solid red;
}
/* li ํ๊ทธ ์ค์ ๋ง์ง๋ง li ํ๊ทธ๋ border-bottom์ ์ ๊ฑฐ */
/* ul li:nth-child(5){ */
ul li:last-child{
border-bottom: none;
}
</style>
<body>
<!-- ul.first>li*5>lorem1 -->
<ul class="first">
<li>Lorem.</li>
<li>Autem!</li>
<li>Minus!</li>
<li>Doloribus!</li>
<li>Molestias.</li>
</ul>
<ol class="second">
<li>Lorem.</li>
<li>Autem!</li>
<li>Minus!</li>
<li>Doloribus!</li>
<li>Molestias.</li>
</ol>
</body>
css ํ ์ด๋ธ
<style>
table{
width: 100%;
border-collapse: collapse;
}
caption{
font-weight: bold;
text-transform: uppercase;
caption-side: bottom;
}
th, td{
border-bottom: 1px dotted red;
}
th{
width: 100px;
height: 70px;
}
td{
height: 30px;
text-align: center;
vertical-align: middle;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
/* not() jquery method */
/* :not() css selector */
tr:hover:not( :first-child ){
background-color: #4caf50;
}
</style>
<!-- table>caption+tr*3>td*4>{$} -->
<table>
<caption>table sample</caption>
<!-- tr>th*4>{์ปฌ๋ผ๋ช
$} -->
<tr>
<th>์ปฌ๋ผ๋ช
1</th>
<th>์ปฌ๋ผ๋ช
2</th>
<th>์ปฌ๋ผ๋ช
3</th>
<th>์ปฌ๋ผ๋ช
4</th>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
</table>
css ๋ฐ์ํ ํ ์ด๋ธ
- ํ๋ฉด์ด ๋๋ฌด ์์์ ์ ์ฒด ํ ์ด๋ธ์ ํ์ํ ์ ์๋ ๊ฒฝ์ฐ
- ๋ฐ์ํ ํ ์ด๋ธ์ ๊ฐ๋ก ์คํฌ๋กค ๋ง๋๊ฐ ํ์๋๋๋กํ๋ ๊ฒ.
- overflow:auto ์ปจํ ์ด๋ ์์์ ์์์์๋ฅผ ์ถ๊ฐํ์ฌ ๋ฐ์ํ ์ผ๋ก ๋ง๋ค ๋ ์ฌ์ฉํ๋ ์์ฑ
<style>
table{
width: 100%;
border-collapse: collapse;
}
th, td{
text-align: left;
padding: 8px;
}
tr:nth-child(even){
background-color: #f2f2f2;
}
div{
border: 1px solid red;
overflow-x:auto;
}
</style>
<!-- table>(tr>th*10>lorem1)+(tr>td*10>lorem1) -->
<div>
<table>
<tr>
<th>Lorem.</th>
<th>Aut.</th>
<th>In.</th>
<th>Ea.</th>
<th>Dolore.</th>
<th>Soluta.</th>
<th>Eligendi.</th>
<th>Nam.</th>
<th>Quasi.</th>
<th>Iusto!</th>
</tr>
<tr>
<td>Lorem.</td>
<td>At!</td>
<td>Provident?</td>
<td>Ducimus.</td>
<td>Ratione.</td>
<td>Placeat?</td>
<td>Amet.</td>
<td>Nihil!</td>
<td>Sunt!</td>
<td>Dolor.</td>
</tr>
</table>
</div>
display ์์ฑ
1. ๋ ์ด์์์ ์ ์ดํ๋ ๊ฐ์ฅ ์ค์ํ CSS ์์ฑ
2. ๊ธฐ๋ณธ๊ฐ : inline / block
3. ์์๊ฐ ํ์๋๋์ง ์ฌ๋ถ๋ฅผ ์ง์ ํ๋ ์์ฑ.
<!-- ๋ธ๋ญ๋ชจ๋ : div, hn, p, header, footer, section,๋ฑ๋ฑ-->
<!-- ul>li*3>a[href="#"]>lorem1 -->
<ul>
<li><a href="#">Lorem.</a></li>
<li><a href="#">Praesentium.</a></li>
<li><a href="#">Temporibus.</a></li>
</ul>
<!-- ์ธ๋ผ์ธ๋ชจ๋ : a, span, img -->
<!-- span*3>lorem1 -->
<span>Lorem.</span>
<span>Error?</span>
<span>Commodi?</span>
ex)
display:none/block, visibility:hidden/visible ์์ฑ์ ์ฐจ์ด์
<style>
.imgbox{
width: 120px;
border:1px solid gray;
padding: 6px;
text-align: center;
float: left;
}
.imgbox img, imgbox button{
width: 100%;
}
</style>
<style>
#imgbox1{
/* display: none; ์์ญ์ฐจ์ง X */
/* visibility: hidden; ์์ญ์ฐจ์ง O( ์ ์ง ) - ๋ ์ด์์ ์ํฅ ๋ผ์น๋ค. */
}
</style>
<div id="imgbox1" class="imgbox">
Box1
<img src="../images/img_5terre.jpg" alt="" />
<button onclick="remove();">Remove</button>
</div>
<div id="imgbox2" class="imgbox">
Box2
<img src="../images/img_5terre.jpg" alt="" />
<button onclick="hide('imgbox2');">Hide</button>
</div>
<div id="imgbox3" class="imgbox">
Box3
<img src="../images/img_5terre.jpg" alt="" />
<button onclick="resetAll();">ResetAll</button>
</div>
js
<script>
function remove() {
// ์์ญ ์ ์ง X - ์จ๊น display=none
// js ๋จ์ ์๋ต(์ฃผ์), ์์ฑ๊ฐ์ ๋ฌธ์์ด๋ก ์ค์ ..(์ฃผ์)
document.querySelector("#imgbox1").style.display = "none";
}
function hide(id) {
// ์์ญ ์ ์ง O - ์จ๊น visibility=hidden
document.getElementById(id).style.visibility = "hidden";
}
function resetAll() {
// ์จ๊น - ๋ณด์ด๋๋ก...
document.querySelector("#imgbox1").style.display = "block";
document.getElementById("imgbox2").style.visibility = "visible";
}
</script>
jquery
<script>
$("#imgbox1 button").click(function (){
// alert("test")
// ์์ญ ์ ์ง X + ์จ๊น
// display=none
// $("#imgbox1").css("display","none"); // jquery css() ๋ฉ์๋
$("#imgbox1").hide(); // jquery hide() ๋ฉ์๋
});
$("#imgbox2 button").click(function (){
// alert("test")
$("#imgbox2").css("visibility", "hidden");
});
$("#imgbox3 button").click(function (){
// alert("test")
$("#imgbox1").show();
$("#imgbox2").css("visibility", "visible");
});
</script>
ex2)
<style>
#panel, .flip{
font-size: 16px;
padding: 10px;
background-color: #4acf50;
color:white;
text-align: center;
margin:auto;
border:1px solid #a6d8a8;
}
#panel{
display: none;
}
.flip:hover{
cursor: pointer;
color:red;
}
</style>
<!-- p.flip>{Click to show panel}^#panel>p*3>lorem -->
<p class="flip">Click to show panel</p>
<div id="panel">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Explicabo sit repudiandae totam rem numquam velit architecto libero unde ratione dignissimos molestiae deserunt amet doloremque aliquid nostrum similique reprehenderit fugit culpa!</p>
<p>Modi blanditiis nemo ducimus saepe ipsum dignissimos repudiandae eos atque. Nihil quisquam rerum vel voluptatem voluptas harum dicta laborum culpa asperiores dolore natus illum laudantium doloribus. Expedita delectus at sint!</p>
<p>Beatae numquam totam accusantium placeat doloremque consectetur iusto dolores esse facere quo impedit facilis sunt delectus commodi ducimus iure vel sequi velit et eum! Accusantium pariatur tenetur soluta mollitia adipisci.</p>
</div>
js
<script>
var sw = false; // ์ค์์น๋ณ์, ์ ์ญ๋ณ์
document.querySelector("p.flip").onclick = function (){
// alert("Test");
/*
if ( !sw ) {
document.getElementById("panel").style.display = "block";
//sw = true;
} else {
document.getElementById("panel").style.display = "none";
//sw = false;
}
*/
// js - if ~ else , ์ผํญ์ฐ์ฐ์ ? :
document.getElementById("panel").style.display = sw ? "none" : "block";
sw = !sw;
}
</script>
jquery
<script>
// sw๋ณ์ ์ ์ธ. X
$("p.flip").click( function (){
// alert("test")
// alert( $("#panel").css("display") ); // "none" ์์ฑ์ ๊ฐ์ ์ป์ด์๋ค.
/*
if( $("#panel").css("display") == "none"){
$("#panel").show();
}else{
$("#panel").hide();
}
*/
// jquery method - toggle() ํ ํด ๋ฉ์๋
// $("#panel").toggle(); // hide-> show, show -> hide
// jquery method - slideToggle()
$("#panel").slideToggle(5000); // slow, fast 1000ms
} );
</script>
width, max-width, min-width ์์ฑ
<style>
div{
border: 3px solid #73ad21;
}
.ex01{
width: 500px;
}
.ex02{
/* width:100%; ๊ธฐ๋ณธ๊ฐ */
max-width: 500px;
}
</style>
<!-- .ex$$*2>lorem5 -->
<div class="ex01">Lorem ipsum dolor sit amet.</div>
<br>
<div class="ex02">Eaque sint consequatur sit tenetur.</div>
๋ ์ด์์ ๊ด๋ จ ์์น : position ์์ฑ *****
[ position ์์ฑ - ์์์ ์์น ์ง์ ๋ฐฉ๋ฒ]
1. static ( ์ ์ , ๊ธฐ๋ณธ๊ฐ ) - top,bottom,left, right ์์ฑ X
2. relative ( ์๋์ขํ) - ๊ธฐ์ค
3. fixed ( ๊ณ ์ )
4. absolute ( ์ ๋ ์ขํ ) - ๊ฐ์ฅ ๊ฐ๊น์ด ๋ถ๋ชจ(์กฐ์)์์๋ฅผ ๊ธฐ์ค์ผ๋ก ๋ฐฐ์น
5. sticky ( ์ฌ์ ์ ์๋ฏธ : ๋์ ๋์ ํ ) - ์ฌ์ฉ์์ ์คํฌ๋กค ์์น์ ๋ฐ๋ผ ๋ฐฐ์น
- postion ์์ฑ์ ๋จผ์ ์ค์ ํ์ง ์์ผ๋ฉด t/b/l/r ์์ฑ์ ์ ์ฉ๋์ง ์๋๋ค.
- top, bottom, left, right ์์ฑ์ ์ฌ์ฉํด์ ๋ฐฐ์น
ex1)
<style>
.box{
border:1px solid gray;
width:100px;
height:100px;
text-align: center;
}
</style>
<style>
/* :nth-of-type(1) , :nth-child(1) */
div:nth-of-type(1){
position:static;
background-color: red;
}
div:nth-of-type(2){
position:relative;
left:30px;
top:30px;
background-color: green;
}
div:nth-of-type(3){
/* Box - 4 ์ ์์น๊ฐ Box-3 ์์น*/
position:fixed;
right:10px;
bottom:10px;
background-color: blue;
}
div:last-of-type{
background-color: yellow;
position: absolute; /* ์ ๋์ขํ */
left:30px;
top:30px;
z-index: -1;
}
</style>
<script>
// js๋ก div ์์ 5๊ฐ๋ฅผ ๋์ ์ถ๊ฐ.
for (var i = 1; i <=5 ; i++) {
var div = document.createElement("div");
div.innerText = "Box - " + i;
/*
div.style.border = "1px solid gray";
div.style.width = "100px";
div.style.height = "100px";
// div.style.text-align = "center";
div.style.textAlign = "center";
*/
/* <style> .box ํด๋์ค๋ช
</style> -> js ํด๋์ค ์์ฑ ์ค์ . */
// div.className = "box";
div.classList.add("box");
document.body.appendChild(div);
} // for
// jquery๋ก p ์์ 50๊ฐ ๋์ ์ถ๊ฐ.
for (var i = 1; i <=50 ; i++) {
$("body").append( $("<p>.</p>") );
// $("body").append( $("<p></p>").text(".") );
} // for
</script>
postion:sticky;
- IE ์ง์ํ์ง ์๋ ์์ฑ.
- Safari : webkit- ์ ๋์ฌ๋ฅผ ๋ถ์ธ๋ค.
- left, right, bottom, top ์ ์ด๋ ํ๋๋ ์ง์ ํด์ผ ๋๋ค.
ex1)
<style>
div.stick_test{
border:2px solid #4caf50;
background-color: #cae8ca;
padding: 3px;
text-align: center;
/* ์ฌ์ฉ์์ ์คํฌ๋กค ์์น์ ๋ฐ๋ผ ๋ฐฐ์น */
position: sticky;
position: -webkit-sticky; /* Safari */
top:0;
}
div:last-of-type{
/* ์คํฌ๋กค๋ฐ๋ฅผ ๊ธธ๊ฒ ์๊ธฐ๋๋ก ํ๊ธฐ ์ํด */
padding-bottom: 2000px;
border:1px solid gray;
}
</style>
<!-- p>lorem -->
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Magnam sit deleniti ducimus consequuntur fuga perferendis doloribus
facere assumenda porro amet dicta eum sequi iusto rerum in eligendi
quod consequatur impedit!
</p>
<!-- .stick_test -->
<div class="stick_test">hello world</div>
<!-- div>p*3>lorem -->
<div>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Cumque aspernatur enim odio voluptas quo non est eius officia
rerum minima molestiae suscipit ad omnis deleniti accusantium
repellat perferendis distinctio quos.
</p>
<p>
Expedita dignissimos laborum odio ea quisquam tempore
alias vel iste odit. Aliquid dolore itaque modi fuga harum molestiae
eaque libero architecto rem! Reiciendis harum dolore corporis
earum culpa tempore dolores!
</p>
<p>
Ex odio est cupiditate nemo quia vero quo? Fuga culpa ullam
officia dolores harum ab ducimus quidem nostrum deserunt sunt
accusamus consequuntur quisquam fugiat. Iusto reiciendis dolore
ipsa sunt laboriosam.
</p>
</div>
ex2)
<style>
body{
margin: 0;
padding: 0;
font-size: 28px;
font-family: Arial, sans-serif;
}
header{
background-color: #f1f1f1;
text-align: center;
padding:30px;
}
</style>
<style>
#navbar{
background-color: #333;
overflow: auto;
position: sticky;
position: -webkit-sticky;
top:0;
/*
width: 50%;
border:1px solid red;
*/
}
#navbar a{
color:#f2f2f2;
display: block;
font-size: 17px;
text-decoration: none;
padding: 14px 16px;
text-align: center;
/* */
float:left;
}
/*
#navbar::after{
}
*/
#navbar a:hover{
color:black;
background-color: #ddd;
}
#navbar a.active{
color:white;
background-color: #4caf50;
}
</style>
v<!-- (header>h3+p>lorem5)+(nav#navbar>a[href='#']*3)+(section.content>h3+p*15>lorem) -->
<header>
<h3>TOP</h3>
<p>Lorem ipsum dolor sit amet.</p>
</header>
<nav id="navbar">
<a href="#" class="active">Home</a>
<a href="#">News</a>
<a href="#">Contact</a>
</nav>
<section class="content">
<h3>Sticky Test</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Architecto ipsam ad dolore eius consectetur odit sunt odio omnis soluta ipsum sed beatae? Aliquid temporibus minima quam beatae asperiores aspernatur ad.</p>
<p>Sequi cumque veniam maiores repellat incidunt sed assumenda iure nihil inventore tempora quia ipsam delectus quisquam voluptatum esse officiis sunt magni error corporis enim. Omnis veritatis exercitationem mollitia distinctio perferendis?</p>
<p>Dolorem quis libero impedit numquam quibusdam delectus architecto minus consectetur deleniti tempora. Error consectetur ipsam aut debitis ducimus reprehenderit quasi soluta explicabo. Adipisci et esse aliquam voluptatibus sint quaerat doloribus.</p>
<p>Veniam libero deserunt dignissimos sunt porro maiores eligendi aperiam sint nihil magnam id ut incidunt. Quaerat ab temporibus corrupti perferendis quam sit. Maxime placeat excepturi odit illum atque dignissimos sapiente.</p>
<p>Laudantium cupiditate provident quas error quis eos repellat ducimus quia accusamus tenetur quaerat nesciunt voluptas eaque enim aliquid quisquam ipsum. Dolorem vitae ab ipsam hic nisi animi ut ullam voluptas.</p>
<p>Quam cupiditate perspiciatis incidunt voluptates placeat at deleniti est debitis necessitatibus molestias consectetur sed rerum distinctio quos commodi ratione aut atque qui eos animi corrupti maiores mollitia fugiat voluptatum minima?</p>
<p>Odio ea provident quia amet sunt iste tempore dignissimos quidem exercitationem debitis magnam soluta ex ab assumenda iusto maxime beatae possimus iure natus a nemo voluptatibus illo eveniet pariatur enim.</p>
<p>Quia ipsam ea iste rem commodi perspiciatis culpa velit adipisci deserunt placeat vitae suscipit modi obcaecati doloremque iusto accusantium animi? Sit blanditiis minus porro fugit cumque laboriosam error numquam et!</p>
<p>Dignissimos modi veritatis aliquam molestiae est sint provident placeat ab fugiat animi ullam ut dicta dolor aperiam reiciendis reprehenderit impedit quasi tempore in eos vitae unde libero amet esse saepe.</p>
<p>Voluptatum perferendis molestias sapiente dolorum assumenda. Nam ut totam eos doloribus rerum fuga voluptatem eligendi incidunt enim excepturi officiis sed exercitationem voluptas porro veritatis asperiores tempora officia! Earum ea tempora.</p>
<p>Vitae cum culpa ea officiis dignissimos animi totam reprehenderit ipsum nemo. Distinctio exercitationem at nisi sapiente neque quae culpa porro voluptatibus mollitia quod nostrum quasi fugiat velit! Nemo laudantium praesentium!</p>
<p>Alias in amet sapiente soluta iste dolorem omnis cum commodi veritatis error ratione ullam. Commodi quos eos nostrum consequatur laboriosam accusantium enim tempora velit fugiat nemo praesentium atque possimus doloribus.</p>
<p>Dignissimos sint unde fuga porro ab cumque molestiae quasi maxime explicabo adipisci perspiciatis quae consequatur itaque harum dolore quibusdam deleniti atque hic neque nesciunt id ut assumenda illo consequuntur optio.</p>
<p>Dolorem rem blanditiis ad voluptates nam rerum fuga deleniti modi impedit quaerat eius eaque hic repellendus saepe harum voluptas unde soluta ratione dolor totam consequuntur eveniet obcaecati explicabo error minima.</p>
<p>Quam natus quo impedit voluptas necessitatibus vero distinctio consequuntur voluptates earum culpa quis tempora repellendus harum veritatis optio aliquid tempore nostrum iure tenetur deserunt magni quod animi minima et dolorem!</p>
</section>
position:absolute ์ค๋ช (์ค์)
<style>
.out{
width: 400px;
height: 200px;
border:3px solid #73ad21;
/* ***** */
position: relative;
}
.in{
width: 200px;
height: 100px;
border:3px solid #73ad21;
/* ๊ฐ์ฅ ๊ฐ๊น์ด ๋ถ๋ชจ์์ : .out, body */
/* div.out position:static X */
position: absolute;
right: 50px;
bottom: 30px;
}
</style>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Placeat possimus quos qui tempora modi explicabo perspiciatis
excepturi sit perferendis repellat tempore inventore. Consequatur
sapiente qui consequuntur voluptatem ipsa atque nisi!</p>
<!-- .out>lorem7+.in>{in} -->
<div class="out">
Lorem ipsum dolor sit amet, consectetur adipisicing.
<div class="in">in</div>
</div>
- ๊ฐ์ฅ ๊ฐ๊น์ด ๋ถ๋ชจ
- ๋ถ๋ชจ์ position์ด static์ ๋ถ๋ชจ๊ฐ ๋ ์ ์์
<style>
div{
width: 80%;
height:100px;
border:1px solid gray;
text-align: center;
margin: 0 auto;
}
</style>
<style>
.prev, .next{
width:50px;
height:50px;
border: 1px solid red;
border-radius: 25px;
position: absolute;
}
.prev{
left: -25px;
top:25px;
}
.next{
right:-25px;
top:25px;
}
</style>
<div></div>
<div></div>
<div style="position: relative;">
<div class="prev"><</div>
<div class="next">></div>
</div>
<div></div>
<div></div>
<div style="position: relative;">
<div class="prev"><</div>
<div class="next">></div>
</div>
<hr>
<div style="position: relative;">
<div class="prev"><</div>
<div class="next">></div>
</div>
<style>
div{
width: 80%;
height:100px;
border:1px solid gray;
text-align: center;
margin: 0 auto;
}
</style>
<style>
.prev, .next{
width:50px;
height:50px;
border: 1px solid red;
border-radius: 25px;
position: absolute;
}
.prev{
left: -25px;
top:25px;
}
.next{
right:-25px;
top:25px;
}
</style>
<div style="position: relative;">
<div class="prev"><</div>
<div class="next">></div>
</div>
<div></div>
<div></div>
<div style="position: relative;">
<div class="prev"><</div>
<div class="next">></div>
</div>
<hr>
<div style="position: relative;">
<div class="prev"><</div>
<div class="next">></div>
</div>
z-index ์์ฑ
<style>
.container{
position: relative;
border:1px solid black;
}
.red-box{
background-color: red;
height: 100px;
margin: 30px;
position: relative;
z-index: 100;
}
.green-box{
background-color: green;
width: 70%;
height:60px;
position: absolute;
left:50px;
top:50px;
z-index: 10;
}
.blue-box{
background-color: blue;
width:35%;
height: 100px;
position: absolute;
left:270px;
top:-15px;
z-index: -1;
}
</style>
<div class="container">
<div class="red-box">red-box</div>
<div class="green-box">green-box</div>
<div class="blue-box">blue-box</div>
</div>
<style>
#mySidenav a{
background-color: #111;
color:white;
padding: 13px;
text-decoration: none;
font-size: 20px;
border-radius: 0 5px 5px 0;
position: absolute; /* ๋ถ๋ชจ์์ body */
width:100px;
left:-84px;
text-align: center;
/* ์ ํ : ๋ค๋ฅธ ์ํ,์กฐ๊ฑด์ผ๋ก ๋ณ๊ฒฝ(์ดํ)*/
/* left๊ฐ์ด -84 -> 0 ์ ํ */
transition:0.5s ease;
}
#mySidenav a:hover{
left:0;
}
#home{ top:20px; }
#services{ top:80px; }
#clients{ top:140px;}
#contact{ top:200px;}
#content{
margin-left:120px;
}
</style>
<div id="mySidenav" class="sidenav">
<a href="#" id="home">Home <i class="fa fa-fw fa-home"></i></a>
<a href="#" id="services">Service<i class="fa fa-fw fa-wrench"></i></a>
<a href="#" id="clients">Clients<i class="fa fa-fw fa-user"></i></a>
<a href="#" id="contact">Contact<i class="fa fa-fw fa-envelope"></i></a>
</div>
<div id="content">
<h2>Lorem ipsum dolor sit amet.</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Magnam beatae!</p>
</div>
์ต๊ทผ๋๊ธ