A particular nested list, with parent div id and list items with different class... I can't make it to assign correctly background colors.
For example:
<div id="sidebar" class="widget-area">
<div class="theiaStickySidebar">
<aside id="advanced_sidebar_menu-2" class="widget advanced-sidebar-menu">
<ul class="parent-sidebar-menu">
<li class="current_page_ancestor">
About Us
<ul class="child-sidebar-menu">
<li class="page_item">
Welcome
</li>
<li class="page_item current_page_item">
Mission and philosophy
</li>
</ul>
</li>
</ul>
</aside>
</div>
What CSS code would you use to change background colour of each li/a item belonging to class current_page_ancestor, page_item and current_page_item(each one should have different colors)
For first a you can use > or direct-child selector and for others you can just select with parentClass->a
.current_page_ancestor > a {
color: black;
}
.page_item a {
color: green;
}
.page_item.current_page_item a {
color: red;
}
<div id="sidebar" class="widget-area">
<div class="theiaStickySidebar">
<aside id="advanced_sidebar_menu-2" class="widget advanced-sidebar-menu">
<ul class="parent-sidebar-menu">
<li class="current_page_ancestor">
About Us
<ul class="child-sidebar-menu">
<li class="page_item">
Welcome
</li>
<li class="page_item current_page_item">
Mission and philosophy
</li>
</ul>
</li>
</ul>
</aside>
</div>
ul {
/* reset lists */
list-style: none;
padding: 0;
margin: 0;
}
ul li a {
text-decoration: none;
}
/* specific styles */
.page_item a {
display: block;
padding: 10px 20px;
border-bottom: 1px solid white;
color: white;
background-color: #333;
}
.page_item a:hover,
.page_item.current_page_item a{
background-color: #666;
}
.parent-sidebar-menu {
width: 200px;
}
.current_page_ancestor > a {
display: block;
padding: 10px 20px;
color: green;
background-color: #fff;
text-align: right;
}
.current_page_ancestor > a:before {
content: "Back to >> ";
font-size: 14px;
color: #000;
margin-right: 10px;
}
<div id="sidebar" class="widget-area">
<div class="theiaStickySidebar">
<aside id="advanced_sidebar_menu-2" class="widget advanced-sidebar-menu">
<ul class="parent-sidebar-menu">
<li class="current_page_ancestor">
About Us
<ul class="child-sidebar-menu">
<li class="page_item">
Welcome
</li>
<li class="page_item current_page_item">
Mission and philosophy
</li>
</ul>
</li>
</ul>
</aside>
</div>
</div> <!-- #sidebar -->
This is slightly different in that instead of using each class to do something different I am using similar things to do the same thing and changing based on state change. The ancestor page is treaded differently than the child sidebar menu. Hope this helps.
Related
It seemed to me a job for a minute, when a friend asked me to fix this. After the update of the mesmerize theme, the footer was set to default and she wanted it to be changed again. Everything went fine except: the a:hover of the footer didn't work. I couldn't fix it eighter.
I changed the CSS to:
/* Footer Link-Farbe*/
.footer a {
color: var(--color-primary);
}
/* Footer Hover-Farbe*/
.footer a:hover {
color: var(--color-primary-light);
}
and also tried:
/* Footer Link-Farbe*/
.footer a:link, .footer a:active, .footer a:visited {
color: var(--color-primary);
}
/* Footer Hover-Farbe*/
.footer a:hover {
color: var(--color-primary-light);
}
In the firefox developer tool i can see the link-color is working:
screenshot of developer-tool
But the :hover is not there.
But if I add the hover-rule to the developer-tool it works:
screenshot of developer-tool with css edited
I'm really lost. I hope somebody can help.
The domain ist: www.ubuntu-ubuntu.at
Have you tried using a more specific selector for the hover style?
Sorry the domain you provided, didn't work so i don't know how the markup looks, but something like this:
.footer .horizontal_footer_menu ul li a:hover {
color: var(--color-primary-light);
}
Or try to use !important just to get things done.(It's not really recommended)
.footer a:hover {
color: var(--color-primary-light) !important;
}
You have do declare variable in ":root" after you can use or chnage in your css classs.
in word press the backend option allow you to change footer link color using "var".
you have to change option in wordpress backend settings.
OR
You can use ":root" for overrite default settings.
:root {
--color-primary: #3f51b5;
--color-primary-light: #1e90ff;
}
.footer .horizontal_footer_menu ul li {
display: inline-block;
}
.footer .horizontal_footer_menu ul li a {
text-decoration: none;
padding: 10px;
}
/* Footer Link-Farbe*/
.footer a {
color: var(--color-primary);
}
/* Footer Hover-Farbe*/
.footer a:hover {
color: var(--color-primary-light);
}
<div class="footer">
<div class="horizontal_footer_menu">
<ul>
<li>Home</li>
<li>About us</li>
<li>Contact us</li>
</ul>
</div>
</div>
Try Using this HTML code for wordpress footer hover. I have tried this in my E-commerce wordpress store and it worked fine.
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
#footer{background:#fff;position:relative}
.footerLogo { font-size: 1.8em; font-weight: 600; color: #333; margin-bottom: 22px; display: block; }
#footer::before{content:"";background:linear-gradient(to right,#fff 0,#535df1 50%,#fff 100%);height:5px;width:100%;position:absolute}
.footer-wrapper{padding:50px 0;float:left;width:100%}
img.footer-logo{margin-bottom:20px}
ul.social-icons{margin:0; padding: 0;}
ul.social-icons li{background:#fff;width:30px;height:30px;border:1px solid #f1f2f2;border-radius:4px;margin:3px;text-align:center; display: inline-block;}
ul.social-icons li a{color:#6d6e71;font-size:15px;line-height:30px}
ul.social-icons li a:hover{color:#27aae1;transition:all 1s}
ul.footer-links { padding: 0; list-style-type: none; position: relative;}
ul.footer-links li{line-height:25px; padding-left: 15px; }
ul.footer-links li:before { position: absolute; content: 'f105'; font-family: FontAwesome; left: 0;}
ul.footer-links li a{color:#6d6e71}
ul.footer-links li a:hover{color:#27aae1; text-decoration: none;}
ul.contact{margin:0;padding:0}
ul.contact li{list-style:none;padding:15px 0;border-bottom:1px solid #f1f2f2;font-size:13px;font-weight:600;line-height:15px;}
ul.contact li i{font-size:18px;margin-right:20px;color:#27aae1}
.copyright{background:#231f20;text-align:center;color:#fff;padding:12px 0 4px}
</style>
<footer id="footer" class="bg-light mt-5">
<div class="container">
<div class="footer-wrapper">
<div class="row">
<div class="col-md-3 col-sm-3">
Company
<ul class="social-icons">
<li><i class="fa fa-facebook"></i></li>
<li><i class="fa fa-twitter"></i></li>
<li><i class="fa fa-xing"></i></li>
<li><i class="fa fa-pinterest"></i></li>
<li><i class="fa fa-linkedin"></i></li>
</ul>
</div>
<div class="col-md-2 col-sm-2">
<h5>For individuals</h5>
<ul class="footer-links">
<li>Signup</li>
<li>login</li>
<li>Explore</li>
<li>Finder app</li>
<li>Features</li>
<li>Language settings</li>
</ul>
</div>
<div class="col-md-2 col-sm-2">
<h5>For businesses</h5>
<ul class="footer-links">
<li>Business signup</li>
<li>Business login</li>
<li>Benefits</li>
<li>Resources</li>
<li>Advertise</li>
<li>Setup</li>
</ul>
</div>
<div class="col-md-2 col-sm-2">
<h5>About</h5>
<ul class="footer-links">
<li>About us</li>
<li>Contact us</li>
<li>Privacy Policy</li>
<li>Terms</li>
<li>Help</li>
</ul>
</div>
<div class="col-md-3 col-sm-3">
<h5>Contact Us</h5>
<ul class="contact">
<li><i class="fa fa-phone"></i>+1 (234) 123 1234</li>
<li><i class="fa fa-envelope-o"></i>info#company.com</li>
<li><i class="fa fa-home"></i>123 Any street second floor, INDIA</li>
</ul>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="copyright">
<p>Company © 2019. All rights reserved</p>
</div>
</footer>
I took this code from https://webdesignerwall.com/wdw-snippet/footer-with-hover-effects Aesthetic outfits
You can learn more about this issue in another thread I found:
https://wordpress.org/support/topic/footer-hover-link-wont-change/
Very basic CSS issue as I can't get the current page to look different in menu. Any suggestion greatly appreciated!
Here is the genesis function
//* Add My New Menu
function my_new_menu() {
echo '<ul class="menu gn responsive-menu">
<li class="menu-item"> New Joke Book!</li>
<li class="menu-item"> Kids Jokes </li>
<li class="menu-item"><a href="/animal-jokes/"> Animal Jokes /a></li>
<li class="menu-item"> Zoo Jokes </li>
<li class="menu-item"> Contest </li>
</ul>';
}
add_action( 'genesis_header_right', 'my_new_menu' );
Here is the CSS
.gn a {
border: 1px solid transparent;
border-radius: 3px;
color: #438ed9;
display: block;
font-weight: 400;
height: auto;
line-height: 1;
margin-top: 0.2rem;
padding: 0.8rem 1rem;
position: relative;
text-decoration: none;
}
.gn a:hover,
.gn .current-menu-item > a,
.gn .sub-menu .current-menu-item > a:hover {
color: #fff;
background-color: #009900;
}
The easiest solution is to add your ".current" class to the corresponding "li" item.
So, for example if you are on the "kids-joke-book" page your "ul" should look like this:
<ul class="menu gn responsive-menu">
<li class="menu-item current"> New Joke Book! </li>
......
</ul>
You should do this method on every single subpage of your site where you use this menu, and add the "current" class to the correct menu item.
("current" class is an example name, it has the styles what you would like to add to the right menu item.)
I am trying to use two Twitter Bootstrap navs on the same page. I have written some css to style them. Problem is, I want the css to apply to just one of the navs. I tried to use css ids to distinguish the two navs, but am having trouble getting the selectors right. Can anyone help?
Here's a simplified version of what I'm trying to do: http://jsfiddle.net/XVReX/
HTML:
<div id="something" class="navbar">
<div class="navbar-inner">
<div class="container">
<ul class="nav">
<li id="selectEventStep"><a>Select Event</a>
</li>
<li id="selectPriceStep"><a>Select Price</a>
</li>
<li id="confirmSwapStep"><a>Confirm Swap</a>
</li>
</ul>
</div>
</div>
</div>
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<ul class="nav">
<li id="selectEventStep"><a>Select Event</a>
</li>
<li id="selectPriceStep"><a>Select Price</a>
</li>
<li id="confirmSwapStep"><a>Confirm Swap</a>
</li>
</ul>
</div>
</div>
</div>
CSS:
#something.navbar #something.navbar-inner {
padding: 0;
background-image: -webkit-linear-gradient(top, #E5665D, #C4564F);
}
#something.navbar #something.nav li a {
font-weight: bold;
text-align: center;
color: #FFE2E0;
text-shadow: 0 1px 0 #000;
;
}
#something.navbar #something.nav li a:hover {
color: #fff;
}
Thanks!
The selectors are more complicated than necessary and the syntax is incorrect - you can override bootstrap.css by instead using:
#something .navbar-inner { }
#something .nav li a{ }
#something .nav li a:hover { }
jsFiddle
I rewrote the entire style sheet to apply the style only on those elements with a class name .bootstrap using sass compiler and regular expression which looks like this
audio.bootstrap:not([controls]) {
display: none;
}
html.bootstrap {
font-size: 100%;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
a.bootstrap:focus {
outline: thin dotted #333;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
I haven't checked everything but I think it works alright.
http://jsfiddle.net/Lc5h6/
When trying to add an box with content inside it on a menu on a hover "drop down menu", it does something like this:
(source: gyazo.com)
I want the drop down to popup when I hover on the categories menu item.
This is the code I used for it:
<div class="secondheader">
<div class="container">
<div class="span12">
<ul class="nav6">
<li>Home</li>
<li class="dropdown1">Categories </li>
<li>Buy</li>
<li>Sell</li>
<li>Forums</li>
<li>Contact</li>
<li>item 1</li>
<li>Forums</li>
<li>Contact</li>
<li>item 1</li>
</ul>
</div>
</div>
</div>
</div>
The CSS:
.secondheader {
background-image: url("../img/second.png");
width: 100%;
height: 66px;
border-bottom: solid 6px #f0e8ce;
}
.nav6 {
list-style: none;
font-family: 'Dosis', sans-serif;
float: left
font-size: 20px;
margin-top: 13px;
margin-left: -35px;
}
.nav6 li {
display: inline;
margin: 0px;
font-size: 18px;
font-family: 'Dosis', sans-serif;
float: left;
margin-top: 10px;
}
.nav6 a {
color: #7d7253;
padding-top: 20px;
padding-bottom: 20px;
padding-left: 20px;
padding-right: 20px;
}
.nav6 a:hover {
background-image: url("../img/hoverbg.png");
color: #53410f;
text-decoration: none;
}
I've tried using tutorials but I don't really understand on how to make the same thing for my layout I mean it has different ways and classes.
Do you want something like http://jsfiddle.net/b76Qc/?
Edit:
In your case the submenu is horizontal because you use descendant selectors instead of child selectors:
replace .nav6 li with .nav6>li and .nav6 li ul with .nav6>li>ul
See my jsfiddle if you want the complete code.
Edit 2:
If you want each element to have a different background,
<li class="dropdown1">Categories
<ul>
<li style="background:red">Buy</li>
<li style="background:blue">Sell</li>
<li style="background:green">Forums</li>
...
</ul>
</li>
But can you provide a link to your site instead of images? The square shown in http://gyazo.com/35835f003d0d8b776248196632cc1d4a.png is weird, but I can't know what's happening just with images...
Edit 3:
You have to change
.nav6 a {
color: #7D7253;
padding: 20px;
}
into
.nav6>li>a {
padding: 20px;
}
.nav6 a {
color: #7D7253;
}
And
.nav6 a:hover {
background-image: url("../img/hoverbg.png");
color: #53410F;
text-decoration: none;
}
into
.nav6 a:hover {
color: #53410F;
text-decoration: none;
}
.nav6 > li > a:hover {
background-image: url("../img/hoverbg.png");
}
Edit 4:
Sorry I didn't explain why I was telling you to use selectors with >, I thought you knew it.
Your html is like this:
<ul class="nav6">
<li>Home</li>
<li class="dropdown1">Categories
<ul>
<li>Buy</li>
<li>Sell</li>
<li>Forums</li>
<li>Contact</li>
<li>item 1</li>
<li>Forums</li>
<li>Contact</li>
<li>item 1</li>
</ul>
</li>
</ul>
If you use .nav6 a, the style will be applied to all <a> inside .nav6. That's a descendant selector.
Then, this will be applied both to menu's links and submenu's links:
<ul class="nav6">
<li>Home</li>
<li class="dropdown1">Categories
<ul>
<li>Buy</li>
<li>Sell</li>
...
</ul>
</li>
</ul>
But if you use a child selector like .nav6>li>a, the style is applied only to the links which are childs of a <li> which is a child of .nav6 (only menu's links). This way we can set which styles we want to apply to all links and which to menu's links:
<ul class="nav6">
<li>Home</li>
<li class="dropdown1">Categories
<ul>
<li>Buy</li>
<li>Sell</li>
...
</ul>
</li>
</ul>
Edit 5:
To fix the problem with backgrounds,
change
.nav6 a:hover {
color: #53410F;
text-decoration: none;
}
to
.nav6>li:hover>a, .nav6 .dropdown1 li:hover>a {
color: #53410F;
text-decoration: none;
}
and
.nav6 > li > a:hover
background-image: url("../img/hoverbg.png");
}
to
.nav6>li:hover>a {
background-image: url("../img/hoverbg.png");
}
To show you how little code is actualy required to make this work i set up a small example here: http://jsfiddle.net/fS5WV/
I put the explanations in the css.
The key lies in nesting the menu's properly, and giving the submenus a position absolute to prevent them from pushing the content down.
I hope it makes sense. Feel free to ask if you need further explanation.
I'm trying to create a horizontal list from a nested list markup, as an example I have the current markup:
<ul>
<li class="alone">List Item 1</li>
<li class="alone">List Item 2</li>
<li class="alone">List Item 3</li>
<li class="group">List Item 4
<ul>
<li class="not_alone">List Item 4a</li>
<li class="not_alone">List Item 4b</li>
<li class="not_alone">List Item 4c</li>
<li class="not_alone">List Item 4d</li>
</ul>
</li>
<li class="alone">List Item 5</li>
</ul>
I would like to achieve something similar to this:
<style>
div { display: inline-block; }
.alone { background: #E5ECF9; border: 1px solid #336699; color: #336699; }
.group { background: #FBE3E4; border: 1px solid #CC0000; color: #CC0000; }
.group .not_alone { background: #FBE3E4; border: 1px solid #CC0000; color: #CC0000; }
.item { padding: 2px; margin: 0 2px; }
</style>
<div class="wrapper">
<div class="alone item">List Item 1</div>
<div class="alone item">List Item 2</div>
<div class="alone item">List Item 3</div>
<div class="group item">
List Item 4
<div class="group item">List Item 4a</div>
<div class="group item">List Item 4b</div>
<div class="group item">List Item 4c</div>
<div class="group item">List Item 4d</div>
</div>
</div>
<div class="alone item">List Item 5</div>
</div>
You can see a demo here http://jsbin.com/exivi5.
Is this possible using the existing nested list markup? Also, can I also keep the width of the ul parent list to 100% so it fits the entire viewport?
This needs to be compatible in FF, Webkit and IE7+ but will settle for IE8+ support.
Thanks in advance!
try adding these css rules:
ul {list-style: none; margin: 0; padding: 0; float:left; display: inline;}
ul li {float:left; display: inline; margin: 0 5px; padding: 3px 2px;}
ul li ul {float:right;}
h2 {clear: left;}
with a bit of fiddling with margins & paddings it should look the same as yours
Try this (requires jQuery):
var wrapper = $("body").append("<div id='wrapper'></div>").find("#wrapper");
var lis = $("ul > li");
lis.each(function() {
var li = $(this);
if (li.hasClass("alone")) wrapper.append("<div class = 'alone item' >" + li.text() + " </div>");
else if (li.hasClass("group")) {
var html = "<div class='group item'>";
li.find("li").each(function() {
html += "<div class = 'group item' >" + $(this).text() + " </div>";
});
html += "</div>";
wrapper.append(html);
}
});
Demo: http://fiddle.jshell.net/EJZMS/show/light/
Code: http://fiddle.jshell.net/EJZMS/
My code is not recursive: If you have more than one level of nesting, you will need to modify it yourself.
If you add the style
display:block;
The li's will render as block level elements, and you should then be able to style them up just like the Div based example. You might need to float them left to get them next to each other exactly like your example page. (or use inline-block instead of block perhaps)
Try this (I haven't tested this as I'm on my little laptop - this is based on memory / guesswork)
<style>
#horizontallist li { display: block; float:left; }
.alone { background: #E5ECF9; border: 1px solid #336699; color: #336699; }
.group { background: #FBE3E4; border: 1px solid #CC0000; color: #CC0000; }
.group .not_alone { background: #FBE3E4; border: 1px solid #CC0000; color: #CC0000; }
.item { padding: 2px; margin: 0 2px; }
</style>
<ul id="horizontallist">
<li class="alone item">List Item 1</li>
<li class="alone item">List Item 2</li>
<li class="alone item">List Item 3</li>
<li class="group item">List Item 4
<ul>
<li class="group item">List Item 4a</li>
<li class="group item">List Item 4b</li>
<li class="group item">List Item 4c</li>
<li class="group item">List Item 4d</li>
</ul>
</li>
<li class="alone">List Item 5</li>
</ul>