i am new to HTML and i need to put some sub menus in my side bar.. just like a dropdown but it opens on the right side. and how can i put links on it. thanks
html
<ul>
<li></br>
<a class="active" href="?">HOME</a>
</li>
<li></br>
<a href="?">Manage Users</a> ----> needs the dropdown here
</li>
<li></br>
<a href="?">Manage Employees</a>----> needs the dropdown here
</li>
<li></br>
<a href="?">Search</a>
</li>
<li></br>
<a href="<?php echo site_url('login/logout') ?>">Log-Out</a>
</li>
</ul>
here is my css.
body {
margin: 0;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
width: 15%;
background-color: #f1f1f1;
position: fixed;
height: 100%;
overflow: auto;
}
li a {
display: block;
color: #000;
padding: 8px 0 8px 16px;
text-decoration: none;
}
li a.active {
background-color: #4CAF50;
color: white;
}
li a:hover:not(.active) {
background-color: #555;
color: white;
}
...................................................................
<ul>
<li></br>
<a class="active" href="?">HOME</a>
</li>
<li></br>
<a href="?">Manage Users</a> ----> needs the dropdown here
</li>
<li></br>
<a href="?">Manage Employees</a>---->
<ul>
<li><a href="#"> You put the sublists here</a></li>
<li> Many has you need</li>
</ul>
</li>
<li></br>
<a href="?">Search</a>
</li>
<li></br>
<a href="<?php echo site_url('login/logout') ?>">Log-Out</a>
</li>
You don't need the </br> (correct would be <br/>, or <br>for HTML5). I tried to make a simple solution with jQuery. where you simply display or not the content you want.
Hope it is what you were looking for.
body { margin: 0; } ul { list-style-type: none; margin: 0; padding: 0; /*width: 15%;*/ background-color: #f1f1f1; /*position: fixed;*/ height: 100%; overflow: auto; } li a { display: block; color: #000; padding: 8px 0 8px 16px; text-decoration: none; } li a.active { background-color: #4CAF50; color: white; } li a:hover:not(.active) { background-color: #555; color: white; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <ul> <li> <a class="active" href="#">HOME</a> </li> <li> <a href="#" onclick="$('ul#contentUsers').toggle();">Manage Users</a> <ul id="contentUsers" style="display: none;"> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> <li><a href="#">Link 3</a></li> </ul> </li> <li> <a href="#" onclick="$('ul#contentEmployees').toggle();">Manage Employees</a> <ul id="contentEmployees" style="display: none;"> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> <li><a href="#">Link 3</a></li> </ul> </li> <li> <a href="#">Search</a> </li> <li> <a href="#">Log-Out</a> </li> </ul>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.