<div id="wrap">
<div class="contArea">
<div class="tgArea fadeType01">
<button type="button" class="btnFadeInout">
<span>클릭!</span>
</button>
<div class="tgCont">
<span>숨겨진 내용이 페이드 인아웃됩니다.</span>
</div>
</div>
</div>
<div class="contArea">
<div class="tgArea fadeType02">
<button type="button" class="btnFadeInout">
<span>클릭!</span>
</button>
<div class="tgCont">
<span>숨겨진 내용이 페이드 인아웃됩니다.</span>
</div>
</div>
</div>
</div>
.tgArea{
&.fadeType01,&.fadeType02{
.btnFadeInout{min-width: 100px; height: 40px; font-family: $d-fz; font-size: 0.88em;
background-color: rgba($color: $dddBg, $alpha: 0.5);}
}
&.fadeType01{
.tgCont{opacity: 0; visibility: hidden; transition: .5s;}
.btnFadeInout.active ~.tgCont{opacity: 1; visibility: visible;}
}
&.fadeType02{
.tgCont{display: none;}
}
}
.tgArea.fadeType01 .btnFadeInout, .tgArea.fadeType02 .btnFadeInout {
min-width: 100px;
height: 40px;
font-family: "Noto Sans";
font-size: 0.88em;
background-color: rgba(221, 221, 221, 0.5);
}
.tgArea.fadeType01 .tgCont {
opacity: 0;
visibility: hidden;
-webkit-transition: .5s;
transition: .5s;
}
.tgArea.fadeType01 .btnFadeInout.active ~ .tgCont {
opacity: 1;
visibility: visible;
}
.tgArea.fadeType02 .tgCont {
display: none;
}
$(function(){
$('.tgArea.fadeType01 .btnFadeInout').on({
"click": function () {
$(this).toggleClass('active').siblings('.btnFadeInout').removeClass('active');
}
});
$('.tgArea.fadeType02 .btnFadeInout').on({
"click": function () {
$(this).siblings('.tgCont').fadeToggle();
}
});
});
아래 주소를 복사하여 다른 곳에 붙여넣으세요.
모바일 환경에서는 코드 결과가 gif로 표시됩니다.
그래도 결과를 볼까요?
(제대로 된 결과를 보려면 노트북 또는 데스크탑에서 실행해주세요.)