Lining up elements on CSS dropdown - css

How would I line up my dropdown elements with the clicker?
Here is my CSS code
#header_dropdown {
float: right;
}
.click-nav {
width: 200px;
}
.click-nav ul {
position: relative;
}
.click-nav ul li {
position: relative;
list-style: none;
cursor: pointer;
}
.click-nav ul li ul {
position: absolute;
}
.click-nav ul .clicker {
position: relative;
background: #2284B5;
color: #FFF;
}
.click-nav ul .clicker:hover, .click-nav ul .active {
background: #196F9A;
}
.click-nav ul li a {
transition: background-color 0.2s ease-in-out;
-webkit-transition: background-color 0.2s ease-in-out;
-moz-transition: background-color 0.2s ease-in-out;
display: block;
background: #FFF;
color: #333;
text-decoration: none;
}
.click-nav ul li a:hover {
background: #F2F2F2;
}
/* Fallbacks */
.click-nav .no-js ul {
display: none;
}
.click-nav .no-js:hover ul {
display: block;
}
Jsfiddle at http://jsfiddle.net/KVrFM/

You need to remove the padding from the sub-menu ul.
http://jsfiddle.net/KVrFM/1/
I modified your anonymous function to add the active class to the li rather than the anchor tag using jQuery parent().
$('.clicker').parent().toggleClass('active');
Then I added the following CSS rule. When doing drop-down and fly-out menus in CSS it is helpful to use the child combinator >. Having a rule like .click-nav ul will target all ul that are descendants of .click-nav. Changing that rule to .click-nav > ul will only target uls that are children of .click-nav and not grandchildren etc.
.active ul {
padding: 0;
}

Related

Menu links jump out from pannel after zoom

Good evening,
I have problem with my menu links. When I see it on mobile and zoom it for text, links just jump out from pannel to next row.( http://www.abclinuxu.cz/data/prilohy/0/6/214560-img_1705-3567267490611876903.PNG ) I have set position fixed etc.. How can I force this bug? Thank you for advices!
HTML:
<div id="nabidka">
<div id='cssmenu'>
<ul>
<li><a href='#about'>O nás</a></li>
<li><a href='#cenik'>Ceník</a></li>
<li><a href='#sluzby'>Služby</a></li>
<li><a href='#kontakt'>Kontakt</a></li>
</ul>
</div>
</div>
CSS:
#nabidka {
width:550px;
height: 90px;
margin-left: 1.5em;
padding-top: 5px;
float:left;
}
#cssmenu,
#cssmenu ul,
#cssmenu ul li,
#cssmenu ul li a,
#cssmenu #menu-button {
list-style: none;
line-height: 80px;
margin: 0 auto;
}
#cssmenu:after,
#cssmenu > ul:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
#cssmenu #menu-button {
display: none;
}
#cssmenu {
width: auto;
line-height: 80px;
height:90px;
}
#cssmenu > ul {
}
#cssmenu > ul > li {
float: left;
}
#cssmenu.align-center > ul {
font-size: 0;
text-align: center;
}
#cssmenu.align-center > ul > li {
display: inline-block;
float: none;
}
#cssmenu.align-right > ul > li {
float: right;
}
#cssmenu > ul > li > a {
font-size: 20px;
text-transform: ;
text-decoration: none;
color: white;
-webkit-transition: all .2s ease;
-moz-transition: all .2s ease;
-ms-transition: all .2s ease;
-o-transition: all .2s ease;
transition: all .2s ease;
}
#cssmenu > ul > li > a:hover,
#cssmenu > ul > li:hover > a,
#cssmenu > ul > li.active > a {
color: #f26c4f;
}
#sipka {
position: absolute;
left: -1000px;
}
#cssmenu #menu-indicator {
position: absolute;
bottom: 0;
display: block;
height: 0;
width: 0;
border: 7px solid transparent;
border-bottom-color: white;
-webkit-transition: all 0.25s ease-out;
-moz-transition: all 0.25s ease-out;
-ms-transition: all 0.25s ease-out;
-o-transition: all 0.25s ease-out;
transition: all 0.25s ease-out;
}
I cannot see what it is supposed to look like. Try to share a link to your html file.
However, I believe the issue lies in your CSS. You are using a combination of px values combined with em. Try to put the line-height for #cssmenu in em, perhaps that is the issue.
From a really fast look at your code, i think the issue is related to the element getting collapsed due to the "float: left".
This issue is easily fixed with .clearfix method Clearfix snippet. You fix this issue by placing the .clearfix class on the parent element or on any parent of the elements you float.
Another simple solution, which i would not recommend is using overflow:hidden;
Hope this helps.

How to get similar effect on menu

I have a menu which is developed using bootstrap. Currently it has a CSS transition effect when you hover over each item I line is placed under each heading. I can't seem to figure out how can I do the same but on top of the heading and the transition effect coming from the other direction.
The code I have so far is
.navbar ul li:after {
content:'';
display: block;
height: 4px;
width: 0;
transition: width .6s ease, background-color .6s ease;
}
.navbar ul li:hover:after {
width: 100%;
background: #fff;
}
I have created a JSFiddle Here
Thanks in advance for all your help.
.navbar ul li:before,
.navbar ul li:after {
content:'';
display: block;
position:absolute;
height: 4px;
width: 0;
background: #fff;
transition: width .6s ease, background-color .6s ease;
}
.navbar ul li:before{ top:0; right:0; }
.navbar ul li:after { bottom:0; left:0; }
.navbar ul li:hover:before,
.navbar ul li:hover:after{ width: 100%; }
http://jsfiddle.net/RokoCB/zpxtre6n/4/
demo - http://jsfiddle.net/zpxtre6n/5/
just add float:right for your .navbar ul li:after and float:left for .navbar ul li:before
.navbar ul li:after, .navbar ul li:before {
content:'';
display: block;
height: 4px;
width: 0;
float:right;
transition: width .6s ease, background-color .6s ease;
}
.navbar ul li:before{
float:left;
}
.navbar ul li:hover:after, .navbar ul li:hover:before {
width: 100%;
background: #fff;
}

Navigation Menu dropdown

i am having a problem which is small but frustrating:
look at the top menu on my site: www.integratedphysicaltherapy.ie
the "Sports Injury Management" link seems to be a effected by its dropdown element in some way. Ive had a look but can't see whats causing it. Any help would be much appreciated.
here is the code
#header .header-links .sub-menu {
display: none;
float: left;
position: absolute;
z-index: 1111;
border: 0px solid #303030;
background: #1C1C1C;
}
#header .header-links .sub-menu a {
color: white;
font-size: 12px;
border-bottom: 0px solid #303030;
line-height: 22px;
margin: 0;
padding: 0 0px 0 10px;
}
#header .header-links .sub-menu li:last-child > a {
border: 0;
}
#header .header-links .sub-menu a:hover,
#header .header-links .sub-menu .current-menu-item a {
}
#pre-header .sub-menu li,
#header .sub-menu li {
float: none;
position: relative;
}
#header .sub-menu li {
padding: 2px 1px;
}
#header .sub-menu li:hover {
padding-left: 1px;
}
#header .menu > li > a {
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-ms-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
transition: all 0.3s ease;
}
#header .menu > li.menu-hover > a,
#header .menu > li.current_page_item > a,
#header .menu > li.current-menu-ancestor > a,
#header .menu > li > a:hover {
color: #F33F3F;
}
.main-navigation:after {
clear: both;
content: "";
display: block;
}
.main-navigation ul {
list-style: none;
margin: 0;
padding-left: 0;
}
.main-navigation .sub-menu a {
white-space: nowrap;
}
.main-navigation .sub-menu .sub-menu {
position: absolute;
top: -1px;
left: 100%;
}
.main-navigation ul ul :hover > a {
}
#pre-header .main-navigation ul li:hover > ul,
#header .main-navigation ul li:hover > ul {
display: block;
}

Center my navigation bar with CSS

Since a couple of days I'm working on a navigation bar for my website. But I want to center it . Here's my CSS
.nav{
float:right;width:980px
}
.nav ul {
width: 980px;
margin: 0 auto;
padding: 0;
list-style: none;
font-size: 1.5em;
font-weight: 300;
}
.nav li {
float: right;
width: 87px;
text-align: center;
-webkit-transition: border .5s;
-moz-transition: border .5s;
-o-transition: border .5s;
-ms-transition: border .5s;
transition: border .5s;
}
.nav a {
display: block;
width:87px;height: 74px;
}
.no-touch .nav a:hover ,
.nav a:active ,
.nav a:focus {
height: 84px;
}
.nav li span {
display: block;
font-family:"Droid Arabic Kufi";
The float on the nav is unnecessary and the with on the .nav prevents the .nav ul to center.
.nav {
float: right; // Remove this.
width: 100%; // Change this.
}
http://jsfiddle.net/7TBHn/2/
Though in my jsfiddle I use the nav element to be more semantic, but other then that it makes no difference.
Put this in your .nav ul:
margin-left:auto;
margin-right:auto;
This should center it. Hope this helps!

CSS menu not rendering correctly in IE

The menu that I built works correctly in all other browsers except IE - what a surprise.
jsfiddle of menu: http://jsfiddle.net/JazParkyn/6jshy/19/
not sure that the fiddle will help though as the menu works correctly on here when viewed in ie, so i'm guessing that it's something to do with my template. I've used the IE edge code and that has made everything else on the site work, does anyone have any ideas?
css:
nav ul ul {
z-index:100;
opacity: 0;
visibility: hidden;
transition: all .5s ease-in;
-o-transition: all .5s ease-in;
-ms-transition: all .5s ease-in;
-moz-transition: all .5s ease-in;
-webkit-transition: all .5s ease-in;
}
nav ul li:hover > ul {
z-index:100;
visibility: visible;
opacity: 1;
}
nav ul {
background: #355E95;
box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.15);
padding: 0 20px;
border-radius: 10px;
list-style: none;
position: relative;
display: inline-table;
}
nav ul:after {
content:"";
clear: both;
display: block;
}
nav ul li {
float: left;
}
nav ul li:hover {
background: #1881B4;
}
nav ul li:hover a {
color: #fff;
}
nav ul li a {
display: block;
padding: 20px;
color: #ffffff;
text-decoration: none;
}
nav ul ul {
background: #355E95;
border-radius: 0px;
padding: 0;
position: absolute;
top: 100%;
}
nav ul ul li {
float: none;
border-top: 1px solid #D5EEFF;
border-bottom: 1px solid #D5EEFF;
position: relative;
}
nav ul ul li a {
padding: 15px 40px;
color: #fff;
}
nav ul ul li a:hover {
background: #1881B4;
}
nav ul ul ul {
position: absolute;
left: 100%;
top:0;
}
Any suggestions would be appreciated
This is happening in IE10 and i've forced standards mode with the ie edge meta tag. the jsfiddle will work fine in ie, just not the actual web page.
EDIT: i've just put the following css in and it now magically works
html {
-webkit-font-smoothing: antialiased;
}
However, I still have the issue of the font not rendering properly in safari and opera, i'm guessing something to do with their rendering machines - the font appears to be heavier in weight, has anyone had this happen before?
hmm, the fiddle is working in IE. on your page I would add in the
menu.css (line 51)
#nav ul li {
/* leave the other properties here */
position:relative;
}
and for the submenu (line 56)
#nav ul ul {
/* leave the other properties here */
left:0;
}
Maybe you can add a property to the separator class (just for visual feedback) :
.separator {
cursor: pointer;
}

Resources