방법 - 그리드 확장
CSS와 JavaScript로 확장 그리드를 만드는 방법을 알아보세요.
그리드 확장
상자를 클릭하여 "확장"합니다(100% 너비).
×
상자 1
고통 자체를 확인하고, 배운 지식이 당신에게서 줄어들게 하고, 그것이 당신을 진정시킨다는 것을 이해합시다. 올바른 오류는 버려진 광고를 의미합니다.
×
상자 2
고통 자체를 확인하고, 배운 지식이 당신에게서 줄어들게 하고, 그것이 당신을 진정시킨다는 것을 이해합시다. 올바른 오류는 버려진 광고를 의미합니다.
×
상자 3
고통 자체를 확인하고, 배운 지식이 당신에게서 줄어들게 하고, 그것이 당신을 진정시킨다는 것을 이해합시다. 올바른 오류는 버려진 광고를 의미합니다.
확장 그리드 만들기
1단계) HTML 추가:
예시
<!-- The grid: three columns -->
<div class="row">
<div class="column" onclick="openTab('b1');" style="background:green;">Box
1</div>
<div class="column" onclick="openTab('b2');" style="background:blue;">Box
2</div>
<div class="column" onclick="openTab('b3');" style="background:red;">Box
3</div>
</div>
<!-- The expanding grid (hidden by default) -->
<div id="b1" class="containerTab" style="display:none;background:green">
<!-- If you want the ability to close the container, add a close button -->
<span onclick="this.parentElement.style.display='none'" class="closebtn">x</span>
<h2>Box 1</h2>
<p>Lorem ipsum..</p>
</div>
<div id="b2" class="containerTab" style="display:none;background:blue">
<span onclick="this.parentElement.style.display='none'" class="closebtn">x</span>
<h2>Box 2</h2>
<p>Lorem ipsum..</p>
</div>
<div id="b3" class="containerTab" style="display:none;background:red">
<span onclick="this.parentElement.style.display='none'" class="closebtn">x</span>
<h2>Box 3</h2>
<p>Lorem ipsum..</p>
</div>
2단계) CSS 추가:
세 개의 열을 만듭니다.
예시
/* The grid: Three equal columns that floats next to each other */
.column
{
float: left;
width: 33.33%;
padding: 50px;
text-align: center;
font-size: 25px;
cursor: pointer;
color: white;
}
.containerTab
{
padding: 20px;
color: white;
}
/* Clear floats after the
columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Closable button inside the image */
.closebtn {
float: right;
color: white;
font-size: 35px;
cursor: pointer;
}
3단계) 자바스크립트 추가:
예시
// Hide all elements with class="containerTab",
except for the one that matches the clickable grid column
function openTab(tabName) {
var i, x;
x = document.getElementsByClassName("containerTab");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
document.getElementById(tabName).style.display = "block";
}