Xem Demo.
Sau đây là hướng dẫn cài đặt hiệu ứng:
Bước 1: Trước tiên, bạn hãy đặt toàn bộ phần code bên dưới vào phần đầu của trang HTML, nằm giữa 2 thẻ <head>, </head>.
<script type="text/javascript" src="http://www.ryanscherf.net/demos/accordion/mootools.js"></script>
<style type="text/css">
#content {
width: 220px;
margin: 0 auto;
}
#wrap {
width: 232px;
overflow: hidden;
background: #fff url("http://www.ryanscherf.net/demos/accordion/images/wrapbg.gif") repeat-y top left;
}
h3 {
padding: 10px 0 11px 15px;
margin: 0;
font-size: 12px;
font-weight: normal;
color: #222;
background: #efefef;
cursor: pointer;
border-bottom: 1px solid #fff;
text-decoration: none;
}
h3.toggler a {
color: #666;
text-decoration: none;
}
h3.toggler a:hover {
color: black;
}
div.accordion {
background: #fff url("http://www.ryanscherf.net/demos/accordion/images/accordionbg.gif") repeat-x top left;
}
div.accordion ul {
list-style-type: none;
padding: 0;
margin: 0 0 5px 0;
}
div.accordion ul li {
padding: 6px 0;
}
div.accordion ul li a {
color: #666;
text-decoration: none;
display: block;
padding: 4px 0px 4px 20px;
font-size: 90%;
}
div.accordion ul li a span {
padding-bottom: 10px;
}
div.accordion ul li a img {
border: 0;
vertical-align: bottom;
margin-right: 15px;
}
div.accordion ul li a:hover span {
text-decoration: underline;
}
#top_round {
height: 10px;
font-size: 1px; /* ie whitespace */
}
#bottom_round {
height: 10px;
font-size: 1px; /* ie whitespace */
}
.top_dark {
background: url("http://www.ryanscherf.net/demos/accordion/images/top_dark.gif") no-repeat top left;
}
.top_light {
background: url("http://www.ryanscherf.net/demos/accordion/images/top_light.gif") no-repeat top left;
}
.bottom_dark {
background: url("http://www.ryanscherf.net/demos/accordion/images/bottom_dark.gif") no-repeat top left;
}
.bottom_light {
background: url("http://www.ryanscherf.net/demos/accordion/images/bottom_light.gif") no-repeat top left;
}
.first {
padding-top: 5px;
}
.last {
padding-bottom: 5px;
}
</style>
<style type="text/css">
#content {
width: 220px;
margin: 0 auto;
}
#wrap {
width: 232px;
overflow: hidden;
background: #fff url("http://www.ryanscherf.net/demos/accordion/images/wrapbg.gif") repeat-y top left;
}
h3 {
padding: 10px 0 11px 15px;
margin: 0;
font-size: 12px;
font-weight: normal;
color: #222;
background: #efefef;
cursor: pointer;
border-bottom: 1px solid #fff;
text-decoration: none;
}
h3.toggler a {
color: #666;
text-decoration: none;
}
h3.toggler a:hover {
color: black;
}
div.accordion {
background: #fff url("http://www.ryanscherf.net/demos/accordion/images/accordionbg.gif") repeat-x top left;
}
div.accordion ul {
list-style-type: none;
padding: 0;
margin: 0 0 5px 0;
}
div.accordion ul li {
padding: 6px 0;
}
div.accordion ul li a {
color: #666;
text-decoration: none;
display: block;
padding: 4px 0px 4px 20px;
font-size: 90%;
}
div.accordion ul li a span {
padding-bottom: 10px;
}
div.accordion ul li a img {
border: 0;
vertical-align: bottom;
margin-right: 15px;
}
div.accordion ul li a:hover span {
text-decoration: underline;
}
#top_round {
height: 10px;
font-size: 1px; /* ie whitespace */
}
#bottom_round {
height: 10px;
font-size: 1px; /* ie whitespace */
}
.top_dark {
background: url("http://www.ryanscherf.net/demos/accordion/images/top_dark.gif") no-repeat top left;
}
.top_light {
background: url("http://www.ryanscherf.net/demos/accordion/images/top_light.gif") no-repeat top left;
}
.bottom_dark {
background: url("http://www.ryanscherf.net/demos/accordion/images/bottom_dark.gif") no-repeat top left;
}
.bottom_light {
background: url("http://www.ryanscherf.net/demos/accordion/images/bottom_light.gif") no-repeat top left;
}
.first {
padding-top: 5px;
}
.last {
padding-bottom: 5px;
}
</style>
Bước 2: Thiết lập HTML như bên dưới để đặt vào phần thân của trang HTML, nằm giữa 2 thẻ <body>, </body>.
<div id="wrap">
<div id="top_round"></div>
<div id="content">
<h3 class="toggler first" style="padding-top:5px;"><a href="#section1" onfocus="this.blur();">Section Title 1</a></h3>
<div class="accordion">
<ul>
<li><a href="#" onfocus="this.blur();"><img src="/images/image1.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image2.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image3.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image4.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image5.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image6.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image7.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image8.png" alt="" /><span>Link to other content area</span></a></li>
</ul>
</div>
<h3 class="toggler"><a href="#section2" onfocus="this.blur();">Section Title 2</a></h3>
<div class="accordion">
<ul>
<li><a href="#" onfocus="this.blur();"><img src="/images/image9.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image10.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image11.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image12.png" alt="" /><span>Link to other content area</span></a></li>
</ul>
</div>
<h3 class="toggler"><a href="#section3" onfocus="this.blur();">Section Title 3</a></h3>
<div class="accordion">
<ul>
<li><a href="#" onfocus="this.blur();"><img src="/images/image13.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image14.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image15.png" alt="" /><span>Link to other content area</span></a></li>
</ul>
</div>
<h3 class="toggler"><a href="#section4" onfocus="this.blur();">Section Title 4</a></h3>
<div class="accordion">
<ul>
<li><a href="#" onfocus="this.blur();"><img src="/images/image16.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image17.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image18.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image19.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image20.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src=" /images/image21.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image22.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image23.png" alt="" /><span>Link to other content area</span></a></li>
</ul>
</div>
<h3 class="toggler last"><a href="#section5" onfocus="this.blur();">Section Title 5</a></h3>
<div class="accordion"><!-- no content hack --></div>
</div>
<div id="bottom_round"></div>
</div>
</div>
<div id="top_round"></div>
<div id="content">
<h3 class="toggler first" style="padding-top:5px;"><a href="#section1" onfocus="this.blur();">Section Title 1</a></h3>
<div class="accordion">
<ul>
<li><a href="#" onfocus="this.blur();"><img src="/images/image1.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image2.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image3.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image4.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image5.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image6.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image7.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image8.png" alt="" /><span>Link to other content area</span></a></li>
</ul>
</div>
<h3 class="toggler"><a href="#section2" onfocus="this.blur();">Section Title 2</a></h3>
<div class="accordion">
<ul>
<li><a href="#" onfocus="this.blur();"><img src="/images/image9.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image10.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image11.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image12.png" alt="" /><span>Link to other content area</span></a></li>
</ul>
</div>
<h3 class="toggler"><a href="#section3" onfocus="this.blur();">Section Title 3</a></h3>
<div class="accordion">
<ul>
<li><a href="#" onfocus="this.blur();"><img src="/images/image13.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image14.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image15.png" alt="" /><span>Link to other content area</span></a></li>
</ul>
</div>
<h3 class="toggler"><a href="#section4" onfocus="this.blur();">Section Title 4</a></h3>
<div class="accordion">
<ul>
<li><a href="#" onfocus="this.blur();"><img src="/images/image16.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image17.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image18.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image19.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image20.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src=" /images/image21.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image22.png" alt="" /><span>Link to other content area</span></a></li>
<li><a href="#" onfocus="this.blur();"><img src="/images/image23.png" alt="" /><span>Link to other content area</span></a></li>
</ul>
</div>
<h3 class="toggler last"><a href="#section5" onfocus="this.blur();">Section Title 5</a></h3>
<div class="accordion"><!-- no content hack --></div>
</div>
<div id="bottom_round"></div>
</div>
</div>
Bước 3: Đặt đoạn code sau đây trước thẻ đóng </body>.
<script type="text/javascript" src="http://www.ryanscherf.net/demos/accordion/accordion.js"></script>
Chú ý ở Bước 2, bạn phải tùy chỉnh scr theo URL các file hình ảnh tương ứng của bạn.
Hiệu ứng này có thể áp dụng cho Blogger khá dễ dàng.
Theo Ryanscherf.net
{ 0 comments... read them below or add one }
Post a Comment