Wednesday, December 4, 2019

Accodian with images

<!DOCTYPE html>
<html>
<head>
<style type="text/css">
html,body{
padding: 0;
margin: 0;
width: 100%
height:100%;
background-color: #f5f5f5;
}
ol,ul{
margin: 0;
padding: 0;
list-style: none;

}
a{
text-decoration: none;
}
#wrapper{
width: 100%;
max-width: 960px;
border: 1px solid #ccc;
margin: 0 auto;
background-color: #fff;
padding: 20px;
box-sizing:border-box;
}
ul#accodion{max-width: 500px;margin: 0 auto;}
ul#accodion>li>a{
display: block;
padding: 15px;
color: #333;
background-color: #446CB3;
border: 1px solid #fff;;
font-family:arial;
color: #fff;
border-radius: 5px;

}
ul#accodion a.active,
ul#accodion a.hover{
background-color: #3560A0:
}
ul#accodion p{
background: #f5f5f5;
font-style: italic;
padding: 10px;
margin: 10px auto;
display: none;
}
ul#accodion > li {
position: relative;
}
 ul#accodion > li::after {
 position: absolute;
 content: "";
 display: block;
 width: 15px;
 height: 15px;
 background-image: url(plus.png);
 right: 20px;
 top: 20px;
 background-size: 100% auto;
 pointer-events: none;
}
 ul#accodion > li.active::after {
background-image: url(minus.png);
}


</style>
</head>
<body>
  <ul id="accodion">
<li><a class="addition" href="#" onclick="return false;">what are you doing 1</a>

<p>Many users already have downloaded jQuery from Google or Microsoft when visiting another site. As a result, it will be loaded from cache when they visit your site, which leads to faster loading time. Also, most CDN's will make sure that once a user requests a file from it, it will be served from the server closest to them, which also leads to faster loading time.</p>
</li>
<li><a class="addition" href="#" onclick="return false;">what are you doing 2</a>
<p>Many users already have downloaded jQuery from Google or Microsoft when visiting another site. As a result, it will be loaded from cache when they visit your site, which leads to faster loading time. Also, most CDN's will make sure that once a user requests a file from it, it will be served from the server closest to them, which also leads to faster loading time.</p>
</li>
<li><a class="addition" href="#" onclick="return false;">what are you doing 3</a>
<p>Many users already have downloaded jQuery from Google or Microsoft when visiting another site. As a result, it will be loaded from cache when they visit your site, which leads to faster loading time. Also, most CDN's will make sure that once a user requests a file from it, it will be served from the server closest to them, which also leads to faster loading time.</p>
</li>
<li><a class="addition" href="#" onclick="return false;">what are you doing 4</a>
<p>Many users already have downloaded jQuery from Google or Microsoft when visiting another site. As a result, it will be loaded from cache when they visit your site, which leads to faster loading time. Also, most CDN's will make sure that once a user requests a file from it, it will be served from the server closest to them, which also leads to faster loading time.</p>
</li>
<li><a class="addition" href="#" onclick="return false;">what are you doing 5</a>
<p>Many users already have downloaded jQuery from Google or Microsoft when visiting another site. As a result, it will be loaded from cache when they visit your site, which leads to faster loading time. Also, most CDN's will make sure that once a user requests a file from it, it will be served from the server closest to them, which also leads to faster loading time.</p>
</li>
</ul>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>jQuery(document).on('click','#accodion>li>a',function(){
  jQuery(this).siblings('p').stop().slideToggle();
  jQuery(this).closest('li').siblings('li').find('p').stop().slideUp();
  jQuery(this).parent('li').toggleClass("active");
  jQuery(this).parent('li').prevAll('li').removeClass("active");
  jQuery(this).parent('li').nextAll('li').removeClass("active");
});</script>
</body>
</html>

No comments:

Post a Comment

If you have any problem please let me know.