CSS Sprite navagation menu won't appear in any browser? - html

I am quite new to the world of HTML and CSS coding and am currently testing things out that I learn on my own website.
I have created a pretty simple nav menu I guess using CSS sprite coding, I am using Visual Studios 2012 and everything appears properly in that program, however when I try to test my webpage in any browser (IE, Google, Firefox) my nav menu just disappears. I notice that the cursor does change when I hover over the space where the nav menu should be, however as I said, no menu actually displays.
To add to that, other elements that I have in my page do appear and seem to function properly?
Here is the HTML code I am using
<div class ="navmenu">
<ul class ="navbar">
<li class ="Aboutus"></li>
<li class="Projects"></li>
<li class="Contactus"></li>
</ul>
</div>
and then the CSS
.navmenu
{
height: 120px;
position: relative;
}
.navbar
{
position: relative;
top: 0px;
left: 0px;
height: 79px;
}
.navbar li
{
list-style: none;
position: absolute;
margin: 0;
padding: 0;
top: 0;
}
.narbar li, .navbar a
{
height: 60px;
display: block;
}
.Aboutus
{
left: 0px;
width: 174px;
background: url('c:\users\teila\documents\visual studio 2012\Projects\Concept2\Concept2\Img\navMenu2.PNG') 0px 0px;
}
.Projects
{
left: 174px;
width: 174px;
background: url('c:\users\teila\documents\visual studio 2012\Projects\Concept2\Concept2\Img\navMenu2.PNG') -174px 0px;
}
.Contactus
{
left: 348px;
width: 174px;
background: url('C:\Users\Teila\documents\visual studio 2012\Projects\Concept2\Concept2\Img\navMenu2.PNG') -348px 0px;
}
.Aboutus a:hover
{
background: url('C:\Users\Teila\documents\visual studio 2012\Projects\Concept2\Concept2\Img\navMenu2.PNG') 0px -60px;
}
.Projects a:hover
{
background: url('C:\Users\Teila\documents\visual studio 2012\Projects\Concept2\Concept2\Img\navMenu2.PNG') -174px -60px;
}
.Contactus a:hover
{
background: url('C:\Users\Teila\documents\visual studio 2012\Projects\Concept2\Concept2\Img\navMenu2.PNG') -348px -60px;
}
I've tried looking for days as to what the problem could be, hopefully somebody could help me out. It would be greatly appreciated.

It may be because you have an absolute path to the image with c:/ etc. If you use the relative path sp perhaps img/ or /img/ or ../img/ using ../ to step back however folders back you need to go to reach your image folder from the css file.

Related

CSS Transitions firing on page load

I'm writing a simple website and have pretty much the same issue as described in these two posts:
Stop CSS transition from firing on page load
Chrome transition fires on page load when form element added
The issue is aparent when testing in Brave Browser, not for example in Edge. Although I have not used any <form> tag in my site..
Anyway, I can resolve this issue as described in those posts by putting a <script> </script> into the footer. My problem is, that I have a bad habit of letting VS Studio format my code with CTRL-K + CTRL + D, which will delete the space between the script tags. Also, copying the footer to a new file will do the same, thus I quite often have to resolve the same issue again and again.
Question now is: Since the linked posts are quite old therefore this issue has been known for quite a long time, is there another - better - way to resolve it?
Transition Code in Question:
nav {
position: relative;
background-color: #61625B;
width: 100%;
height: 100px;
}
nav ul {
position: absolute;
bottom: 0;
width: 70%;
list-style: none;
padding: 0 15%;
display: flex;
margin: 0;
}
nav li {
width: 125px;
text-align: center;
}
.navunderline {
width: 125px;
height: 0;
margin: 5px 0 0 0;
background-color: #DAD9D7;
transition: 500ms;
}
nav a {
color: #DAD9D7;
}
nav a:hover {
text-decoration: none;
}
nav li:hover .navunderline {
height: 5px;
margin: 0;
}
#selected .navunderline {
height: 5px;
margin: 0;
}
<nav>
<ul>
<li>Unternehmen<div class="navunderline"></div></li>
<li>Leistungen<div class="navunderline"></div></li>
<li>Referenzen<div class="navunderline"></div></li>
<li>News<div class="navunderline"></div></li>
<li>Kontakt<div class="navunderline"></div></li>
</ul>
</nav>

Foundation 6 top bar left and right stack when I use a wrap class around top-bar-left and top-bar-right

So I'm using Foundation 6 to prototype a project and I'm noticing that top-bar, top-bar-left, and top-bar-right work just as shown on the docs page except when I want to wrap the left and right bars so that they don't touch the sides.
Both top-left-bar and top-right-bar take up the whole width of the top-bar area each and then end up stacking on top of each other. I want them to look like they do in the code pen link below:
(its linked with foundation 6.0.5, and I'm using 6.4.1 - couldn't find a link for that version)
https://codepen.io/mgrosen/pen/RgEVvY
relevant code from app.css
.wrap {
width: 90%;
max-width: 1100px;
margin: 0 auto;
}
.nav-desktop {
background-color: #222;
height: 80px;
padding: 0;
}
.site-logo {
color: white;
line-height: 80px;
}
.nav-desktop .menu-desktop {
line-height: 80px;
background-color: transparent;
}
.nav-desktop a {
display: inline-block;
}
.menu-desktop > li > a {
display: inline-block;
line-height: 80px;
padding-top: 0;
padding-bottom: 0;
color: white;
}
.menu-desktop > li > a:hover {
background-color: rgba(255,255,255, 0.1);
}
relevant index.html code
<nav class="top-bar nav-desktop" id="responsive-menu">
<div class="wrap">
<div class="top-bar-left">
<h3 class="site-logo">Site Logo</h3>
</div>
<div class="top-bar-right">
<ul class="menu menu-desktop">
<li>Home</li>
<li>About</li>
<li>Foundation Examples</li>
</ul>
</div>
</div>
</nav>
That's the actual code I'm using, but when open index.html to look at it (or run my flask application and view it on local host) this is what i see when I'm scrolled all the way to the top of the screen.
Anybody know why this is happening or how I might debug it with dev tools?
Thanks!

Image Sprite Will Not Show

I can't seem to get the image sprite to display. Can someone look at the code and tell me if I have it correct? I have checked the code and can't seem to figure out what's wrong.
CSS
#nav-footer
{ background:url(./_img//Footersprite.png) repeat-y;
width: 490px;
height: 40px;
margin: 0;
padding: 0;
}
#nav-footer li, #nav-footer a {
height: 40px;
display: block;
}
#nav-footer li {
float: left;
list-style: none;
display: inline;
}
#whyroofrepair a:hover { background:url("/_img/Footersprite.png") 0px -40px no-repeat; }
#savings a:hover { background:url("/_img/Footersprite.png") -98px -40px no-repeat; }
#enviromental a:hover { background:url("/_img/Footersprite.png") -229px -40px no-repeat; }
#advantage a:hover { background:url("/_img/Footersprite.png") -352px -40px no-repeat; }
#whyroofrepair { width: 55px; }
#savings { width: 55px; }
#enviromental { width: 55px; }
#advantage { width: 55px; }
HTML
<ul id="nav-footer">
<li id="whyroofrepair">Why Repair</li>
<li id="savings">Savings</li>
<li id="environmental">Environmental Benefits</li>
<li id="advantage">Roof Rx Advantage</li>
Blockquote
http://jsfiddle.net/LQCm2/2/
I tested this using Js fiddle.
can some one take a look?
First, change ./_img//Footersprite.png to ../_img/Footersprite.png
If that doesn't solve the problem then proceed below:
If your _img folder, containing the sprite:
Live next to your css file, then your image path should be like
_img/foo.jpg
Live just outside your css file's parent folder, then your image
path should be like ../_img/foo.jpg
Live in the root of your project, then your image path should be
like /_img/foo.jpg
EmileKumfa - I added additional info. Please see original post

CSS drop-down menu fails to remain following hover activity

I'm currently working on a couple of drop-down menus on the following page:
http://icao.tungsten.hireserve-test.com/home.html
Originally, we only had one of these menus but our client has since changed their template and we now need to implement two drop-down menus. Previously this was done with jQuery hover() events which fired show() and hide() but now I have replaced this with CSS.
li.dynamic-children{
position: relative
}
li.dynamic-children ul{
display: none;
position: absolute;
}
li.dynamic-children:hover ul{
display: block;
left: -1px;
top: 18px;
position: absolute;
z-index: 100
}
li.dynamic-children:hover ul span{
width: 100%
}
The dropdown menu is displayed successfully on hover however because it is done with CSS there does not appear to be any way of ensuring that the drop-down persists when the user moves off of the link which triggers the drop-down. This means that the user cannot select any of the items in the dropdown menu rendering it useless.
Do any of you have any ideas as to how I can force the menu to persist long enough for users to be able to make a selection for the drop-down menus?
EDIT:
Based upon some of the code provided below I have now included the following CSS rules:
.s4-tn .horizontal ul.dynamic {
background-color: #ECF4FC;
border-top:4px solid #003D78;
margin: 0;
width: 255px;
z-index: 1000 !important;
}
.menu-horizontal li.static, .menu-horizontal a.static, .menu-horizontal span.static {
float: left;
padding-bottom: 5px;
}
These rules cause the menu to persist however in IE7 the drop-down menu now falls behind other elements on the page rendering it still useless in this browser. I have tried numerous z-index fixes to no avail.
try this one,
.s4-tn .horizontal ul.dynamic {
background-color: #ECF4FC;
border: 0 solid #003D78;
margin: 0;
width: 255px;
z-index: 101;
}
li.dynamic-children:hover ul {
display: block;
left: -1px;
position: absolute;
top: 22px;
}
Either 1 of the two:
Option 1 (Line 2840)
. .s4-tn li.static > .menu-item {
color: #3b4f65;
white-space: nowrap;
border: 1px solid transparent;
padding: 4px 10px;
display: inline-block;
height: 34px;
vertical-align: middle;
}
Option 2 (Line 99)
.s4-tn .horizontal ul.dynamic {
margin: 0 0 0 0;
border: 0px #003D78 solid;
width: 255px;
background-color: #ecf4fc;
}

IE9 & Mac CSS bug?

I'm experiencing a very frustrating problem with my CSS and IE9 and maybe even Chrome on MacOS.
I have an ul of four images in a container #categories {width: 960px}.
Each img (li) is contained in a box .catBox {width: 220px; float: left; margin: 20px 25px 10px 0px}.
I took away the right margin on the last image with .catBox:last-child {margin-right: 0px;}.
Basically, what I am trying to do is justify the four images across the 960px width container. This renders fine in Chrome, Safari, FF, and IE9 on my local computer and Chrome, Safari and FF work fine remotely from my Windows machine.
In IE when I test remotely it pushes the last image to the next line. ALSO, when testing in Chrome on a Mac it does the same thing.
Here is my math: 220px * 4 images = 880px. 3 margins (last one removed) at 25px = 75px. 75 + 880 = 955px. This should give me a 5px "buffer" in any of these browsers. Can someone please help? Am I thinking about this incorrectly?
Thanks in advance for your help.
HTML
<div id="categories">
<ul>
<li class="catBox"><img src="img/3mmwpolytongue22mm.jpg" alt=""><div class="caption"><h2>Stone</h2></div>
</li>
<li class="catBox"><img src="img/4g5.5m12ws.JPG" alt=""><div class="caption"><h2>Wood</h2></div></li>
<li class="catBox"><img src="img/5mmsnowflakeobsidianlabretA_01.JPG" alt=""><div class="caption"><h2>Teflon & Polymer</h2></div></li>
<li class="catBox"><img src="img/13mmblueindianearrings1.jpg" alt=""><div class="caption"><h2>Custom</h2></div></li>
</ul>
</div>
CSS
#categories {
width: 960px;
height: 240px;
}
.catBox {
position: relative;
display: inline;
overflow: hidden;
width: 220px;
margin: 20px 25px 10px 0px;
float: left;
z-index: -999;
}
.catBox:last-child {
margin-right: 0px;
}
.caption {
position: absolute;
top: 190px;
width: 220px;
height: 30px;
background-color: #333;
-webkit-opacity: .5;
-moz-opacity: .5;
-ms-opacity: .5;
text-align: center;
z-index: 999;
padding: 0px;
}
.caption h2 {
color: #fff;
}
Remove all whitespace between tags. It can interfere with pixel-precise layouts.
I don't see any problem. You should use tab to do whitespaces and no the space key. Here you have the JSFiddle, tested in FF, Chrome and Safari.
http://jsfiddle.net/PwkAW/
I'm not exactly sure why you're seeing the behavior that you're describing - do you know for a fact that ALL your CSS is exactly the same on the remote server? If I had to guess, there is another rule that is affecting your li's. Can you share the remote server link?
Also, your markup and CSS could be greatly simplified. I'm not saying it will fix what you're seeing, but it would at least remove some variables in the situation. You could have:
<ul id="categories">
<li>
<img src="img/3mmwpolytongue22mm.jpg" alt="" />
<h2>Stone</h2>
</li>
<li>
<img src="img/4g5.5m12ws.JPG" alt="" />
<h2>Wood</h2>
</li>
<li>
<img src="img/5mmsnowflakeobsidianlabretA_01.JPG" alt="" />
<h2>Teflon & Polymer</h2>
</li>
<li>
<img src="img/13mmblueindianearrings1.jpg" alt="">
<h2>Custom</h2>
</li>
</ul>
Then your CSS could look like this:
#categories {
width: 960px;
height: 240px;
}
#categories li {
position: relative;
display: inline;
overflow: hidden;
width: 220px;
margin: 20px 25px 10px 0px;
float: left;
z-index: -999;
}
#categories li:last-child {
margin-right: 0px;
}
#categories h2 {
position: absolute;
top: 190px;
width: 220px;
height: 30px;
background-color: #333;
-webkit-opacity: .5;
-moz-opacity: .5;
-ms-opacity: .5;
text-align: center;
z-index: 999;
padding: 0px;
color: #fff;
}
Actually, in refactoring the CSS, I did notice an issue - this rule:
catBox:last-child
Will not work the way you expect. The last-child rule, at least in my experience, doesn't work when applied to classes as part of the selector. It seems to work only on straight up elements - like #categories li:last-child. So, it may not removing the right margin as you expect.