I am almost done w/ my menu here. However I have two issues.
I can't add a 1px solid border #fff on the last item of the list.
I need to remove the vertical scrollbar on the left.
Here's my CSS:
#nav li ul {
opacity: 0;
height: 0px;
}
#nav li a {
font-style: normal;
font-weight: 400;
position: relative;
display: block;
padding: 16px 25px;
color: #fff;
white-space: nowrap;
z-index: 2;
text-decoration: none
}
#nav li a:hover {
color: #c0392b;
background-color: #ecf0f1;
}
#nav ul li {
background-color: #e74c3c;
color: #fff;
display: block;
list-style: disc;
}
#nav li:first-child {
border-top: 1px solid #fff;
}
#nav ul {
margin: 0;
padding: 0;
}
#nav .fa { margin: 0px 17px 0px 0px; }
.logo {
width: 100%;
padding: 21px;
margin-bottom: 20px;
box-sizing: border-box;
}
#logo{
color: #fff;
font-size: 30px;
font-style: normal;
}
.sidebar-icon {
position: relative;
float: right;
text-align: center;
line-height: 1;
font-size: 25px;
padding: 6px 8px;
color: #fff;
}
.disp {
opacity: 1!important;
height:auto!important;
transition: height 100ms ease-in-out;
transition-delay: 300ms;
}
#nav li span:first-child {
margin-left: 32px;
}
asdasdasdasdasdasdasdassa
Well, first remove this:
#nav li:not(:last-child) {
border-bottom: 1px solid #fff;
}
for add border to all li even last one:
#nav li {
border-bottom: 1px solid #fff;
}
for removing scroll do this:
JS:
$('body, html').toggleClass('OverflowHidden');
CSS:
.OverflowHidden {
overflow: auto;
}
and for removing double border use this:
#nav li ul li:last-child {
border-bottom: none!important;
}
jsFiddle
Related
I'm asking on here because I'm thoroughly fed up of trying to resolve this myself and getting absolutely nowhere. The only solution I've found so far is to remove the border itself but it's probably best to explain the problem first...
So I'm building a navigation bar for a website and I've done absolutely dozens of these, re-used the same code across multiple projects because... it's a navigation bar! It's incredibly simple, the only difference is that I have an extra nested navigation sub-category. However this occurs regardless whether or not that sub-category exists. When I've built it, it looked absolutely fine but I noticed that there was a small white gap between the elements inside the menu element between them and the border. This gap is incredibly inconsistent however - in the small JS fiddle screen on my old monitor it doesn't appear at all but move it onto my laptop widescreen display and the gaps appear.
I've checked all of my CSS and code, nothing is amiss compared to my other websites and according to Chrome's Computed tab, there isn't actually a gap there at all. There's nothing but the border?! How does it appear then when the Computed tab tells me it's not there? Am I losing my mind?
Regardless, I've posted a JSFiddle to try and get some input on this. I'm using SCSS compiled by Scout App and it appears to only happen on Chrome as far as I can see. Anybody got any ideas?
*,
body {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: auto;
background-color: #D0E9FD;
}
body {
color: #1D1E2C;
font-size: 18px;
font-family: "Kodchasan", sans-serif;
}
a {
text-decoration: underline;
color: #713031;
}
img {
max-width: 100%;
}
h1,
h2,
h3,
h4,
h5 {
color: #2AA6A6;
}
h1 {
font-size: 32px;
margin-top: 10px;
}
h2 {
font-size: 28px;
}
hr {
border: 4px solid #2AA6A6;
}
input,
textarea,
select {
border: 2px solid #2AA6A6;
padding: 10px;
color: #991B1D;
}
input:focus,
textarea:focus,
select:focus {
outline: none;
border: 2px solid #991B1D;
}
input:disabled,
textarea:disabled,
select:disabled {
background-color: #d9f6f6;
border-color: #d9f6f6;
text-align: center;
-webkit-appearance: none;
-moz-appearance: none;
font-family: "Kodchasan", sans-serif;
font-size: 18px;
opacity: 1;
}
input:disabled:-ms-expand,
textarea:disabled:-ms-expand,
select:disabled:-ms-expand {
display: none;
}
form {
border: 2px solid #2AA6A6;
padding: 10px;
}
form input,
form textarea,
form label {
margin-bottom: 10px;
width: 49%;
display: inline-block;
}
form input,
form textarea {
border: 2px solid #2AA6A6;
padding: 10px;
color: #991B1D;
}
form input:focus,
form textarea:focus {
outline: none;
border: 2px solid #991B1D;
}
form input[type="submit"] {
width: 100%;
margin: 0;
}
form button {
background-color: #2AA6A6;
color: #FFFFFF;
border: 2px solid #2AA6A6;
}
form a {
width: 90%;
display: block;
text-align: center;
}
form>p {
width: 50%;
display: block;
margin: 0 auto;
text-align: center;
}
#navigation {
padding: 2px 0;
background-color: #2AA6A6;
}
#navigation ul {
list-style-type: none;
margin: 0;
padding: 0;
}
#navigation li a {
display: block;
color: #FFFFFF;
font-weight: 700;
font-size: 24px;
text-decoration: none;
width: 100%;
padding: 15px;
}
#navigation li.parent-cat ul {
background-color: #FFFFFF;
margin: 10px 0;
margin-left: 20px;
}
#navigation li.parent-cat ul a {
color: #713031;
}
#navigation li ul {
background-color: #FFFFFF;
margin: 10px 0;
margin-left: 20px;
}
#navigation li ul a {
color: #713031;
}
#navigation #nav {
display: none;
border-top: 5px solid #FFFFFF;
}
#navigation #menu {
display: block;
text-align: center;
background-color: #2AA6A6;
cursor: pointer;
padding: 10px 0;
font-size: 24px;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
color: #FFFFFF;
}
#navigation #menu.open {
background-color: #713031;
color: #FFFFFF;
}
#navigation li {
display: inline-block;
}
#navigation li a {
font-size: 18px;
padding: 20px 30px;
}
#navigation li a:hover {
background-color: #FFFFFF;
color: #2AA6A6;
}
#navigation li.parent-cat {
position: relative;
}
#navigation li.parent-cat:hover a {
background-color: #FFFFFF;
color: #2AA6A6;
}
#navigation li.parent-cat:hover ul {
display: block;
position: absolute;
width: 100%;
margin-top: 0;
z-index: 99;
margin-left: 0;
border: 2px solid #713031;
margin-bottom: 0;
}
#navigation li.parent-cat:hover ul li {
width: 100%;
}
#navigation li.parent-cat:hover ul a:hover {
background-color: #713031;
color: #FFFFFF;
}
#navigation li.parent-cat:hover .parent-cat:hover ul {
display: block;
margin-left: 100%;
margin-top: -32%;
}
#navigation li.parent-cat:hover .parent-cat ul {
display: none;
}
#navigation li.parent-cat ul {
display: none;
}
#navigation #menu {
display: none;
}
#navigation #nav {
display: block;
border: none;
}
/* EOS */
<div id="navigation">
<ul id="nav">
<li id="one"><span>Home</span></li>
<li id="two" class="parent-cat"><span>Our Workshop</span> <i class="fas fa-level-down-alt"></i>
<ul>
<li id="three"><span>Our Solutions</span></li>
<li id="four" class="parent-cat">
<span>Our Products</span> <i class="fas fa-level-down-alt"></i>
<ul>
<li id="five"><span>Lighting Components</span></li>
<li id="six"><span>Motorcycle Parts</span></li>
<li id="seven"><span>RC Buggy Parts</span></li>
</ul>
</li>
</ul>
</li>
<li id="five"><span>Careers</span></li>
<li id="six"><span>Latest News</span></li>
<li id="seven"><span>Contact Us</span></li>
</ul>
<a id="menu"><i class="fas fa-bars"></i></a>
</div>
I have a simple vertical hover menu and even when I don't hover over any buttons but the cursor is a little to the right of it, it shows the submenu. When there isn't a submenu the main menu button starts to flicker. I am not entirely sure what is going on and why it is happening. Here is link to show what I mean.
EDIT: Thank you for your responses! Now I'm having a different/almost same problem. The menu doesn't freak out any more, but now there's a bar that sticks out of it and it is still opening the submenus without having to hover over the parent menu. Link to picture here.
Here's my HTML
<div id="divMenu">
<ul>
<li>Home1</li>
<li>Home2
<ul>
<li>Homed</li>
<li>Homee</li>
<li>Homef</li>
</ul></li>
<li>Home3
<ul>
<li>Homeg</li>
<li>Homeh</li>
<li>Homei</li>
</ul></li>
<li>Home4</li>
<li>Home5
<ul>
<li>Homej</li>
<li>Homek</li>
<li>Homel</li>
</ul></li>
<li>Home6</li>
</ul>
</div>
And my CSS
<style type="text/css">
#divMenu {
margin: 0px;
padding: 0px;
}
#divMenu ul {
margin: 0px;
padding: 5px 15px;
}
#divMenu li {
margin: 4px;
padding: 4px;
}
#divMenu li li {
margin: 0px;
padding: 0px;
}
#divMenu {
width: 150px;
height: 27px;
}
#divMenu ul {
line-height: 25px;
}
#divMenu li {
list-style: none;
position: relative;
background: #000;
}
#divMenu li li {
list-style: none;
position: relative;
background: #000;
left: 95px;
top: -30px;
}
#divMenu ul li a {
width: 150px;
height: 25px;
padding: 5px 5px;
display: inline-block;
letter-spacing: 6px;
text-decoration: none;
text-align: left;
font-family: Quicksand Light;
color: #ffffff;
border: 0px;
}
#divMenu ul ul {
position: absolute;
visibility: hidden;
top: 27px;
}
#divMenu ul li:hover ul {
visibility: visible;
}
#divMenu li:hover {
background-color: #fff;
}
#divMenu ul li:hover > a {
background-color: #fff;
color: #000;
}
#divMenu a:hover {
font-weight: normal;
color: #000;
}
</style>
Just remove width:0px from #divMenu ul li:hover > a and #divMenu a:hover from your style.
The problem of the block tripping is because of the width in the block underneath:
#divMenu ul li a {
width: 150px;
height: 25px;
padding: 5px 5px;
display: inline-block;
letter-spacing: 6px;
text-decoration: none;
text-align: left;
font-family: Quicksand Light;
color: #ffffff;
border: 0px;
}
Just remove that width and it should work.
It's due to the zero width you're applying to the links. You really don't need that.
#divMenu ul li:hover > a {
/*width: 0px;*/
background-color: #fff;
color: #000;
}
#divMenu a:hover {
/*width: 0px;*/
font-weight: normal;
color: #000;
}
#divMenu {
margin: 0px;
padding: 0px;
}
#divMenu ul {
margin: 0px;
padding: 5px 15px;
}
#divMenu li {
margin: 4px;
padding: 4px;
}
#divMenu li li {
margin: 0px;
padding: 0px;
}
#divMenu {
width: 150px;
height: 27px;
}
#divMenu ul {
line-height: 25px;
}
#divMenu li {
list-style: none;
position: relative;
background: #000;
}
#divMenu li li {
list-style: none;
position: relative;
background: #000;
left: 95px;
top: -30px;
}
#divMenu ul li a {
width: 150px;
height: 25px;
padding: 5px 5px;
display: inline-block;
letter-spacing: 6px;
text-decoration: none;
text-align: left;
font-family: Quicksand Light;
color: #ffffff;
border: 0px;
}
#divMenu ul ul {
position: absolute;
visibility: hidden;
top: 27px;
}
#divMenu ul li:hover ul {
visibility: visible;
}
#divMenu li:hover {
background-color: #fff;
}
#divMenu ul li:hover > a {
/*width: 0px;*/
background-color: #fff;
color: #000;
}
#divMenu a:hover {
/*width: 0px;*/
font-weight: normal;
color: #000;
}
<div id="divMenu">
<ul>
<li>Home1</li>
<li>Home2
<ul>
<li>Homed</li>
<li>Homee</li>
<li>Homef</li>
</ul></li>
<li>Home3
<ul>
<li>Homeg</li>
<li>Homeh</li>
<li>Homei</li>
</ul></li>
<li>Home4</li>
<li>Home5
<ul>
<li>Homej</li>
<li>Homek</li>
<li>Homel</li>
</ul></li>
<li>Home6</li>
</ul>
</div>
My website's menu drop down seems to malfunction and it is stuck on the screen. Don't know how to fix http://www.kingadlerhomedecor.com/store/
I want to add more sub categories to this drop-down, but I wish to avoid making the drop down list too lengthy. I thus want 2 rows here in the drop-down to adjust the length list of sub-categories, but it doesn't seems to happen, instead there is a new problem - The drop-down menu item is half stuck and I am unable to fix this.
I have not made any changes and yet it seems to malfunction. No clue how to fix the dropdown menu stuck on my screen. Please advice.
/* MENU */
.primary-define #menu {
text-align: left;
font-family: helvetica, Arial;
/*background-color: #999;*/
}
.primary-define #menu-inner {
position: relative;
font-family: helvetica, Arial;
background-color: #999; /*No color was added origninally - added to make it grey*/
}
.primary-define .mainmenu {
margin: 0;
padding: 0;
position: relative;
list-style-type: none;
}
.primary-define .mainmenu li {
margin: 0;
padding: 0;
position: relative;
}
.primary-define .mainmenu > li {
float: left;
/*background-color: #999;*/
}
.primary-define .mainmenu li a {
color: #666; /*originial #666*/
display: block;
font-size: 10px; /*original 15px */
padding: 0.5px 1px; /*20px 25px */ /*Padding for the dropdown elements*/
text-decoration: none;
/*background-color: #999;*/
}
.primary-define .mainmenu > li > a {
color: #fff;
padding: 15px 25px; /*35px*/
font-size: 14px; /*original 18px */
font-weight: 600;
line-height: 100%;
font-family: helvetica, Arial;
}
.primary-define .mainmenu > li:hover > a,
.primary-define .mainmenu > li.active > a {
background-color: rgba(0, 0, 0, 1); /*rgba(0, 0, 0, 0.2)*/
/*font-size: 15px;*/
}
.primary-define .mainmenu li .dropdown-container {
top: 99%;
overflow: hidden;
position: absolute; /*absolute*/
padding-left: 1px; /*added by yuvi*/
font-size: 30px; /*added by yuvi*/
}
.primary-define .mainmenu li .dropdown {
margin-top: -300px; /*-999px*/
background-color: #fff;
border-left: 1px solid #eee;
border-bottom: 1px solid #eee;
font-size: 30px; /*added by yuvi*/
padding: 10px;
}
.primary-define .mainmenu li:hover .dropdown {
margin-top: 0;
/*font-size: 30px; added by yuvi*/
}
}
.primary-define .mainmenu ul {
margin: 0;
float: left;
width: auto; /*249px*/
list-style-type: none;
border-right: 1px solid #eee;
}
.primary-define .mainmenu ul li:hover a,
.primary-define .mainmenu ul li.active a {
background-color: #eee; /*orginiarl #eee*/
margin-top has to be -380px.
.primary-define .mainmenu li .dropdown {
margin-top: -380px;
background-color: #fff;
border-left: 1px solid #eee;
border-bottom: 1px solid #eee;
font-size: 30px;
padding: 10px;
}
I want to have a border (looks like underline) that moves up on hover.
So if this is a link:
LINK
Then if I hover on it
LINK
""""
Example from the website:
http://matthias-schoenaerts.com/
(navigation bar)
I want it as simple as possible.
This is what I came up with:
http://jsfiddle.net/Lxxqz3pL/
HTML:
<ul id="nav">
<li>About Us</li>
<li>Our Products</li>
<li>FAQs</li>
<li>Contact</li>
<li>Login</li>
</ul>
CSS:
/* Begin Navigation Bar Styling */
#nav {
width: 100%;
float: center;
margin: 0 0 3em 0;
left: 0;
padding: 0;
list-style: none;
background-color: #333333;
border-bottom: 1px solid #ccc;
border-top: 1px solid #ccc;
position: absolute;
}
#nav li {
float: left;
}
#nav li a {
display: block;
padding: 8px 15px;
text-decoration: none;
font-weight: bold;
color: #a3a3a3;
}
#nav li a:hover {
transition: border .5s ease-in;
background-color: #fff;
border-bottom: 3px solid red;
}
/* End navigation bar styling. */
Here is updated CSS, does it what you trying to get?
/* Begin Navigation Bar Styling */
#nav {
width: 100%;
float: center;
margin: 0 0 3em 0;
left: 0;
padding: 0;
list-style: none;
background-color: #333333;
border-bottom: 1px solid #ccc;
border-top: 1px solid #ccc;
position: absolute;
overflow: hidden;
}
#nav li {
float: left;
}
#nav li a {
display: block;
padding: 8px 15px;
text-decoration: none;
font-weight: bold;
color: #a3a3a3;
}
#nav li a:after{
display:block;
width:100%;
height:0px;
content:" ";
border:1px solid red;
position: relative;
top:10px;
}
#nav li a:hover:after{
transition: 0.5s ease-in;
transform: translate(0px, -10px);
}
/* End navigation bar styling. */
I've modified your code in areas to get the desired effect
DEMO http://jsfiddle.net/Lxxqz3pL/3/
#nav li a {
display: block;
padding: 8px 15px;
text-decoration: none;
font-weight: bold;
color: #a3a3a3;
padding: 22px 0 35px;
color: #a3a3a3;
border-bottom: 3px solid #6a901b;
transition: all 0.5s ease;
}
#nav li a:hover {
transition: all 0.5s ease;
color: #fff;
padding-bottom: 5px;
}
How about something like this? FIDDLE.
Just keep the background fixed, add a border at the bottom, and make the height of the anchor smaller.
Relevant CSS
#nav li {
float: left;
height: 40px;
}
#nav li a {
display: block;
padding: 8px 15px;
text-decoration: none;
font-weight: bold;
color: #a3a3a3;
height: 20px;
transition: height 0.5s;
}
#nav li a:hover {
height: 10px;
border-bottom: 3px solid red;
}
It looks like the example site uses flexNav, a jQuery plugin.
http://jasonweaver.name/lab/flexiblenavigation/
Here's a quick-fix solution. I added a transition to <li> padding to compensate for the added border.
http://jsfiddle.net/Lxxqz3pL/1/
I am facing some problem with this drop down menu thing. I read your article and it helped me. In the beginning, the drop down worked but when I added some more styling then it stopped working. Other divs and navigation bar is working fine but the drop down menu is not working. Can you please help me pointing out what should be corrected here?
The parent div is nav-bar-left and the style is
.nav-bar-left {
float; left;
overflow: hidden;
width: 980px;
height: 26px;
background-color: Lavender;
border: 1px solid MidnightBlue;
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
}
The navigation div is #horizontalmenu which resides within the above parent div and the style is
#horizontalmenu {
width: 733px;
margin: 0;
position: relative;
float: left;
padding: 0;
}
Rest of the styling for navigation bar is
#navbar {
list-style-type: none;
margin: 0;
width: 100%;
padding: 0;
position: relative;
display: inline-table;
height: 26px;
z-index: 5;
}
#navbar li {
float: left;
position: relative;
}
#navbar a:link, #navbar a:visited {
display: block;
color: #333;
background-color: lavender;
text-align: center;
padding: 6px 10px;
border-style: solid;
border-color: MidnightBlue;
border-width: 0 1px 0 0;
text-decoration: none;
font-size: 14px;
line-height: 14px;
}
#navbar a:hover, #navbar a:active {
color: #fff;
background-color: #6b0c36;
text-decoration: underline;
}
#navbar ul {
left:-9999px;
list-style-type: none;
margin: 0;
padding: 0;
position: absolute;
}
#navbar ul li {
float:none;
border-style: solid;
border-color: Lavender;
border-width: 0 1px 1px 1px;
}
#navbar ul a {
white-space: nowrap;
}
#navbar li:hover ul {
left: 0;
}
#navbar:hover a {
text-decoration: none;
}
#navbar li:hover ul a {
text-decoration: none;
background-color: Lavender;
color: #333;
}
#navbar li:hover ul li a:hover {
background-color: Lavender;
color: #333;
}
So, why is it not working and what can be done?
I found this menu CSS one of my best collection for dropdown menu:
Create a Multilevel Dropdown menu with CSS and improve it via jQuery
And you can find a backup of those codes here in my pastebin.