CSS3 accordion effect- Here the <a href="#five">my machine</a> link can be placed anywhere in the place, not to mention that it must be placed behind this ID. The front of this anchor is also OK.
Do not use UL, LI this way, just do it, just make sure that the address of this click is for an ID.
HTML CODE:
<section class="demo">
<ul class="menu">
<li id="one">
<a href="#one">My friends</a>
<ul>
<li><a href="#">Cute Kittens </a></li>
<li><a href="#">Strange “Stuff” </a></li>
<li><a href="#">Automatic Fails </a></li>
<li><a href="#">Cute Kittens </a></li>
<li><a href="#">Strange “Stuff” </a></li>
<li><a href="#">Automatic Fails </a></li>
</ul>
</li>
<li id="two">
<a href="#two">My Neighbors</a>
<ul>
<li><a href="#">Cute Kittens </a></li>
<li><a href="#">Strange “Stuff” </a></li>
<li><a href="#">Automatic Fails </a></li>
<li><a href="#">Strange “Stuff” </a></li>
<li><a href="#">Cute Kittens </a></li>
<li><a href="#">Strange “Stuff” </a></li>
</ul>
</li>
<li id="three">
<a href="#three">My Apps</a>
<ul>
<li><a href="#">Automatic Fails</a></li>
</ul>
</li>
<li id="five">
<a href="#five">My Machine</a>
<ul>
<li><a href="#">Cute Kittens</a></li>
<li><a href="#">Strange “Stuff”</a></li>
<li><a href="#">Automatic Fails </a></li>
</ul>
</li>
</ul>
</section>
CSS CODE:
<style type="text/css">
.demo {
width: 200px;
min-height: 400px;
margin: 40px auto 0;
}
.menu > li {
line-height: 50px;
border-bottom: 1px solid #3d3d3d;
box-shadow: 0 1px 0 #888;
list-style: none;
}
.menu > li:first-child {
border-top: 1px solid #3d3d3d;
box-shadow: 0 1px 0 #888,0 1px 0 #888 inset;
}
.menu a {
position: relative;
outline: 0;
display: block;
text-align: left;
color: #444;
font-size: 18px;
text-shadow: 0 1px 1px #eee;
padding: 0 40px;
}
.menu a:hover {
text-decoration: none;
}
.menu > li > a:before, .menu > li > a:after {
font-size: 26px;
}
.menu > li > a:before {
position: absolute;
left: 10px;
color: #ddd;
text-shadow: inherit -1px 0 #fff,0 -2px 0 #1a1a1a,0 1px 2px #1a1a1a;
}
.menu > li > a:after {
position: absolute;
right: 10px;
color: #ddd;
}
.menu > li:nth-child(1) > a:before {
content: "1";
}
.menu > li:nth-child(2) > a:before {
content: "2";
}
.menu > li:nth-child(3) > a:before {
content: "3";
}
.menu > li:nth-child(4) > a:before {
content: "4";
}
.menu > li > a:after {
content: "+";
}
.menu ul {
line-height: 30px;
display: none;
overflow: hidden;
-webkit-transition: all .5s linear;
-moz-transition: all .5s linear;
transition: all .5s linear;
}
.menu ul a {
color: #000;
text-shadow: 0 1px 1px #848484;
font-size: 12px;
}
.menu ul a:hover {
color: #ccc;
text-shadow: 0 1px 0 #252525;
}
.menu li:target > a:after {
content: "-";
}
.menu li:target ul {
display: block;
border-top: 1px solid #3d3d3d;
box-shadow: 0 1px 0 #888 inset;
}
#top_nav {
background: rgba(0,0,0,0.6);
min-height: 32px;
}
#top_nav ul {
left: 50%;
position: relative;
float: left;
}
#top_nav li {
right: 50%;
position: relative;
float: left;
padding: 0 10px;
}
#top_nav li a {
color: #fff;
line-height: 30px;
font-size: 15px;
}
#top_nav:after {
clear: both;
}
input {
display: none;
}
label {
display: block;
line-height: 40px;
border-bottom: 1px solid #ddd;
cursor: pointer;
font-size: 15px;
font-weight: bold;
}
.list > ul {
display: none;
-webkit-transition: all .5s linear;
-moz-transition: all .5s linear;
-ms-transition: all .5s linear;
-o-transition: all .5s linear;
transition: all .5s linear;
}
#list1:checked + ul {
display: block;
}
#list2:checked + ul {
display: block;
}
#list3:checked + ul {
display: block;
}
#list4:checked + ul {
display: block;
}
h1 {
color: red;
}
p {
font-size: 20px;
}
a {
text-decoration: none;
}
* {
margin: 0;
padding: 0;
}
</style>
Post your comments / questions
Recent Article
- How to create custom 404 error page in Django?
- Requested setting INSTALLED_APPS, but settings are not configured. You must either define..
- ValueError:All arrays must be of the same length - Python
- Check hostname requires server hostname - SOLVED
- How to restrict access to the page Access only for logged user in Django
- Migration admin.0001_initial is applied before its dependency admin.0001_initial on database default
- Add or change a related_name argument to the definition for 'auth.User.groups' or 'DriverUser.groups'. -Django ERROR
- Addition of two numbers in django python
Related Article