Zurb Foundation change top-bar colour - html

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%);

Related

styling a bootstrap dropdown menu

I'm not sure why my CSS is not hitting my HTML and styling it correctly.
HTML:
<li class="dropdown">
Page 2 <b class="caret"></b>
<ul class="dropdown-menu">
<li>Page 2.0.0 </li>
<li class="divider"></li>
<li>Page 2.0.1 </li>
<li class="divider"></li>
<li>Page 2.0.2 </li>
</ul>
</li>
CSS:
.dropdown-menu li:hover{
background-color: green;
}
The class dropdown-menu should be hit and then when you hover over the li's inside it. I have tried adding an id as dropdown menu and changing the CSS to #dropdown-menu but it made no difference.
Also, is there an easy way to find out exactly how to hit the appropriate element as I find this is a frequent problem?
Ok here we go,
here is the working solution of your problem,
.dropdown-menu > li > a:focus,
.dropdown-menu > li > a:hover {
clear: both;
background-color: green !important;
background-image:none !important;
display: block;
font-weight: 400;
line-height: 1.42857;
padding: 3px 20px;
white-space: nowrap;
color: black !important;
}
i have just edited your code
http://jsfiddle.net/bf1cyptm/1/
:)
Try adding !important in CSS like:
.dropdown-menu li a:hover{
background-color:green !important;
}
If it does not work it could possibly be some other CSS code that is not letting it happen. So the solution to it is to do an inspect element and see which element is affecting it.
If you are not expert in than a best solution for you.
Please add a new class just after dropdown-menu like:
<ul class="dropdown-menu colorchange">
and call CSS by it like:
.colorchange li a:hover{
background-color: green;
}
It should work! You can use important here as well.
Try this
.dropdown-menu li:hover .dropdown-menu li a{
color: green;
}

Editing a particular element in inactive/hover/active states

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;
}

child items styling different from active parent

I am working on a pretty simple menu with just one level of submenu items.
I have managed to get the styling as I want it, only that once the parent item is selceted (it displays a background image)te submenu items then also display that background image, which shouldn;t happen.
Here is my css
#fav-nav .navigation li a:hover,
#fav-nav .navigation li.active a{
color: #fff;
background: url(../../../images/menu-back.png) no-repeat top;
}
#fav-nav .nav-child li a:hover,
#fav-nav .nav-child li a:active {
background-image: none;
color: #fff;
}
Here is the html, sorry it's out of a joomla site, I hope I got all the relevant info here.:
<div class="navigation">
<div class="moduletable">
<ul class="nav menu">
<li class="item-102 deeper parent">FENCING
<ul class="nav-child unstyled small">
<li class="item-106">Fence Panels</li>
<li class="item-107">Fence Posts</li>
<li class="item-108">Gates</li>
<li class="item-109">Gate Furniture</li></ul></li>
<li class="item-103 current active">
TIMBER</li></ul>
</div>
</div>
</div>
Any help would be really appreciated.
Thanks
Make the following changes in your css
#fav-nav .nav-child li > a:hover,
#fav-nav .nav-child li > a:active {
background-image: none;
color: #fff;
}

Creating Navbar where each link has a different color when hover

Trying to change individual links in navbar to different colors when hovered. Can't seem to figure it out.
HTML:
<div class="collapse navbar-collapse navbar-right navbar-main-collapse">
<ul class="nav navbar-nav">
<!-- Hidden li included to remove active class from about link when scrolled up past about section -->
<li class="hidden">
</li>
<li class="page-scroll">
1
</li>
<li class="page-scroll">
2
</li>
<li class="page-scroll">
3
</li>
<li class="page-scroll">
4
</li>
</ul>
</div>
CSS:
.navbar-custom li a:hover,
.navbar-custom .nav li a:focus,
.navbar-custom .nav li.active
{
outline: 0;
background-color: #bdc3c7 !important;
color: #fff;
}
Have the current links set to red. But would like each individual link to have a different color. E.g. Link1 = Red, Link2 = Blue.
I am having trouble doing this! Help appreciated!
Thanks!
if you use SASS, it could be done in a more cleaner way like this in your scss file:
$colors: (1: red, 2: blue, 3: yellow, 4: black);
#each $anchor, $color in $colors {
#{".navbar-custom .nav li:nth-child("+ (1 + $anchor) + ") a:hover"} {
background-color: $color;
}
}
which will generate the CSS:
.navbar-custom .nav li:nth-child(2) a:hover {
background-color: red;
}
.navbar-custom .nav li:nth-child(3) a:hover {
background-color: blue;
}
.navbar-custom .nav li:nth-child(4) a:hover {
background-color: yellow;
}
.navbar-custom .nav li:nth-child(5) a:hover {
background-color: black;
}
Now you could add as many as different colors for all your links and let the SASS generate the CSS for you.
Yeah, just need to class them up uniquely
HTML
<li class="hidden colour1">
</li>
<li class="page-scroll colour2">
1
</li>
<li class="page-scroll colour3">
2
</li>
CSS:
.colour1:hover { background-color:blue; }
.colour2:hover { background-color:red; }
.colour3:hover { background-color:green; }
You would need to assign their CSS for each individual class and give the different link different class
like
.pagescroll1{
}
.pagescroll2{
}
and the call them from your HTML
The elegant solution is to select by attribute value. example for the first one:
a[href="#link1"]:hover,
a[href="#link1"]:active,
{
outline: 0;
background-color: #bdc3c7 !important;
color: #fff;
}
however, this works only when you're directly selecting the a-elements. With your third selector li.active, there is no information in that element as to where it links. in this case, you'll have to add classes as suggested by rob.

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?