I have a horizontal nav menu that I am working on. I have one issue left with this menu. When the user navigates to a page, I would like the main li to remain hovered. Right now, the li does not remain in a hovered state and simply reverts to default. Do I need to give the body a class to make this work or is there another way? The code snippet can be found here: http://jsfiddle.net/SeasonEnds/LSmfN/
Ideally, the Read tab should take on the hover styles upon on loading the page, but go away as the user hovers over the other main nav links.
The highlight on the active element shouldn't really disappear when the user hovers on another top-level link as this is bad for usability - if the user doesn't click on a link then they've lost the visual clue as to where they are on your site.
I've amended the css slightly:
ul#topnav li.on a {color:#828282; background: #f3f3f3; }
ul#topnav li a:hover {background: #f3f3f3; color:#828282;}
ul#topnav li a:visited {color:#828282; }
I've also added a bit of jQuery to keep the colour of the active top-level link as you hover over the children:
$("li a").hover(function(){
$(this).parent().prev().toggleClass("top-level-highlight");
});
Updated fiddle:
http://jsfiddle.net/LSmfN/14/
There's no way for the menu to know which page it's on without either the server setting the active menu element, or JS indicating the active element.
Here's what you can do - add a class "here" to indicate the current position:
ul#topnav li:hover, ul#topnav li.here {background: #f3f3f3;
Detect the current page using js:
//var here = document.location+"" //for production
var here = "/home.html" //for testing
if(here.indexOf("home.html")>-1) {
$('ul#topnav li').eq(0).addClass('here')
$('ul#topnav li').mouseout(function() {
$('ul#topnav li').removeClass('here')
})
} //repeat for all pages
Related
I am trying to design a button for a multi-lingual Wordpress site, in order to access the contact page. The problem appears when I click on it and access the target contact page. At this point the text in the button disappears, and only reappears when I hover over the button. The text appears normally in all the other pages, this only occurs when I access the target page. I will attach some screenshots below of the button working normally in other pages, how it looks when hovering over it and how it looks when accessing the contact page where the problem appears.
I have tried different codes for creating the button but the problems keeps appearing. Below is the code I am currently using.
.btn-class-eng{
border-radius: 50px;
padding: 0px 40px;
color: #ffffff;
border-color: #4064d7;
background-color: #4064d7;
}
.btn-class-eng a {
color:#fff;
}
.btn-class-eng:hover{
opacity:0.8;
color:#4064D7;
background-color:#3A3A3A;
}
I expect the text to appear on the button when not hovering over it, as it does in all the other pages.
Add the following CSS block, too:
.btn-class-eng a:visited, .btn-class-eng a:link {
color:#fff;
}
All visited links turn blue, by default, making the background and the text, both, blue. Hence, it looks as if the text disappeared.
a: visited makes sure that if the link is already visited, it still remains white in colour.
Corrected: as suggested by #04fs.
I have a tab based page that looks like the following when loaded:
After the page is loaded and the middle tab is selected, I get the following:
When I click anywhere on the page after the tab is selected, I get this:
I want the background color of the tab to be "pink" (#e12387) when selected. I am not sure why I have to click somewhere on the page for the color change to take place. This problem occurs when any of the tabs are selected.
EDIT
Just got to view the page on a computer. I have had this issue in the past when I use .active on some elements.
Try this...
li.nav-item a.nav-link.active:not(:active) {
background: #e12387
}
That should do the trick.
I hope this code help you out:
.pt-tabs ul li a{background-color:#000;color:#fff!important;text-decoration:none;}
.pt-tabs ul li a:active, .pt-tabs ul li a:focus{background-color:#e12387!important;text-decoration:none;}
.pt-tabs__content, .pt-tabs__content p{background-color:#e12387!important;}
I have backend dev background but newbie to CSS. Recently launched www.feisworld.com using an existing Wordpress template. Unfortunately I notice "HOME" in top nav, upper lefthand corner is not noticeable. I want to up the size to about 24px.
Then I notice after clicking on an article the HOME button is now in deep purple, even less readable! I tried to manipulate .navigation-main .a but the entire top nav changes - including About and Podcast.
I also played with .navigation-main .current-menu-item.home-link > a, .navigation-main .current-page-item.home-link > a, with no luck.
Can someone please advice what I'm missing here and why HOME behaves differently depending on the page?
Thanks!
You should be able to change it using :
#menu-item-4 > a {
font-size: what-you-want;
}
#menu-item 4 > a:visited { /*For the link color after you click it */
color : what-you-want;
}
try to use !important tag.
.home-link { font-size: 24px !important }
I'm designing a new website, but I currently have the following problem:
In the menu, when the I open a page with a sub menu, and then hover a menu item without sub menu I want to display an empty gray bar. But I've got no clue how to do this.
To reproduce this go to this page: http://www.kvvikingvenlo.nl/joomla/nl/aluminium-gietwerk.html and then hover over the home item in the menu. (Home has no sub menu, so I want the gray bar to be empty.)
Edit
I'm sorry, my question seems to be quite hard to understand. Lets try again:
On the web page http://www.kvvikingvenlo.nl/joomla/nl/aluminium-gietwerk.html there is a menu which is always displays the current sub menu, until you hover a different sub menu. This part is already working.
But when you hover Home, you will still see:"ONTWIKKELING, HOGEDRUK SPUITGIETEN, CNC-NABEWERKING and MONTAGE".
These are the sub menu items of the parent "Processen" (which is the current active one)
Because home does not have any sub menu items, i want this bar to be empty instead.
i think you would have to do this through javascript, you have you .active on your ul and that is the parent you your li what is the parent to your a so in order to change the child tag to display as .active you would do this through javascript. i hope that makes sense.
If I understood correctly, if there is no submenu to the menu section, you just want to display the grey bar beneath.
This menu is being done with nested UL and LI tags with CSS, it is a very common technique.
I should warn you though, that the effect in the page you linked doesn't do what you need in IE <9. There are a few pure CSS menu examples that achieve this purpose quite easily.
If you don't want (or know) how to change it because it would mean messing with Joomla's inner workings, what I think you can do is: first create an empty SPAN inside a "fake" LI under HOME, then, set that specific (via class or id attribute in the HTML) SPAN with width equal to the gray bar. then set display:block; to the SPAN. This has to be done when the :hover event occurs in the parent class of the SPAN.
For example:
If you set the class of the SPAN tag to hideme:
.menumenu li ul li .hideme {
width: [width of the grey bar];
}
.menumenu li:hover ul li .hideme { display:block; }
It's not pretty, but it should work.
EDIT I had the right idea, but wrong execution (too early in the morning)
What you actually need is to give a unique identifier to a fake UL under the HOME LI (ie fakeUL), nest a LI inside of it to hold a SPAN tag, define the size of that SPAN tag with the width property, and then the CSS could be something like:
.menumenu li .fakeUL li span {
width: [width of the grey bar];
}
.menumenu li:hover .fakeUL li span { display:block; }
I ended up in making a template override in joomla so that it inserted an empty ul tag in the menu. I thought this would be the cleanest option I had.
To make a template override copy the file \modules\mod_mainmenu\tmpl\default.php to \templates\YOURTEMPLATE\html\mod_mainmenu\default.php
Then find this code in the file you copied:
if (isset($path) && $node->attributes('id') == $path[0]) {
$node->addAttribute('id', 'current');
} else {
$node->removeAttribute('id');
}
$node->removeAttribute('rel');
$node->removeAttribute('level');
$node->removeAttribute('access');
And add these lines just BEFORE them.
if (($node->name() == 'li') && !isset($node->ul)) {
$node->addChild('ul ');
$node->addChild('/ul');
}
Hope I helped anyone!
I have a basic menu and some of the menu items have submenus.
I have very little experience with wordpress and don't have time to dive deeper into the details right now. So my question is, what is the simplest way to highlight the top menu item when the use navigates to one of the submenu pages. (I tried using both javascript and also pure css to set the color property by element id and by using the "current-cat-parent" class but neither worked).
Any help is greatly appreciated.
Note: I am using a theme called chameleon.
you can assign current-menu-item class to .current-menu-ancestor class like
.main_menu li.current-menu-item a, .main_menu li.current-menu-ancestor a{
color: #777777 !important; /* highlight color */
}
It will highlight parent page menu
Please refer this page
You can insert the following code in the theme’s footer.php file right before the closing body tag .
<!-- Highlight parent page link when on child page -->
<?php if (is_page()) { // displaying a child page ?>
<script type="text/javascript">
jQuery("li.current-page-ancestor").addClass('current-menu-item');
</script>
<?php } ?>
The beauty of this is its in PHP so the code's dynamic. What it does is simply add another native WordPress nav li class that makes the link of the current page active.
I wrote a short post here explaining how it works: How to keep parent page navigation link highlighted when viewing a child/sub page!
Feel free to let me know if you have questions about it.
I had a bit of a problem editing this but found an easy solution.
I am using the Wordpress Storefront theme, just paste this into your child theme's style.css file:
li.current-menu-parent >a {
color:red !important;
}
Interesting. Your solution highlighted the parent but not the current child. But it put me on the right path and in the end, this was what I needed.
li.current-menu-parent >a, .current-menu-item >a {
color: red !important;
}
WordPress 5.7
Tested and Working, 2021
Year 2021. If any of you still looking for the solution, then here it is.
This will highlight the parent and its child. If no child menu then the parent will get highlighted. Remember !important is required.
.current-menu-parent > a,
.current-menu-item a {
color: blue !important; /* Important is required */
}
.current-menu-ancestor did not work for me. .current-page-ancestor did.
This worked for me. The following CSS will allow you to style the active menu... down to three menus deep.
.current-menu-ancestor{ background:RED !important; }
.current_page_parent{background:GREEN !important;}
.active{background:YELLOW !important;}
The menu button that represents the currently active page will be
YELLOW,
If the button representing the currently active page is nested, its
parent will be GREEN... else the Top-Level button on your menu will be GREEN.
And most importantly (no matter how many levels of nesting appear in
your menu) Any element with a class of .current-menu-ancestor
will be styled with a RED background.
It is also possible to ONLY style the .current-menu-ancestor and any parent menu-item will be styled.