Editing a particular element in inactive/hover/active states - html

I am using the Foundation framework for my website and the following code is what I'm focusing on in my HTML file:
<nav class="top-bar" data-topbar role="navigation">
<ul class="title-area">
<li class="name">
<h1>jDispatch</h1>
</li>
<li class="toggle-topbar menu-icon">
<span>Menu</span>
</li>
</ul>
<section class="top-bar-section">
<ul class="right">
<li class="has-dropdown">
Menu
<ul class="dropdown">
<li>Link one</li>
<li>Link two</li>
</ul>
</li>
</ul>
</section>
</nav>
I am wondering how do I edit the dropdown button itself (which has text 'Menu') and edit it for all of its possible states (inactive, hovered over, and clicked on)?
By inspection of the code on Foundation's actual website (which of course uses their own framework), I have been able to modify the inactive and hovered over states with the following CSS code respectively:
/* inactive/not hovered or clicked */
.top-bar-section li:not(.has-form) a:not(.button) {
background: yellow;
color: blue;
}
/* hovered over */
.top-bar-section li:not(.has-form) a:not(.button):hover {
background: green;
color: yellow;
}
I figured .top-bar-section li:not(.has-form) a:not(.button):active {...} would do the trick, but it didn't.
EDIT: Also how do I change the font-family of the dropdown items? Using .top-bar-section ul li > a {...} I can change the text color of the 'Menu' button and all of its dropdown items with color, but using font-family only changes the font for the 'Menu' button.

.top-bar-section li:not(.has-form) a:not(.button):active {...} will change the style for 'Menu' when clicked on.
But if 'Menu' is also linking to another page, you will only see the styles on active for a second, if you see them at all before the new page loads.
Check out the codepen demo here
.top-bar-section li:not(.has-form) a:not(.button):active {
background-color: blue;
color: white;
}

Related

CSS style links not working with my navigation links

Trying to change colors when hovering over navigation links, never had a problem before but it will not work.
I have my navigation in several div's, I tried to set my a link style to all divs, nothing changes at all. I originally made my code in a CSS class. Trying to make a responsive website at home, didn't have links in the navigation bar originally, just text.
a.navBar:link {color: white; text-decoration: none; }
a.navBar:visited {color: white; text-decoration: none; }
a.navBar:hover {color: #16262E; text-decoration: underline; }
a.navBar:active {color: white; text-decoration: underline; }
<div id="outerWrapper"> </div>
<div id="navWrapper">
<div id="navInnerWrapper">
<div id="navBar">
<ul>
<li>About</li>
<li>Our Work</li>
<li>Contact Us</li>
</ul>
</div>
</div>
</div>
I just want white text as navigation links that turn #16262E when the mouse is hovering over the link. Not receiving any errors, it just doesn't change from the default blue, underlined links.
a.navBar means that you are selecting a link tag wich have class 'navBar'. This selector does not exist.
No link tag have a class navBar.
To solve this you can apply color changing when you hover the list tag.
Use this selector :
#navBar ul li:hover a {color : #000fff}
This means that when you hover li (which is located inside #navBar) change the link color
Step 1
Remove a from starting of a.navBar.
Step 2
Change .navBar to #navBar you are declaring id attribute in element <div id="navBar">.
Step 3
Add space and a between #navbar and Pseudo-elements.
Below code snippet have all above mentioned fixes. Try this I hope it'll help you out. Thanks
body {
background-color:grey;
}
#navBar a:link {color: white; text-decoration: none; }
#navBar a:visited {color: white; text-decoration: none; }
#navBar a:hover {color: #16262E; text-decoration: underline; }
#navBar a:active {color: white; text-decoration: underline; }
<div id="outerWrapper">
<div id="navWrapper">
<div id="navInnerWrapper">
<div id="navBar">
<ul>
<li>About</li>
<li>Our Work</li>
<li>Contact Us</li>
</ul>
</div>
</div>
</div>
<body>
<ul>
<li><a class="navBar" href="#">About</a></li>
<li><a class="navBar" href="#">Our Work</a></li>
<li><a class="navBar" href="#">Contact Us</a></li>
</ul>
</body>
I have removed other div which are not nested properly.
Now put CSS inside "style" tag.
I will suggest to change either text-color or background-color, as text isn't visible on white background.

Not able to apply display property on li element

i am a newbie to CSS,HTML and trying to understand lists.however something confuses me .As you can see below my HTML i am trying to create a drop down navigation bar.what i don't understand is why would display property won't work on a single li element.
.block1{background-color:#736570;margin:0px;}
ul a {color:white;}
ul li{list-style-type: none; padding:5px;}
.hidden {display:none;}
.home:hover .hidden{display:block;}
.hidden a:hover{background-color: #f1f1f1;}
<body>
<ul class="block1">
<li class="home">Home
<li class="hidden">
contact us
</li>
<li>about<li>
<li>Investor</li>
<li> what we do</li>
</li>
</ul>
</body>
Here is the new css you should use:
.block1{background-color:#736570;margin:0px;}
ul a {color:white;}
ul li{list-style-type: none; padding:5px;}
.hidden{display:none;}
.home:hover + .hidden{display:block;}
li:hover{background-color: #f1f1f1;}
Then your html should look like this:
<body>
<ul class="block1">
<li class="home">Home</li>
<li class="hidden" >
contact us
</li>
<li>about</li>
<li>Investor</li>
<li> what we do</li>
</ul>
</body>
Nothing too wrong with your html, just a mismatch <li>, and the css you want to look at this post: Using only CSS, show div on hover over <a>
Here is the JSFiddle: Example of OP Code
i don't understand is why would display property won't work on a
single li element.
The div with class .home is not the parent of li tag with class hidden. Hence it will never trigger a hover over that. Whenever you trigger a hover over a parent container it trickles down and find its children and does some sort of styling.
In your case, you are trying to use display:none to hide a li and make it display by means of hover.
Consider the snippet below, whenever you hover over the parent container, the li tag is being displayed. (This approach below does not make a drop down menu for you but it is give you some insight how to make that display property change on hover)
.block1 {
background-color: #736570;
margin: 0px;
}
ul a {
color: white;
}
ul li {
list-style-type: none;
padding: 5px;
}
.hidden {
display: none;
}
.block1:hover .hidden {
display: block;
}
.hidden a:hover {
background-color: #f1f1f1;
}
.home
<html>
<body>
<ul class="block1">
<li class="home">Home
<li class="hidden">
contact us
</li>
<li>about
<li>
<li>Investor</li>
<li> what we do</li>
</li>
</ul>
</body>
</html>

Zurb Foundation change top-bar colour

I am having trouble changing the top-bar section of a Foundation site to a different colour.
I have created a custom style.css for this.
I can change most of the top-bar color but NOT the right hand drop down list side (I don't have a list on the left). Clicking a link on the drop down changes colour of the nav bar but the nav bar component at the top does not change other than this (hope this makes sense?)...
This is the basic HTML:
<section class="top-bar-section">
<!-- Right Nav Section -->
<ul class="right">
<li class="divider"></li>
<li class="has-dropdown">
Sections
<ul class="dropdown">
<li>####</li>
<li class="divider"></li>
<li>####</li>
<li class="divider"></li>
<li>####</li>
<li class="divider"></li>
<li>#####</li>
<li class="divider"></li>
</ul>
</li>
<li class="has-dropdown">
Links
<ul class="dropdown">
<li>####</li>
<li class="divider"></li>
<li>####</li>
<li class="divider"></li>
<li>####</li>
<li class="divider"></li>
</ul>
</li>
</ul>
</section>
This is my attempt at changing it using style.css:
#charset "UTF-8";
.top-bar {
background-color: #2D4DC7;
}
.top-bar-section ul {
background-color: #2D4DC7;
}
.top-bar-section ul.right {
background-color: #2D4DC7;
}
.top-bar-section li a:not(.button) {
background-color: #2D4DC7;
}
.top-bar-section ul li.active > a {
background-color: #2D4DC7;
/** Changes the hover state of non active menu items **/
.top-bar-section li:hover a {
background-color: #2D4DC7;
}
.top-bar-section ul li > a {
background-color: #2D4DC7;
}
.top-bar-section ul.dropdown li a:hover:not(.button) {
background-color: #2D4DC7;
}
.top-bar-section ul.dropdown {
background-color: #2D4DC7;
}
.top-bar-section .has-dropdown > a:after {
background-color: #2D4DC7;
}
I am pretty sure it is just syntax that I am having issues with. Something to do with the 'right' class I think???
Any help please?
Many Thanks
I strongly suggest you use a browser such as Firefox with Firebug installed.
Load any page, hit Tools > Web Developer > Inspector (or its hot key equivalent), then click on your object, the HTML code inspector will reference the exact line of the css file that is governing the style being generated (either the style directly, or the computed style).
Time and sanity saver.
After several attempts and some help from Zurb support the CSS i needed was:
.top-bar-section .dropdown li:not(.has-form) a:not(.button) {
color: white;
background: #740707;
}
Thanks for the help
If you use the SCSS/SASS version of foundation you should change the defaultvalues for the topbar.
The defaultsettings are stored in _settings.scss.
For example to change it to cornflowerblue I used these settings:
$topbar-bg-color: cornflowerblue;
$topbar-bg: $topbar-bg-color;
$topbar-link-bg-hover: scale-color($topbar-bg, $lightness: -14%);
$topbar-link-bg-active: $topbar-bg;
$topbar-dropdown-bg: $topbar-bg;
$topbar-dropdown-link-bg: $topbar-bg;
$topbar-dropdown-link-bg-hover: scale-color($topbar-bg, $lightness: -14%);

Dropdown menu items inheriting parent menu item border CSS issue

I have created a drop down menu however i have an issue with some of the sub menu items inheriting the CSS of the parent menu item.
In particualr, the sub menu items are inheriting the blue border of the parent, and the light blue background colour when hovering over the sub menu item.
I have added a red border, and can see that, but the blue still appears, also, i have added a 'red' hover class but this is not being triggered.
Here is my fiddle: http://jsfiddle.net/oampz/W2zrn/
HTML:
<nav class="site-nav">
<ul class="menu-nav wrap menu menu--hor">
<ul id="main-nav">
<li class="menu-nav--home">
</li>
<li id="nav-dropdown" class="drop-down"> <a>Link 1</a>
<ul class="visuallyhidden">
<li>
Link Two Sub One
</li>
<li>
Link Two Sub Two
</li>
<li>
Link Two Sub Three
</li>
</ul>
</li>
<li><a>Link 2</a>
</li>
</ul>
</ul>
</nav>
To remove the sub menu items inhering the blue border of the parent, change this
.menu-nav li li a, .menu-nav a {
border-right: 1px solid #0d63ba;
}
to
.menu-nav > li a {
border-right: 1px solid #0d63ba;
}
What this does is apply the blue border only to the anchor tags of the immediate child elements(li items) of the ul menu-nav.
For the red background hover to happen change this
.drop-down ul li:hover {
background-color: red;
}
to
.drop-down ul li:hover a {
background-color: red;
}
check out this i have updated your fiddle
http://jsfiddle.net/W2zrn/5/
added small code
#nav-dropdown li a {
border: medium none;
padding: 0 0 0 10%;
width:100%;
}
#nav-dropdown li {
width: 100%;
border: none;
}

navigation sub-menu one page website

I am not really into all those coding terms, so I am having some difficulties to find answer to my problem. Usually I am just copy paste existing code and try to make some adjustments to what I want. Anyway I am working on a navigation menu on a one-page website. So till now that works. However, I want to have a sub-menu. I tried some things, but I cannot really get what I want. What I want is when I click on a menu item, the sub-menu opens and activate the first sub-menu item.
I found an example: http://inthe7heaven.com/fb-john-doe/dark/
The photo section. I tried to replicate that, but I think the sub-menu is connected to the filtering function of the photogallery.
Can anybody give me some guidance in this?
HTML
<nav class="on_caption">
<ul class="pagination">
<li class="home current">Home</li>
<li class="">About EJ</li>
<li class="">Services</li>
<li class="photos">
Photos
<div id="filter" class="category_filter_list">
<span class="active_link" id="all">All</span>
<span id="cookies">Cookies</span>
<span id="bread">Bread</span>
<span id="baking">Baking</span>
</div>
</li>
<li class="">Classes</li>
<!--<li class="">Testimonials</li>-->
<li class="">Contact</li>
</ul>
</nav>
CSS
nav {
position: absolute;
z-index: 999;
right: 0;
top: 0;
width: 158px;
height: 600px;
display: block;
overflow: hidden;
behavior: url(js/PIE.htc);
}
nav.on_caption {
background: rgba(20,11,19,.6);
-pie-background: rgba(20,11,19,.6);
}
nav.on_caption a {
color: #d0ced0;
}
nav.off_caption {
background: rgba(20,11,19,.08);
-pie-background: rgba(20,11,19,.08);
}
nav.off_caption a {
color: #524b51;
}
nav a {
font-size: 1.143em;
text-transform: uppercase;
}
nav > a {
padding-left: 24px;
}
ul.pagination {
margin: 0;
padding: 0;
padding-bottom: 8px;
list-style:none;
}
ul.pagination li {
margin: 0px 0px 0px 0px;
clear: both;
padding: 8px 10px 0px 24px;
list-style: none;
}
ul.pagination li:first-child {
padding-top: 25px;
}
nav > a:hover,
nav ul.pagination li a:hover,
nav ul.pagination li.current a {
color: #90705B;
}
So I got this code based on the website I provided above. I want the same effect as in the photo section only then for a normal menu item that is not connected to a filter. That is, when the menu item is clicked, the menu gets extended with the sub-menu and the page goes to the first item in the sub-menu. In addition, the sub-menu item gets active.
I managed to get the sub-menu expand and collapse in jsfiddle using a tree-menu. I tested it in jsfiddle and there it works. However, it doesn't work in my website. The menu doesn't expand. The website I am using it in is a single page website. So the menu items are pointing to a section on the page. So, I guess that my href="sub-1" is not working because it's pointing at the 3rd section of the page.
Is there a simple work-around for this? I don't need any fancy jquery effects, it just needs to open.
Furthermore, when the parent item is clicked, the sub-menu needs to expand and needs to activate the first sub-item. How can I do this?
HTML
<nav class="on_caption">
<ul class="pagination">
<li class="home current">Home</li>
<li class="">About EJ</li>
<li class="">Services
<ul id="sub-1">
<li class="">Test</li>
<li class="">Test</li>
</ul>
</li>
<li class="">Photos</li>
<li class="">Classes</li>
<li class="">Contact</li>
</ul>
</nav>
CSS
.pagination > li ul {
display: none;
}
.pagination > li ul:target {
display: block;
}
Made some progress.
HTML
<nav class="on_caption">
<ul class="pagination">
<li class="home current">Home</li>
<li class="">About EJ</li>
<li class="">Services
<ul id="sub-1">
<li class="">Test</li>
<li class="">Test</li>
</ul>
</li>
<li class="">Photos</li>
<li class="">Classes</li>
<li class="">Contact</li>
</ul>
</nav>
CSS
.pagination > li ul {
display: none;
}
jQuery
jQuery(
function($)
{
$('.pagination a').click(function(){$(this).next('ul').toggle();});
}
);
This works now. When I click the menu item, the sub-menu gets expended. However, how do I let the sub-menu collapse again when another menu item is clicked? And how do I let the page automatically go to the first sub-menu item by default when the menu item is clicked?