HTML5 & CSS3 Dropdown Menu & Google Fonts only working in Chrome - css

I'm pretty new to HTML5 and CSS3 and I've been developing a new website for my NGO. I'm pretty much done all the design, but I can't get my drop down menu to work in IE, and I can't get the Google Font I'm using to work in IE or Firefox.
I have a drop down menu with the org logo in the middle and the menu text floating at the vertical center of the logo on either side. In Chrome this works just as I want it to, but when I open it in IE11 the menu text is floating at the very top of the page, and the drop down boxes don't line up correctly. All of it lines up correctly in Firefox, but the Google Font 'Lato' that I'm using only works in Chrome.
Here is the HTML for the header:
/* Header */
* {margin: 0;padding: 0 ;outline: none;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;-o-box-sizing: border-box;-ms-box-sizing: border-box;box-sizing: border-box;}
*:after, *:before { -webkit-box-sizing: border-box;-moz-box-sizing: border-box;-o-box-sizing: border-box;-ms-box-sizing: border-box;box-sizing: border-box;}
article,aside,details,figcaption,figure,footer,header,hgroup,nav,section { display: block; }
html {font-size: 60%;height: auto; !important;height: 100%;-webkit-text-size-adjust: 100%;-ms-text-size-adjust: 100%;-o-box-sizing: border-box;-moz-box-sizing: border-box; }
.clear {display: block; }
.clear::after {clear: both;content: ".";display: block;height: 1px;visibility: hidden;}
/*GENERIC STYLES*/
body {background: url('../images/bg-tile-grey-2.png') font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 1.05em;font-weight: 400;height: auto !important;height: 100%;min-height: 100%;}
/*NAV*/
#logo {
display: inline;
margin: 0 auto;
padding: 0;
}
.menu {
position: relative;
}
#search {
float: left;
position: absolute;
}
#searchbox {
padding: 16px 15px 16px 15px;
font-family: 'Lato', Helvetica, Arial, sans-serif;
margin-left: 0;
color: #603a16;
position: relative;
right: -5px;
border: none;
border-color: white;
}
#go {
padding: 8px;
font-size: 1.5rem;
font-family: 'Lato', Helvetica, Arial, sans-serif;
letter-spacing: 1px;
text-transform: uppercase;
font-weight: bolder;
color: transparent;
background: url('../images/magnifying-glass.png') top right no-repeat;
border: #74b648;
margin-right: 0;
}
.facebook {
height: 32px;
width: 32px;
background: url('../images/facebook_colour_32-03.png') top right no-repeat;
text-indent: -9999px;
margin: 0 15px 0 10px;
display: inline-block;
float: right;
box-shadow: none;
border: none;
}
.twitter {
height: 32px;
width: 32px;
background: url('../images/twitter_colour_32-03.png') top right no-repeat;
text-indent: -9999px;
display:inline-block;
float: right;
}
.donate {
position: relative;
right:-695px;
}
header {
display: block;
width: 100%;
text-align: center;
}
header > nav > ul {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
list-style: none;
margin: 0;
padding: 0;
}
header > nav > ul > li {
flex: 0 1 auto;
margin: auto;
padding: 0;
position: relative;
transition: all linear 0.1s;
}
header > nav > ul > li:hover {
background-color: white;
}
header > nav > ul > li a + div {
background: white;
border-radius: 0 0 2px 2px;
box-shadow: 0 3px 1px rgba(0,0,0,.05);
display: none;
font-size: 1.1rem;
color: #603a16;
padding: .25rem 1.5rem;
letter-spacing: 1.5px;
text-transform: uppercase;
text-align: left;
position: absolute;
width: 220px;
}
header > nav > ul > li:hover a + div {
display: block;
}
header > nav > ul > li a + div > ul {
list-style-type: none;
}
header > nav > ul > li a + div > ul > li {
margin: 0;
padding: 0;
-webkit-font-smoothing: antialiased;
-moz-font-smoothing: antialiased;
-o-font-smoothing: antialiased;
-ms-font-smoothing: antialiased;
font-smoothing: antialiased;
font-family: 'Lato', Helvetica, sans-serif;
font-weight: bolder;
line-height: 2rem;
}
header > nav > ul > li a + div > ul > li > a {
color: #603a16;
display: block;
font-size: 1.1rem;
letter-spacing: 1.5px;
padding: .25rem 1.5rem;
text-decoration: none;
text-transform: uppercase;
width: 200px;
background: white;
}
header > nav > ul > li a + div > ul > li:hover > a {
background-color: #bbbbbb;
}
header > nav > ul > li > a {
color: #603a16;
display: block;
font-size: 1.7rem;
max-width: 500px;
padding: .9rem ;
text-decoration: none;
font-weight: ;
text-transform: uppercase;
transition: all linear 0.1s;
text-align: center;
margin-right: auto;
margin-left: auto;
-webkit-font-smoothing: antialiased;
-moz-font-smoothing: antialiased;
-o-font-smoothing: antialiased;
-ms-font-smoothing: antialiased;
font-smoothing: antialiased;
font-family: "Lato", Helvetica, Arial, sans-serif;
font-weight: bolder;
}
header > nav > ul > li > a > div > span {
color: rgba(255,255,255,.75);
display: block;
font-family: "Lato", Helvetica, Arial, sans-serif;
font-size: .7rem;
font-style: italic;
line-height: 1rem;
max-width: 260px;
}
<header class="main">
<nav role="navigation">
<ul style="position:relative; z-index:90;">
<li class="menu">
<a href="/about/index.html">
<div>
About
</div>
</a><div>
<ul style="position:relative; z-index:99;">
<li>Member Groups</li>
<li>Board of Directors</li>
<li>Bulletin</li>
<li>Brochure</li>
<li>Join</li>
<li>Contact</li>
</ul>
</div>
</li>
<li>
<li class="menu">
<a href="/events/index.html">
<div>
Events
</div>
</a>
<div>
<ul style="position:relative; z-index:99;">
<li>SEN World Rivers Day</li>
<li>SEN Environmental Film Festival</li>
<li>SEN Earth Overshoot</li>
<li>SEN Environmental Activist Awards</li>
<li>Events Calendar</li>
</ul>
</div>
</li>
<li>
<li class="menu">
<a href="/tools/index.html">
<div>
Tools
</div>
</a><div>
<ul style="position:relative; z-index:99;">
<li>Group Tools</li>
<li>Campaign Tools</li>
<li>Laws</li>
<li>Government Contacts</li>
<li>SEN's Grassroots Activism Fund</li>
</ul>
</div>
</li>
<li class="menu">
<a href="/solutions/energy/index.html">
<div>
Solutions
</div>
</a><div>
<ul style="position:relative; z-index:99;">
<li>Energy Policy</li>
<li>Energy Conservation and Efficiency</li>
<li>Alternate Energy Resources</li>
</ul>
</div>
</li>
<li class="menu">
<a href="/index.html">
<div id="top-logo">
<img src="images/EcoNet_logo_head2.png" height="180" width="180" title="Saskatchewan_Eco_Network" alt="Saskatchewan Eco Network">
</div>
</a>
</li>
<li class="menu">
<a href="/issues/index.html">
<div>
Issues
</div>
</a><div>
<ul style="position:relative; z-index:99;">
<li>Biodiversity</li>
<li>Biotechnology</li>
<li>Climate Change</li>
<li>Ethanol</li>
<li>Forests</li>
<li>Great Sand Hills</li>
<li>Intensive Livestock Operations</li>
<li>Mining</li>
<li>Pesticides</li>
<li>Water</li>
</ul>
</div>
</li>
<li>
<li>
<li class="menu">
<a href="/action/index.html">
<div>
Action
</div>
</a><div>
<ul style="position:relative; z-index:99;">
<li>Find your Representitive</li>
<li>Write a Letter to the Editor</li>
</ul>
</div>
</li>
<li>
<li>
<li class="menu">
<a href="/ecoed/index.html">
<div>
Eco-Education
</div>
</a><div>
<ul style="position:relative; z-index:99;">
<li>Teacher Resources</li>
<li>Eco-Education Stories</li>
<li>Indigenous Educators</li>
<li>Student Resources</li>
</ul>
</div>
</li>
<li>
</ul>
</nav>
</header>
and here is the CSS for the Header
The menu is in the correct position in Firefox, but the Google Font 'Lato' still isn't working correctly. Does anybody know what I'm doing wrong with my HTML and CSS that the menu and font are only working properly in Chrome?

Related

Anchor does not stretch across full width of the sidebar

I'm having an issue with my anchors not covering full width of the sidebar (for instance, 'Search'). I realise that this is because of padding, but I'm not sure how to overcome the issue whilst keeping the padded effect. I have tried to add a class (like, '.no-submenu) on the <li> and did .no-submenu a { margin: 0 -1.5rem; padding: 0 3rem; }, but it only partially solved the problem - my icons were off, they go all the way to the left:
I couldn't find the place online to upload SVG files (my icons are SVG), so I created a minimal example without icons. Icons are handled as background-image on the anchors.
<div class="sidebar">
<nav>
<ul class="menu">
<li id="search">
<a class="sidebar-icon" href="/search/notes/">Search</a>
</li>
<li id="dashboard">
<a class="sidebar-icon">Dashboard</a>
</li>
<li id="notebooks" class="has-submenu">
<div class="menu-item">
<span class="sidebar-icon">Notebooks</span>
<span class="arrow"></span>
</div>
<ul class="submenu">
<li id="new-notebook"><a class="sidebar-icon" href="/notebooks/create/">New Notebook</a></li>
<li id="view-notebooks"><a class="sidebar-icon" href="/notebooks/">View Notebooks</a></li>
</ul>
</li>
<li id="tags" class="has-submenu">
<div class="menu-item">
<span class="sidebar-icon">Tags</span>
<span class="arrow"></span>
</div>
<ul class="submenu">
<li id="view-tags"><a class="sidebar-icon" href="/tags/">View Tags</a></li>
</ul>
</li>
<li id="account" class="has-submenu">
<div class="menu-item">
<span class="sidebar-icon">Account</span>
<span class="arrow"></span>
</div>
<ul class="submenu">
<li id="settings"><a class="sidebar-icon" href="/accounts/settings/">Settings</a></li>
<li id="logout"><a class="sidebar-icon" href="/accounts/logout/">Logout</a></li>
</ul>
</li>
</ul>
</nav>
</div>
CSS:
#import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,600);
#font-face { font-family: "ionicons"; src: url("https://code.ionicframework.com/ionicons/2.0.1/fonts/ionicons.eot?v=2.0.1"); src: url("https://code.ionicframework.com/ionicons/2.0.1/fonts/ionicons.eot?v=2.0.1#iefix") format("embedded-opentype"), url("https://code.ionicframework.com/ionicons/2.0.1/fonts/ionicons.ttf?v=2.0.1") format("truetype"), url("https://code.ionicframework.com/ionicons/2.0.1/fonts/ionicons.woff?v=2.0.1") format("woff"), url("https://code.ionicframework.com/ionicons/2.0.1/fonts/ionicons.svg?v=2.0.1#Ionicons") format("svg"); font-weight: normal; font-style: normal; }
.sidebar {
width: 200px;
height: 100vh;
padding: 1rem 1.5rem;
background-color: #348ceb;
font-family: 'Source Sans Pro';
font-size: 14px;
position: fixed;
box-sizing: border-box;
}
ul {
list-style: none;
}
ul, li {
padding: 0;
margin: 0;
}
li {
padding: 0.5rem 0;
}
.submenu {
display: none;
overflow-y: hidden;
margin: 0 -1.5rem;
background-color: #3287e3;
}
.submenu li:first-child {
padding: 0.1rem 0 0 1.5rem;
}
.submenu li:last-child {
padding: 0 0 0.1rem 1.5rem;
}
.submenu li {
padding: 0.5rem 1.5rem;
}
.menu > li:hover {
background-color: #3287e3;
}
.menu > li {
position: relative;
color: #F9FAFC;
font-weight: bold;
margin: 0 -1.5rem;
padding: 0.5rem 1.5rem;
}
.menu > li > a {
display: block;
color: #F9FAFC;
text-decoration: none;
font-weight: bold;
}
.menu > li > a:hover {
color: white;
}
.submenu > li > a {
display: block;
color: #F9FAFC;
text-decoration: none;
}
.submenu > li > a:hover {
color: white;
}
.submenu > li {
font-weight: normal !important;
}
.arrow {
display: inline-block;
width: 10px;
transition: all 0.5s ease-in-out;
transform-origin: left center;
font-size: 0.5em;
position: absolute;
right: 0.75em;
}
.arrow:after {
content: '\f125';
font-family: 'ionicons';
color: white;
}
.rotated {
transform: rotate(90deg);
transition: transform 0.5s ease;
}
.menu-item {
display: flex;
align-items: center;
}
.menu-item > span:first-child {
flex: 1;
}
.sidebar-icon {
background-repeat: no-repeat;
padding-left: 25px;
}
JS (jQuery):
$(document).ready(function() {
$('.has-submenu').click(function() {
$(this).toggleClass('active');
$(this).children('.menu-item').children('.arrow').toggleClass('rotated');
if ($(this).hasClass('active')) {
$(this).children('.submenu').slideDown("slow");
}
else {
$(this).children('.submenu').slideUp("slow");
}
});
});
How can I overcome the issue?
Here is the demo.
#EDIT:
so, I want this:
but the menu item has to be fully clickable, i.e. you can click on any part of it and it brings you to, say, Search. To see the area it currently covers, right-click on the anchor or inspect the element.
I guess this is what you want:
<li style="padding: 0.5rem 0" id="search">
<a style="width: 100% !important; padding: none" class="sidebar-icon" href="/search/notes/">
<i style="padding-right: 10px">#</i>Search</a>
</li>

.btn font color not changing

Beginner to CSS and I'm trying to build a Nav;
So far I have the following CSS code. I want the .btn font color to be white. I've tried using !important; but also not working.
any ideas what is overriding the font color and what I can do to change it?
/* navigation */
nav {
width: 503px;
height: 45px;
font-family: Roboto;
font-size: 16px;
font-weight: 500;
float: right;
color: #646881;
}
nav li {
display: inline;
padding-right: 20px;
}
nav a:link {
color: #646881;
}
nav a:hover {
color: #646881
font-style: italic;
}
nav a:active {
color: #646881;
}
nav a:visited {
color: #646881;
}
img.logo{
max-height: 45px;
max-width: 105px;
border-top: 40px;
margin-left: 60px;
float: left;
padding: 5px;
}
.btn {
background-color: #646881;
width: 75px;
border-radius: 4%;
border: none;
color: #ffffff;
}
HTML
Yes, sorry here is the HTML:
<header role="header">
</div>
<img border="0" class="logo" src="/assets/images/logo.png" alt="David Bowie Personas Logo">
<!-- Nav-->
<nav id="MainMenu" role="navigation">
<ol>
<li>
About
</li>
....
<li>
Shop
</li>
</ol>
</nav>
</header>
/* navigation */
nav {
width: 503px;
height: 45px;
font-family: Roboto;
font-size: 16px;
font-weight: 500;
float: right;
color: #646881;
}
nav li {
display: inline;
padding-right: 20px;
}
nav a:hover {
color: #646881
font-style: italic;
}
img.logo{
max-height: 45px;
max-width: 105px;
border-top: 40px;
margin-left: 60px;
float: left;
padding: 5px;
}
a.btn {
background-color: #646881;
width: 75px;
border-radius: 4%;
border: none;
color: #ffffff;
display: block;
padding: 10px;
text-align: center;
}
<header role="header">
<img border="0" class="logo" src="/assets/images/logo.png" alt="David Bowie Personas Logo">
<!-- Nav-->
<nav id="MainMenu" role="navigation">
<ol>
<li>
About
</li>
....
<li>
Shop
</li>
</ol>
</nav>
</header>
You are referring to an HTML-tag with nav i assume that you got a div-element with a class-name, in that case you shall use a dot .nav

How to center a letter in a circle on a <li>

I've been stuck on this for a while. Please see image attached. I need to make a circle with a centered letter inside it and a line to text aligned centre to the circle. I need help with rest of the code.
.lettercircle {
font-family: Helvetica, sans-serif;
background-color: #009cda;
color: #fff;
padding: 5px 12px;
border-radius: 50%;
font-size: 28px;
}
#div {
width: 499px;
height: 166px;
}
<div id="div">
<ul>
<li> <span>A</span>
DREAMWEAVER
</li>
<li> <span>B</span>
PHOTOSHOP
</li>
</ul>
</div>
How about this:
.lettercircle {
font-family: Helvetica, sans-serif;
background-color: #333;
color: #fff;
padding: 5px 9px;
border-radius: 50%;
font-size: 12px;
display: table-cell;
vertical-align: middle;
}
.title {
padding-left: 10px;
display: table-cell;
vertical-align: middle;
}
#div {
width: 499px;
background: red;
height: 100%;
padding: 10px;
}
#div > ul {
padding: 0;
display: table-cell;
vertical-align: middle;
}
#div > ul > li {
list-style: none;
padding: 10px;
font-family: Helvetica, sans-serif;
text-transform: uppercase;
display: table;
}
<div id="div">
<ul>
<li>
<span class="lettercircle">A</span>
<span class="title">DREAMWEAVER</span>
</li>
<li>
<span class="lettercircle">B</span>
<span class="title">PHOTOSHOP</span>
</li>
</ul>
</div>
I think you just forgot to add your class to your spans.
.lettercircle {
font-family: Helvetica, sans-serif;
background-color: #009cda;
color: #fff;
padding: 5px 12px;
border-radius: 50%;
font-size: 28px;
}
#div {
width: 499px;
height: 166px;
}
<div id="div">
<ul>
<li> <span class="lettercircle">A</span>
DREAMWEAVER
</li>
<li> <span class="lettercircle">B</span>
PHOTOSHOP
</li>
</ul>
</div>

CSS dropdown menu remaining visible in Chrome, IE

I'm hoping someone might be able to help me with this. It looked fine in the preview mode of my program. However, when I opened it in IE and Chrome, the dropdown remains dropped at all times. I'm guessing it's a simple solution to fix it, but I have been staring at this screen for too long. To see what I'm talking about, please see the picture below.
http://img.photobucket.com/albums/v299/insane43/DropdownError_zpsa3e89f8a.jpg
CSS
body {
background: #eaeff2 url("BG Top.jpg") repeat-x right top }
.menu {
background-color: #97a7b7;
font-family: times;
color: #ffffff;
line-height: 50px;
text-align: center;
margin: 0px auto;
display: block}
.menu ul li:hover > ul {
display: block;
width: auto;}
.menu li:hover ul {
position: absolute;
display: block;
left: auto; }
.menu ul {
margin: 0px auto;
padding: 0;
display: inline-block;
text-align: center;
list-style-type: none; }
.menu ul ul{
background: #eaeff2;
top: 100%;
position: absolute}
.menu ul ul li {
float: none;
position: relative;
background-color: #97a7b7}
.menu li {
float: left;
position: relative:
width: 98%:}
.menu li ul {
display: none; }
.menu a:link, a:visited {
display: block;
height: 50px;
margin-left: 30px;
margin-right: 30px;
font-family: times;
font-size: 16px;
color: #ffffff;
text-align: center;
font-weight: bold;
text-transform: uppercase;
text-decoration: none }
.menu a:hover, a:active {
background-color: #4f5963;
text-decoration: none }
.header {
font-family: times;
color: #ffffff;
font-size: 40px;
vertical-align: middle }
.frame {
width: 98%;
text-align: center;}
iframe {
overflow: hidden;
border: 0px;
padding: 0px;
margin: 0px }
.header img {
vertical-align: middle}
.petpics img {
opacity: 0.7;
filter: alpha(opacity=70);}
HTML
<div id="header" class="header" style="position: absolute; top: 0px; text-align: center; width: 100%"><img height="140px" src="Logo.png">&nbsp&nbsp&nbsp<span class="petpics" class="petpics"><img height="194px" src="Lily.jpg"><img height="194px" src="Annie.jpg"><img height="194px" src="Smoki.jpg"></span></div>
<div id="menu" class="menu" style="position: absolute; top:194px; left:0px; text-align: center; width: 100%; z-index:1"><center>
<ul>
<li>Home</li>
<li>About</li>
<ul>
<li>Our Board</li>
<li>Our Staff</li>
</ul>
<li>Adopt</li>
<ul>
<li>Cats</li>
<li>Dogs</li>
</ul>
<li>Lost Pets</li>
<ul>
<li>Lost</li>
<li>Found</li>
</ul>
<li>Volunteer</li>
<ul>
<li>Become a Volunteer</li>
<li>Volunteer Login</li>
</ul>
<li>How to Help</li>
<ul>
<li>Membership</li>
<li>Donate</li>
<li>Upcoming Events</li>
</ul>
<li>Education</li>
<ul>
<li>Information</li>
<li>Educational Events</li>
</ul>
</ul>
</center>
</div>
<div id="frame" class="frame" style="position: absolute; top: 280px; width: 98%; height: 100%; z-index:0">
<iframe name="display" width="100%" height="100%" overflow="visible" scrolling="hidden" seamless="seamless" border="0" margin="0" src="Home.html">
</iframe>
</div>
Thank you! Your help is appreciated. Edited to add full code.

Horizontal Table needed centering

Bit new at CSS and been looking around at various sites and bits of code trying to get a centered drop down menu which I managed to get :).
However as soon as I added some images to make up the heading the menu shifted off to the left and I have not been able to budge it ever since, any help? Code is below.
<style type="text/css">
<!--
body {
background-image: url();
background-color: #0099FF;
}
.style1 {color: #FFCC00}
.style2 {color: #FF9900}
.style3 {
color: #FFCC00;
font-weight: bold;
font-size: 12px;
}
.style4 {
color: #000099;
font-weight: bold;
}
.style5 {color: #000099; font-weight: bold; font-size: 12px; }
.style6 {color: #000099}
* { padding: 0; margin: 0; }
body { padding: 5px; }
ul { list-style: none; margin: auto}
ul li { float: left; padding-right: 0px; position: relative; }
ul a { display: table-cell; vertical-align: middle; width: 100px; height: 50px; text-align: center; background-color: #0099EE; color: #000000; text-decoration: none; border: 1px solid #000000;}
ul a:hover { background-color: #0066FF; }
li > ul { display: none; position: absolute; left: 0; top: 100%; }
li:hover > ul { display: inline; }
li > ul li { padding: 0; padding-top: 0px; }
#menu-outer {
height: 84px;
background: url(images/bar-bg.jpg) repeat-x;
}
.table {
display: table;
margin: 0 auto;
}
ul#horizontal-list {
min-width: 696px;
list-style: none;
padding-top: 20px;
}
ul#horizontal-list li {
display:inline
}
-->
</style></head>
<body>
<div id="menu-outer"></div>
<div class="table"></div>
<div align="center"><img src="logo_with_words_3.jpg" width="172" height="145"><img src="heading.gif" width="557" height="69"><img src="logo_with_words_3.jpg" width="172" height="145">
</div>
<ul id="horizontal-list">
<li>
Home
</li>
<li>About Us
<ul>
<li>History</li>
<li>Guest Comments</li>
</ul>
<li>News</li>
<li>Accommodation
<ul>
<li>Rooms</li>
<li>Bedrooms</li>
<li>St Joseph's Annexe</li>
</ul>
<li>Visiting St Katharine's
<ul>
<li>Retreats</li>
<li>B&B</li>
<li>Events</li>
<li>Conferences</li>
<li>Catering</li>
</ul>
<li>Contact Us
<ul>
<li>Find Us</li>
</ul>
<li>Walled Garden</li>
<li>Sue Ryder Legacy
<ul>
<li>Sue Ryder</li>
<li>Prayer Fellowship</li>
<li>LRWMT</li>
</ul>
</ul>
</body>
You aren't really using a table, but you can add something like this: #horizontal-list {margin: auto; width: 850px;}
JS Fiddle with your code

Resources