This is my first time on stackverflow and hope someone could help me with this kind of problem.
I made website in Wordpress and want to disable hover effect on my category list in webshop. There are parent categories which automatically, when you hover with mouse, dropdown child categories. After researching i found css solution which looks like this:
.widget.woocommerce.widget_product_categories ul li{
pointer-events:none;
}
Wordpress Customize Custom CSS,
After this kind of update i found the problem - when i click on parent category, nothing happens (because of pointer-events obviously).
Is there any CSS solution for this kind of problem?
Hello did you try the following, I think you can use the CSS to just disable to pointer event on hover:
.widget.woocommerce.widget_product_categories ul li:hover {
pointer-events: none;
}
Edit 1:
ok the functionality that you need can't be done with CSS alone, you will need a bit of Javascript.
Try to add the following code in theme javascript file
jQuery(".cat-item.cat-parent > a").click(function(event) {
event.preventDefault();
const ul_children = jQuery(this).parent().find('> ul.children');
if(jQuery(this).parent().hasClass('open')) {
jQuery(this).parent().removeClass('open')
ul_children.css('max-height',0)
} else {
jQuery(this).parent().addClass('open');
ul_children.css('max-height', ul_children[0].scrollHeight )
}
})
also add the following CSS:
.product-categories > .cat-parent:hover > ul.children {
max-height: 0px;
}
.product-categories li ul.children li:hover > .children {
max-height: 0px;
}
You should replace this code
.cat-parent:hover > ul.children {
max-height: 373px;
overflow-y: scroll;
overflow-x: hidden;
}
by this one
.cat-parent:active > ul.children {
max-height: 373px;
overflow-y: scroll;
overflow-x: hidden;
}
The only step left is to remove the link from your parent category. If you do not remove this link, it will redirect you automatically when you click on it
Simply we can hide container when in hover effect by Jquery such as
// remove popup on hover for mini cart dawar
$(".icon").hover(function(){
$("#container").css("display", "none");
});
Related
I am working on a site that that is supposed to display sub-menus when you hover over both the "References" and the "Contact Us" items in the main nav. However, these items will not display.
I have tried adding hover properties via CSS to the menu & sub-menu items but nothing seems to work. It seems to always default to the "display: none;" for the sub-menu.
Here is the URL for the site: http://fongconstruction.com
I'm not sure where to go from here, if there is a CSS fix that maybe I'm missing then any guidance would be helpful! Thanks in advance!
First you need to delete below css from custom.cs(line number 1) and style.css(line number 844) https://prnt.sc/15pru62
#nav .sub-menu {
display: block !important;
}
Also you need to delete inline style(display: none) from sub menu https://prnt.sc/15ps03v
After that add this css
#nav li ul.sub-menu {
display: none;
}
#nav li:hover ul.sub-menu {
display: block;
}
I was able to locate a solution by using a different selector that I had not thought of before:
#menu-item-5990 a:hover + .sub-menu,
#menu-item-5237 a:hover + .sub-menu {
display: block;
}
How Can I hide a content for specific page in css.
I find on the internet some solutions but they only valid for element's id.
This code is an example
.page-id-47 #header-image-id { display: none; }
I want to apply this on a class not id because some content does not have id I tried to use this but it does not work with me:
.page-id-47 #header-image-class-name { display: none; }
and also this code is hide the class for the whole website:
.class-name{
display:none;
}
Any help please?
Try using visibility: hidden, as shown below :-
.myClass{
visibility: hidden;
}
<div class="myClass">
<h1>hello</h1>
</div>
Use the following CSS
body .page-id-47 .header-image-class-name {
display: none;
}
After body give a space and type .page-id-47 .header-image-class-name {display: none;}
On the WordPress theme I am working on https://themes.getmotopress.com/2019/ the menu turns into a circle and excess menu items are put into this when the screen resolution decreases.
I would like to stop <div class="main-menu-more"> from showing and all elements become listed in the main container. I have used the code
.main-navigation .main-menu-more {
display:none;
}
Which hides the more menu however the elements inside do not show?
Try this style I hope this will work for you but you should have to upgrade style according to your requirement
#media (max-width:500px){
.submenu-expand{
display: none;
}
.main-navigation .sub-menu {
background-color: transparent;
position: relative;
opacity: 1;
left: 0;
}
.main-navigation .sub-menu > li > a, .main-navigation .sub-menu > li > .menu-item-link-return {
color: #0073aa;
}
.sub-menu:hover{
position: relative;
}
}
I checked out the source codes of the WordPress you are currently working and determined that by deleting the word "toggle" from class="submenu-expand main-menu-more-toggle is-empty" which will become class="submenu-expand main-menu-more is-empty" will no longer hide the menus in the circle, but will simply become part of the responsive webpage.
The code came from the button section of your WordPress. Simply search for the class attribute with a value of "submenu-expand main-menu-more-toggle" using the search function on your text editor and delete the word "toggle" from it. It worked for me.
Let me know how it went.
I have a menu, which is responsive, the only problem it has is with the sub-level, please check the example here
http://jsfiddle.net/6vp3U/409/
.sf-menu ul {
position:static !important;
display: none !important;
}
.xpopdrop ul {
display: block !important;
}
in above example, under "Item 2" there is another sub-menu under "item 2.1", that doesn't work according to the media query, I want this to work as other sub menus working, please drag the fiddle center area to see this in action.. I know it has something to do with the css "ul".. tried a lot, couldn't find a solution, I would appreciate if someone experienced with CSS can spend 5 minutes and help me fix this..
regards
I add two selectors:
.xpopdrop ul ul {
display: none!important;
}
.xpopdrop .xpopdrop ul {
display: block!important;
}
It seems like worked...
Fiddle
I want to make my wordpress menu items have 2 different background colors: one for the link and one for :hover. I'm a CSS beginner and found a solution but unfortunately it's not a good one because I target by the menu id generated by wordpress and if I delete the menu and create another one, that id will be gone and my styling will not work anymore.
Example:
menu-item-1212 a {
background-color:#fff;
}
menu-item-1212 a:hover{
background-color:#000;
}
Is there a more elegant way to solve this so that no matter what id the first menu item will have, it will retain that background-color and the hover one?
I've searched online for an alternative and found :nth-child. I did tried to create something like this:(but it didn't worked)
#menu-secondary li a:nth-child(1) {
background-color:#fff;
}
#menu secondari li a:hover:nth-child(1) {
background-color:#000;
}
Will appreciate any suggestion, thanks.
You are targeting an anchor which is the nth child of li element. Each li only has one anchor probably. You need to target li as the nth child of the menu, like this:
#menu-secondary li:nth-child(1) a {
background-color:#fff;
}
#menu secondari li:nth-child(1) a:hover {
background-color:#000;
}
You won't even need nth-child if you are using a common background color and common hover color..
#menu-secondary li a {
/* Styles goes here */
}
As you said you are not looking forward to use an id as it may be dynamic, than you can also select the elements using element selector if it's unique, like
div.class_name ul li a { /* class_name indicates your wrapper element class name */
/* Styles goes here */
}
Also be sure you make your anchor tag display: block; if you want to cover up entire li