I am facing the CSS problem in the dropdown menu selection box. My position in the dropdown box view position is not good. My client is not satisfied look like this view dropdown box. Hope someone can guide me how to solve it. Thanks.
Below is my coding:
<style>
.dropdown-content {
display: none;
position: absolute;
min-width: 70px;
z-index: 9;
}
.dropdown-content a {
display: block;
background: #f1f1f1;
text-decoration: none;
color: black;
}
.dropdown {
display: inline-block; /* Change display from block to inline-block */
}
.dropdown-content a:hover {
background-color: #ddd;
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown:hover #dropbtn {
background-color: #3e8e41;
}
</style>
<div class="topnav">
<span id="curTime" class='hide'> </span>
<div class="dropdown">
<a id="dropbtn" style="margin-right:20px;" href="#" onclick="setting()" data-toggle="tooltip" data-original-title="Setting" data-placement="bottom" class="btn btn-metis-1 btn-sm">
<i class="fa fa-wrench"></i>
</a>
<div class="dropdown-content">
Tetapan Umum
Pengurusan Pengguna
</div>
</div>
<!-- Edit 1: Move logout button out of dropdown menu -->
<a href="#" onclick="logout()" data-toggle="tooltip" data-original-title="Logout" data-placement="bottom" class="btn btn-metis-1 btn-sm">
<i class="fa fa-power-off"></i>
</a>
</div>
My output show me like the below picture:
I expected the result is like below the picture:
i've added some padding to the anchor's inside the dropdown-content div and on the div itself i've added width: fit-content to make sure it will not cutoff the text inside.
<style>
.dropdown-content {
display: block;
position: absolute;
min-width: 70px;
z-index: 9;
width: fit-content;
}
.dropdown-content a {
display: block;
background: #f1f1f1;
text-decoration: none;
color: black;
padding-left: 5px;
padding-right: 5px;
}
.dropdown {
display: inline-block; /* Change display from block to inline-block */
}
.dropdown-content a:hover {
background-color: #ddd;
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown:hover #dropbtn {
background-color: #3e8e41;
}
</style>
<div class="topnav">
<span id="curTime" class='hide'> </span>
<div class="dropdown">
<a id="dropbtn" style="margin-right:20px;" href="#" onclick="setting()" data-toggle="tooltip" data-original-title="Setting" data-placement="bottom" class="btn btn-metis-1 btn-sm">
<i class="fa fa-wrench"></i>
</a>
<div class="dropdown-content">
Tetapan Umum
Pengurusan Pengguna
</div>
</div>
<!-- Edit 1: Move logout button out of dropdown menu -->
<a href="#" onclick="logout()" data-toggle="tooltip" data-original-title="Logout" data-placement="bottom" class="btn btn-metis-1 btn-sm">
<i class="fa fa-power-off"></i>
</a>
</div>
Related
.sidebar-left .dropdown {
position: static;
}
.sidebar-left .dropdown .dropdown-menu {
position: absolute;
z-index: 10;
display: none;
}
.sidebar-left .dropdown:hover .dropdown-menu{
position: absolute;
display: block;
left: 63px;
transform: translateY(-50px);
}
.sidebar-left .dropdown:hover > .dropdown-menu{
display: block;
}
.sidebar-left.open .dropdown:hover .dropdown-menu{
position: absolute;
display: block;
left: 273px;
}
.sidebar-left.open li[aria-expanded="true"]:hover > .dropdown-menu{
display: none;
}
.sidebar-left.open .dropdown:hover > .dropdown-menu{
display: block;
}
.dropdown-menu{
position: absolute;
padding-top: 0;
padding-bottom: 0;
box-shadow: 2px 2px 2px 2px #222;
background-color: #4c5569;
border-radius: 1px;
}
.dropdown-menu li{
margin-top: 0;
margin-bottom: 0;
padding: 15px 25px;
min-width: 175px;
}
.dropdown-menu li a span {
font-size: .8rem;
line-height: 1rem;
color: #fff;
text-decoration: none;
}
.dropdown-menu li:hover {
background-color: rgba(255,255,255,.05);
}
<div class="sidebar-left" id="sidebar">
<div class="sidebar-header">
<div class="sidebar-title">Navigation</div>
<div class="sidebar-collapse" id="sidebar-collapse" data-bind="click: toggleOpen">
<i class="fa-solid fa-bars" ></i>
</div>
</div>
<div class="sidebar">
<div class="sidebar-content">
<nav class="sidebar_nav" role="navigation">
<ul id=sidebar-accordion class="sidebar_nav-main" data-bind="foreach: {data:items}">
<li class="sidebar-link dropdown" data-bind="css: {'active': $data.isActive() ? true : false}, attr: { 'data-target': '#collapse' + $index(), 'aria-expanded': false, 'data-toggle': 'collapse' } ">
<a href="javascript:void(0)" data-bind="attr: {'href': $data.parent_link}" class="sidebar_main-link">
<i data-bind="class: $data.icon"><i data-bind="class: $data.icon2"></i></i>
<span class="sidebar-item" data-bind="text: name"></span>
</a>
<ul class="dropdown-menu sidebar_submenu" data-bind="foreach: $data.children">
<li class="dropdown-item sidebar_submenu-item" data-bind="class: $data.className">
<span data-bind="text: name"></span>
</li>
</ul>
<div class="sidebar-subchild" id="sidebar-subchild" onclick="event.stopPropagation()">
<ul data-parent="#sidebar-accordion" class="collapse sidebar_submenu" data-bind="attr: { id: 'collapse' + $index()}, foreach: $data.children">
<li class="sidebar_submenu-item" data-bind="class: $data.isSelectModule">
<a target="_self" data-bind="attr: { 'href' : $data.link}"><span data-bind="text: $data.name"></span></a>
</li>
</ul>
</div>
</li>
</ul>
</nav>
</div>
</div>
</div>
Good Day, I am facing some problem in my hover dropdown submenu, if in the full size of browser, the submenu item of my last menu is only show two items but actually there have 5 items. How can I make the submenu showing upward to prevent the items be hidden? Also if I smaller the browser screen, the submenu also will be hidden from browser. I was using bottom: cal() before, but the position of submenu also will crashed. Is there any better solution?
When i click on the dropdown menu or hover over the dropdown list's elements.. the browser window shakes. The shaking effect disappears when i remove the .row and .column classes from the markup.. I am using bootstrap for most of the purpose (including dropdown menu and grid) in this project
here's the markup.
#import url('https://fonts.googleapis.com/css2?family=Lato:wght#300;400;700&display=swap');
#nav-left {
background-color: #44403b;
height: 92vh;
overflow: hidden;
#navigation {
padding: 10px;
width: 100%;
color: #acb2d4;
font-size: 18px;
letter-spacing: 0.5px;
background-color: #322e2b;
}
ul.menu {
padding: 0;
margin : 0;
list-style: none;
li {
&:hover {
background-color: #49423f;
}
a {
text-decoration: none;
display: block;
padding: 15px;
cursor: pointer;
font-size: 18px;
color: #acb2d4;
border-bottom: 1px solid #515151;
&.parent::after {
content: "\f107";
font: normal normal normal 14px/2 FontAwesome;
float: right;
margin-right: 8px;
}
//collapsed class is overriding the content of parent class, but when we click the collapsed class changes to
// collapse and then the content of parent is shown
&.collapsed::after {
content: "\f105";
}
}
}
}
& li ul#sub-menu1 {
margin:0;
padding: 0;
list-style: none;
& li {
line-height: 10px;
&:hover {
background-color: #48423f;
}
a {
transition: all 0.5s;
}
}
}
& li ul li a:hover {
transform:translateX(10px);
background-color: #322e2b;
width: 100%;
overflow: hidden;
}
}
<div class="row">
<div class="col-2">
<nav id="nav-left">
<div id="navigation"><i class="fa fa-bars"></i> Navigation</div>
<ul class="menu">
<li class="active">
<i class="fa fa-dashboard fw"></i> Dashboard
</li>
<li>
<a data-toggle="collapse"
href="#sub-menu1"
role="button"
aria-expanded="false"
aria-controls="sub-menu1"
class="parent collapsed">
<i class="fa fa-user fw"></i>
Users
</a>
<ul class="collapse" id="sub-menu1">
<li>
<i class="fa fa-users text-primary"></i> All Users
</li>
<li>
<i class="fa fa-plus text-secondary"></i> New Users
</li>
<li>
<i class="fa fa-dot-circle-o text-success"></i> Active Users
</li>
<li>
<i class="fa fa-dot-circle-o text-danger"></i> Inactive Users
</li>
<li>
<i class="fa fa-ban"></i> Blocked Users
</li>
</ul>
</li>
<li>
<i class="fa fa-calendar"></i> Events
</li>
</ul>
</nav>
</div>
<div class="col-10">
<div class="row">
<div class="col-4">
</div>
<div class="col-4"></div>
<div class="col-4"></div>
</div>
<div class="row">
<div class="col-4"></div>
<div class="col-4"></div>
<div class="col-4"></div>
</div>
<div class="row">
<div class="col-4"></div>
<div class="col-4"></div>
<div class="col-4"></div>
</div>
</div>
</div>
Could it be so simple that it is the browsers vertical scrollbar that appears? Is the drop down very high?
If so you can make the vertical browser scrollbar visible all the time by adding a css Rule
body {
overflow: scroll;
}
Adds both the vertical and horizontal scrollbar all the time
Use overflow-y only for vertical
Hi I am developing Nav bar using Html and CSS. In right side I want to have icon in drop-down list as shown below.
I am trying as below to get it done.
<div className="dropdown">
<button className="dropbtn">John Doe</button>
<div className="dropdown-content">
Settings & Configurations
Logout
<div>
</div>
Below are my css styles.
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 16px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
margin: 0;
}
.navbar a:hover,
.dropdown:hover .dropbtn {
display: block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.dropdown-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {
background-color: #ddd;
}
.dropdown:hover .dropdown-content {
display: block;
}
.navbar-brand {
display: inline-block;
padding-top: .3125rem;
padding-bottom: .3125rem;
margin-right: 1rem;
font-size: 1.25rem;
line-height: inherit;
white-space: nowrap;
}
.navbar-light .navbar-brand {
color: rgba(0, 0, 0, .9);
}
I am trying to add one notification bar and drop-down with icon which shows user icon. Can someone help me in this regard. Any help would be appreciated. Thanks
If you want to have an icon in the dropdown list you could try this example:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--Link for Font awesome icons-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!--Links for Bootstrap-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="dropdown mt-5">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
Dropdown button
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#"> <i class="fa fa-home"></i> Home </a>
<a class="dropdown-item" href="#"> <i class="fa fa-address-book"></i> Contact </a>
<a class="dropdown-item" href="#"> <i class="fa fa-bell"></i> Notifications </a>
<a class="dropdown-item" href="#"><i class="fa fa-cog"></i> Setting </a>
</div>
</div>
</div>
</body>
</html>
Just change the icon to your likings
Hello sir If you don't want to use bootstrap you could do the following. Imagine this is your dropdown list:
<div class="dropdown">
<button class="dropbtn">Dropdown</button>
<div class="dropdown-content">
<a class="dropdown-item" href="#"> Home </a>
<a class="dropdown-item" href="#">Contact </a>
<a class="dropdown-item" href="#"> Notifications </a>
<a class="dropdown-item" href="#"> Setting </a>
</div>
</div>
and the css
/* Dropdown Button */
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {background-color: #ddd;}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {display: block;}
/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn {background-color: #3e8e41;}
/* This align the icon to the right */
#icon{
align-items: right;
}
I copied this example from W3 schools so if you have your own drop down list you can also use that. Then to add the icons change the dropdown list as follows:
<div class="dropdown">
<button class="dropbtn">Dropdown</button>
<div class="dropdown-content">
<a class="dropdown-item" href="#"> <i class="fa fa-home"></i> Home </a>
<a class="dropdown-item" href="#"> <i class="fa fa-address-book"></i> Contact </a>
<a class="dropdown-item" href="#"> Notifications <i class="fa fa-bell"></i></a>
<a class="dropdown-item" href="#"> Setting <i class="fas fa-bars"></i></a>
</div>
depending on where you want your icons you could put them before the text (just as the first 2 items in the dropdown-list) aligning them to the left & you could place them after the text (just as the last 2 items in the dropdown-list) aligning them to the right.
But to make all this possible you need to put this link under the title attribute in the head element:
<script src='https://kit.fontawesome.com/a076d05399.js'></script>
There you go now your dropdown-list items will have icons with the text.To get more icons go to the following link:
https://www.w3schools.com/icons/icons_reference.asp
I made a test page using Bootstrap 4 beta. The navbar has a drop down menu. It works fine in full screen on my laptop but when I view it on my iphone, the drop down shows 7 of the 9 drop down links. Is this a bug in Bootstrap or how can I fix it? here is my html, I left out some of the things that don't relate. Here is a
/* Navbar */
#primary-navbar {
background: #CDEBED;
margin-bottom: 0;
}
/* we overwrite the default navbar style from Bootstrap */
nav.navbar {
background: #CDEBED;
font-size:18px;
border: 0;
border-radius: 0;
margin-bottom: 0;
min-height: 34px;
white-space: nowrap;
}
/* The toggle unit (there is more stuff in there..) */
.navbar-header .navbar-toggle {
border: 0;
}
.navbar-header .navbar-toggle span.icon-bar {
background: #004289;
}
.navbar-header .navbar-toggle:hover span.icon-bar {
background: #004289;
}
/* The Logo/Start Button on mobile devices */
a.navbar-brand:link,
a.navbar-brand:visited {
color: #004289;
text-decoration: none;
background-color: #fff;
border-radius: 50%; padding: .5rem;
}
a.navbar-brand:hover,
a.navbar-brand:focus {
color: #ff0000;
text-decoration: none;
}
/* First Level Main nav */
ul.nav {
/* Menu style */
}
ul.nav li.active {
background: #004289;
text-decoration: none;
}
ul.nav li.active a:link,
ul.nav li.active a:visited {
color: #004289;
text-decoration: none;
}
ul.nav li a:link,
ul.nav li a:visited {
color: #004289;
text-decoration: none;
}
ul.nav li a:hover,
ul.nav li a:focus {
color: #fff;
}
/* Our resposive dropdown */
ul.dropdown-menu {
border-radius: 0;
background: #CDEBED;
width: 100%;
margin: 0;
}
ul.dropdown-menu li a:link,
ul.dropdown-menu li a:visited {
color: #004289;
padding: 5px 15px;
text-decoration: none;
}
ul.dropdown-menu li a:hover,
ul.dropdown-menu li a:focus {
color: #fff;
text-decoration: none;
}
.dropdown-submenu {
position: relative;
}
.dropdown-submenu>.dropdown-menu {
top: 0;
left: 100%;
margin-top: -6px;
margin-left: -1px;
-webkit-border-radius: 0 6px 6px 6px;
-moz-border-radius: 0 6px 6px;
border-radius: 0 6px 6px 6px;
}
.dropdown-submenu:hover>.dropdown-menu {
display: block;
}
.dropdown-submenu>a:after {
display: block;
content: " ";
float: right;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
border-width: 5px 0 5px 5px;
border-left-color: #CDEBED;
margin-top: 5px;
margin-right: -10px;
}
.dropdown-submenu:hover>a:after {
border-left-color: #fff;
text-decoration: none;
}
.dropdown-submenu.pull-left {
float: none;
}
.dropdown-submenu.pull-left>.dropdown-menu {
left: -100%;
margin-left: 10px;
-webkit-border-radius: 6px 0 6px 6px;
-moz-border-radius: 6px 0 6px 6px;
border-radius: 6px 0 6px 6px;
}
.dropdown:hover .dropdown-menu {
display: block;
}
#media (min-width:769px) {
.dropdown:hover .dropdown-menu {
display: block;
}
}
/* Links */
a {
color: #036;
text-decoration: none;
}
a:hover,
a:focus {
color: #036;
text-decoration: none;
}
.navbar-right li { display: inline-block; }
a {
color: #036;
text-decoration: none;
&:hover {
color: #fff;
text-decoration: none;
}
}
#media (min-width: 992px) {
.equal{
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="John Samonas">
<meta name="robots" content="index, follow">
<title>DriftwoodRentals.com</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<link href="dist/css/custom-bs4.css" rel="stylesheet">
</head>
<body>
<nav class="navbar fixed-top navbar-custom justify-content-center navbar-expand-md">
The Driftwood
<button class="navbar-toggler drpbtn" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span style="color:#036">Menu</span> <i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mx-auto">
<li class="nav-item">
<a class="nav-link" href="index.html"><i class="fa fa-home" aria-hidden="true"></i>
Home <span class="sr-only">(current)</span></a></li>
<li><a class="nav-link" href="photos.html">Photos</a></li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Thing To Do</a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="http://ryebeachinfo.com/" target="_blank">Rye Beach</a>
<a class="dropdown-item" href="https://www.nhstateparks.org/visit/state-parks/jenness-state-beach.aspx" target="_blank">Jenness State Beach</a>
<a class="dropdown-item" href="http://www.nhstateparks.com/wallis.html" target="_blank">Wallis Sands Beach</a>
<a class="dropdown-item" href="http://www.newcastlenh.org/pages/newcastlenh_common/great" target="_blank">Great Island Commons</a>
<a class="dropdown-item" href="http://www.nhstateparks.org/visit/state-parks/odiorne-point-state-park.aspx" target="_blank">Odiorn State Park</a>
<a class="dropdown-item" href="http://www.nhstateparks.org/visit/state-parks/rye-harbor-state-park.aspx" target="_blank">Rye Harbor State Park</a>
<a class="dropdown-item" href="http://www.seacoastsciencecenter.org/" target="_blank">Seacoast Science Center</a>
<a class="dropdown-item" href="http://www.granitestatewhalewatch.com/" target="_blank">Granite State Whale Watch</a>
<a class="dropdown-item" href="http://www.portsmouthharbor.com/" target="_blank">Portsmouth Harbor Cruises</a>
</div>
</li>
<li><a class="nav-link" href="rates.html">Rates & Booking</a></li>
<li><a class="nav-link" href="map.html">Map</a></li>
<li><a class="nav-link" href="contact.html">Contact</a></li>
</ul>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="https://www.facebook.com/DriftwoodRentals/" target="_blank">
<span class="fa-stack">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-facebook fa-stack-1x fa-inverse"></i>
</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="mailto:Info#DriftwoodRentals.com">
<span class="fa-stack">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-envelope fa-stack-1x fa-inverse"></i>
</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="tel:1-603-501-0465">
<span class="fa-stack">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-phone fa-stack-1x fa-inverse"></i>
</span>
</a>
</li>
</ul>
</div>
</nav>
<header class="masthead">
<img src="images/Driftwood_Logo.jpg" class="mx-auto d-block img-fluid" alt="Driftwood logo">
</header>
<!-- /.container -->
<!-- Feature -->
<div class="container">
<h1 class="text-center">Welcome to Driftwood Rentals</h1>
<h2 class="text-center">Located on nationally recognized Rye Beach, just steps from Pirate's Coves/Wallis Sands beach and overlooks the majestic marsh.</h2>
<img src="images/Driftwood-aerial.jpg" class="mx-auto d-block img-fluid" alt="Driftwood aerial view">
<p>Welcome to The Driftwood Cottages and Apartments. We are new owners of this seaside vacation spot. Enjoy our charming studios, and one bedroom rustic cottages and two and three bedroom apartments. One minute walk to a pure sandy beach, moments to Portsmouth and all the shopping, whale watches, deep sea fishing, and world class surfing! Our sparkling pool is here for your enjoyment. </p>
<div class="embed-responsive embed-responsive-16by9 center-block">
<iframe width="1920" height="1080" src="https://www.youtube.com/embed/ibkRG1gVtZA?rel=0" allowfullscreen></iframe>
</div>
<p>Our guests can also enjoy our Pool. All cottages have kitchenettes, private bath, screened porch, Cable TV, refrigerator and more!</p>
<p>NO PETS/NO SMOKING ALLOWED!</p>
<p>We are open from May through October</p>
</div>
<div class="clearfix"></div>
<footer class="site-footer">
<p>Copyright © <script>document.write(new Date().getFullYear());</script> The Driftwood</p>
</footer>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
<script>
var $buoop = {vs:{i:10,f:-4,o:-4,s:8,c:-4},unsecure:true,api:4};
function $buo_f(){
var e = document.createElement("script");
e.src = "//browser-update.org/update.min.js";
document.body.appendChild(e);
};
try {document.addEventListener("DOMContentLoaded", $buo_f,false)}
catch(e){window.attachEvent("onload", $buo_f)}
</script>
</body>
</html>
Your nav is fixed position and there's nothing constraining the height - this should work!
#media (max-width: 767px){
nav.navbar{
max-height: 100vh;
overflow: auto;
-webkit-overflow-scrolling: touch;
}
}
I made a collapse menu with Bootstrap, works fine, but I can't make it so the link has the same color as the button:
.collapse-link a:after {
font-family: 'Glyphicons Halflings';
content: "\e114";
color: $white;
background-color: black;
}
.collapse-link a.collapsed:after {
content: "\e080";
background-color: white;
}
I would like the class="collapse-link" get the same background color as right now in the buttons in the right, so the full div will be following the buttons color when is collapse and when is not, right now just the buttons getting background color i would like the titles: test3 and test get the background color of the buttons beside.
jsfiddle: http://jsfiddle.net/Wc4xt/4377/
HTML:
<div class="sidebar">
<div class="sidebar-wrapper">
<ul class="sidebar-nav">
<li>
<i class="pull-left fa-lg fa fa-book" aria-hidden="true"></i>
<div class="collapse-link">
<a data-toggle="collapse" data-target="#collapseExample1" aria-expanded="false" aria-controls="collapseExample1">test3
</a>
</div>
<div class="collapse in collapse-styled" id="collapseExample1">
<i class="pull-left fa fa-lg fa-list" aria-hidden="true"></i>
test List
<i class="pull-left fa fa-lg fa-list" aria-hidden="true"></i>
Create
</div>
</li>
<li>
<i class="pull-left fa fa-lg fa-book" aria-hidden="true"></i>
<div class="collapse-link">
<a data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">test
</a>
</div>
<div class="collapse in collapse-styled" id="collapseExample">
<i class="pull-left fa fa-lg fa-list" aria-hidden="true"></i>
link List
<i class="pull-left fa fa-lg fa-list" aria-hidden="true"></i>
test
</div>
</li>
</ul>
</div>
</div>
CSS:
.sidebar-wrapper {
height: 100%;
overflow-y: auto;
background: #2f3f4d;
-webkit-transition: all 0.5s ease;
transition: all 0.5s ease;
}
.sidebar-nav li {
text-indent: 22px;
line-height: 60px;
border-bottom: 1px solid #455b6f;
}
.sidebar-nav li a {
display: block;
height: 65px;
}
.collapse-link a:after {
font-family: 'Glyphicons Halflings';
content: "\e114";
color: $white;
background-color: black;
}
.collapse-link a.collapsed:after {
content: "\e080";
background-color: white;
}
Add following css to make it work:
.collapse-link a.collapsed {
color: white;
}
a {
text-decoration:none;
}
ul li {
list-style:none;
}
Also check:
http://jsfiddle.net/mayankN/Wc4xt/4381/