Wordpress CSS, customizing menu - html

So, I've tried to implement a two column menu into my wordpress, using this CSS code which I’ve found on the internet:
.sub-menu-columns .sub-menu{
display:inline-block;
width:500px !important;
background-color:#FFFFFF;
}
.sub-menu-columns .sub-menu li{
width:50% !important;
}
.sub-menu-columns .sub-menu li a:hover{
color:#FFFFFF;
}
.sub-menu-columns .sub-menu li:nth-child(even){
float:right;
border-left:2px;
border-color: #404040;
}
I added .sub-menu-columns as a CSS class for the top-level-menu “Products” at which only!! the two column sub menu should be seen.
I managed to get this to work. Now is the problem, since the menu is bigger in width, that I need to move the sub-menu container to the left. I also managed to solve this issue with this code:
#mainnav ul li ul{
left:-400px;
}
Now is the only thing, that all other Menus with submenus are moved to the left too (as you can see with “Contact/Support”)
My logical approach would be to edit the previous code to:
#mainnav .sub-menu-columns .sub-menu ul li ul{
left:-400px;
}
In addition, adding border-left doesnt bring any border up.
Here is how it looks like:
And this is how it should look like:
My current custom CSS script for the menu (with double colums, moving to the left and the Bootstrap Arrow-up back to the righ which is the ::before):
.sub-menu-columns .sub-menu{
display:inline-block;
width:500px !important;
background-color:#FFFFFF;
}
.sub-menu-columns .sub-menu li{
width:50% !important;
}
.sub-menu-columns .sub-menu li a:hover{
color:#FFFFFF;
}
.sub-menu-columns .sub-menu li:nth-child(even){
float:right;
}
#mainnav ul li a{
border-left:2px;
border-color: #404040;
}
#mainnav ul li ul{
left:-400px;
border-left:2px;
border-color: #404040;
}
#mainnav ul li ul::before{
left:450px;
}
However that is not working.
Any ideas maybe? Since I've heard many people use lately jsFiddle for helping out, I'm not sure if I've done it right, but this is what I could provide for you: https://jsfiddle.net/mve1wdfd/
Website: https://xs-sol.com/
Thank you for your help!
Update: I think the main issue is that I'm unable to combine the id=mainnav with other classes and ul's, il's a:hover's and so on.

Related

CSS only menu hover issue in Safari iOS 8.4.1

I've got a safari-specific problem with a hover effect probably related to the synthetic click vulnerability fix in iOS 8.4.1. When the user tries to click on a link there is no response.
The menu is a simple CSS-only menu. I have created a demo here: https://jsfiddle.net/baad95e3/
#menu :hover ul {
right:auto;
left:0;
}
#menu :hover ul ul {
left:-9999px;
width:160px;
padding-left:5px;
background:none;
}
#menu li ul :hover ul {
left: 170px;
right:auto;
}
#menu li ul li ul li a {
text-align:left;
color:#000;
}
#menu li ul li ul li a:hover {
color:#000;
}
What would be a good workaround without losing the hover effect.
Hacky but can work, did for me in some cases:
* { z-index: 0; }

I have a few css issues with a dropdown menu I've created

I get the feeling that these are really simple problems, however I'm new to coding and can't work out how to fix them. Any help would be greatly appreciated.
Firstly, the hyperlink text is currently the only clickable part of the dropdown menu. I want to be able to click the whole section of the menu that the text sits in, i.e the individual parts separated by the 1px borders. I'd also like these sections to change color when the cursor hovers over them, but I'm not sure which part of the css to change if I want to achieve this.
Secondly, the padding creating the space between my main menu links is being included in the link hover function. Is there a way of spacing out the links that doesn't cause the subpages to drop down when I hover over the white space to the left of them? (This seems like the opposite of my first problem)
Finally, part of the css I've written makes any of the parent menu links that have been clicked stay highlighted purple while the viewer is on that page. This was intentional, however now that I have child pages in the dropdown menu, they all stay that color too when the parent page is clicked. Is there a way of fixing this? it would be ideal if both the parent link and the specific child link stayed highlighted purple whilst the viewer was on a that particular child page.
The website link is www.lucieaverill.co.uk
Here is the code :
HTML:
<nav class="site-nav">
<?php $args = array('theme_location' => 'primary'); ?>
<?php wp_nav_menu(); ?>
</nav>
CSS:
/* header navigation menu */
.header nav ul{
display:block;
float:right;
width:auto;
margin-top:15px;
padding: 0;
background-color:#ffffff;
list-style:none;
}
.header nav ul li {
float:left;
padding-left:50px;
padding-bottom:20px;
}
.header nav ul li.current-menu-item a:link,
.header nav ul li.current-menu-item a:visited{
color:#A084BD;
}
/* dropdown menu */
.header nav ul ul {
position:absolute;
left: -999em;
}
.header ul li:hover ul {
left:auto;
width: 200px;
}
.header ul li ul li {
float:none;
padding-left:10px;
padding-top: 12px;
padding-bottom: 12px;
border-bottom: 1px solid #ededed;
}
.header ul li ul li a {
font-size:11px;}
/* end dropdown menu */
/* end header navigation menu */
UPDATE! ------------------------------
I think I've made some progress based on what various people have been saying about a tags. I've managed to reach the point where the hover effect changes the a tag's color, however the padding is a little off, and I can't work out why. I've tried setting the padding-right value to "auto", as I don't think it can have a specific value as each link varies in length.
Obviously, I want the padding to extend to the very end of the menu at the right hand side, but I can't make this work.
There also seems to be some odd spacing between the color of each link, and at the very bottom of the menu.
I'm surprised to see that the transition between colors is smooth and gradual.. I don't think I have any css that tells it to act like this.. is there a way of making it more instant?
The web link again, is www.lucieaverill.co.uk
/* dropdown menu */
.header nav ul ul {
position:absolute;
left: -999em;
}
.header ul li:hover ul {
left:auto;
width: 200px;
}
.header ul li ul li {
margin-left:0px;
float:none;
}
.header ul li ul li a {
background-color:#FF3F55;
padding-left:10px;
padding-right:auto;
padding-top: 12px;
padding-bottom: 12px;
font-size:11px;
border-bottom: 1px solid #ededed;
}
.header ul li ul li:hover a {
background-color:#ededed; }
/* end dropdown menu */
See the fiddle:
Remove the padding of li and add the required padding to a tag.
the clickable problem will be fixed.
/* header navigation menu */
.header nav ul{
display:block;
float:right;
width:auto;
margin-top:15px;
padding: 0;
background-color:#ffffff;
list-style:none;
}
.header nav ul li {
float:left;
padding:0px;
}
.header nav ul li a{
padding:20px 25px;
}
.header nav ul li a:hover {
color:white;
background:black;
}
.header nav ul li.current-menu-item a:link,
.header nav ul li.current-menu-item a:visited{
color:#A084BD;
}
/* dropdown menu */
.header nav ul ul {
position:absolute;
left: -999em;
}
.header ul li:hover ul {
left:auto;
width: 200px;
}
.header ul li ul li {
float:none;
padding-left:10px;
padding-top: 12px;
padding-bottom: 12px;
border-bottom: 1px solid #ededed;
}
.header ul li ul li a {
font-size:11px;}
/* end dropdown menu */
/* end header navigation menu */
<div class="header">
<nav class="site-nav">
<ul>
<li>menu1</li>
<li>menu2</li>
<li>submenu
<ul>
<li>submenu1</li>
<li>submenu2</li>
</ul>
</li>
</ul>
</nav>
</div>

css menu alignment and word spacing issues

I have two small issues in CSS that I am unable to figure out. First is the ability to extend the area of the block on the drop down to fit the wording in properly. And secondly is the sub-menu, sub-menu placement. I have a fiddle setup here: fiddle
The only attribute from what I can tell is
display: inline-block;
This is the first issue: http://screencast.com/t/9GSbhMWe
And the second issue: http://screencast.com/t/TOAKiE5db
Could someone maybe assist if they could. What am I missing?
Thanks in advance.
Add this into your stylesheet. Or you'd better find and edit the related properties directly.
#nav .main-navigation .sub-menu {
background: url(images/background.jpg);
}
#nav .main-navigation .sub-menu li {
display: block;
}
#nav .main-navigation .sub-menu,
#nav .main-navigation .sub-menu li a {
width: auto;
}
#nav .main-navigation .sub-menu li a {
background: none;
}
To fix the 2nd issue, add this.
#nav .main-navigation .sub-menu .page_item_has_sub-menu {
position: relative;
}

In a bit of a CSS Pickle

I am in the process of making a CSS drop down menu and CSS has just thrown me a curve ball.
Problem:
When I hover over my "Tools" section, the submenu is a few pixels off my main menu.
Problem CSS:
#menubar ul li {
font:bold 12px/18px sans-serif;
display:inline-block;
position:relative;
padding:10px 35px;
/*Change this to 15px 35px;and it will work*/
background:#666;
cursor:pointer;
color:#fff;
-webkit-transition:all 0.2s;
-moz-transition:all 0.2s;
-ms-transition:all 0.2s;
-o-transition:all 0.2s;
transition:all 0.2s;
}
I have broken it for the purpose of this question (And because I do not want to use 15px padding, I want to use 10px)
Here is a FIDDLE so you can see exactly what I am talking about if I did not explain this correctly.
I have tried Margin, Top with negative values, all sorts of other things and cannot get this to stay glued to the main menu.
Please guide me in fixing this...
EDIT
Thank you ALL... This has been solved! :) +1 for all.
Fiddle
In this CSS rule, you have this:
#menubar ul li ul {
top:48px;
}
However, you should have this:
#menubar ul li ul {
top:38px;
}
That should fix it with the existing code you have and not create any new code.
Alternatively, set it to 100% instead, as it will take the % of the ul above it, pushing it always the correct height if you change the ul's design in future.
add top:-10px; to #menubar ul li
EXAMPLE
I think the problem is in following code
#menubar ul li ul {
padding:0;
position:absolute;
top:48px; //Change this value and it will glued to upper menu
......
Just set top to 100% then it doesn't matter how big the parent is and will cope if the user resizes the text:
#menubar ul li ul {
padding:0;
position:absolute;
top:100%;
...
}
http://jsfiddle.net/65ZAv/6/
In to CSS class #menubar ul li ul you define top:48px;.
#menubar ul li ul {
top:48px;
}
try to set top:38px;.
#menubar ul li ul {
top:38px;
}

How to stop drop down menu in Wordpress from highlighting?

I have a Wordpress menu with a drop down menu. The problem I'm having is when the parent page is highlighted, the below drop down items are also highlighted. This is a problem because the parent is highlighted with an image. The drop down menu needs to be highlighted with just a colours. It works fine when the parent page isn't the current page. Can anyone help with this?
#navbar li.current_page_item a {
background:url(../images/activetab.png);
width:95px;
height:30px;
}
#navbar li li.current_page_item a {
background:#e9536c;
font-size:12pt;
width:150px;
color:black;
}
I'm pretty sure that your second selector is wrong. Try this code:
#navbar li.current_page_item a {
background:url(../images/activetab.png);
width:95px;
height:30px;
}
#navbar li.current_page_item li a,
#navbar li li.current_page_item a {
background:#e9536c;
font-size:12pt;
width:150px;
color:black;
}
This will target li's that are child elements of a current page item, and second(or more)-level li's that are current page items.
Maybe you can try this
#navbar li li.current_page_item a {
background-image:none;
background:#e9536c;
font-size:12pt;
width:150px;
color:black;
}
This should disable the background image in your dropdown menu.
Or use
background: #e9536c !important;
it will override your previous css style.