Forum Moderators: not2easy
[edited by: alt131 at 8:07 pm (utc) on Jul 9, 2011]
[edit reason] Thread Tidy - 404 [/edit]
For this example I put the first image in a div with a class attached to it, but the image doesn't centre like I expected/wanted it to do. Looking at firebug, it turns out to take the style rules from parent (body). What I don't understand and what causes choosing me for tables most of the time is why on earth the image doesn't do anything with the class attached to it. I tried span as well, no result either
<style type="text/css">
ul#siteNavigation {
background-image: url(top-level.png);/*the whole top-level menu images combined into a single image*/
padding:0;
margin: 0 auto;
list-style-type:none;
width:744px;
height:63px;
}
ul#siteNavigation li {
float:left;
position: relative;
height:63px;
width:146px;
}
ul#siteNavigation li a {
position: absolute;
height:50px;
width:146px;
/*hiding the text*/
/*hiding the text*/
color:transparent;/* works for all but ie, but is NOT valid*/
/*opacity:0; works for all browsers but ie */
/*filter:alpha(opacity=0); works for ie, but does not validate*/
font-size:0; /*for all but winSafari and ie7*/
line-height:0; /*for ie7 but not winsafari*/
}
/*position the links for hover effects */
.concave {top:0;}
.convex {bottom:0}
ul#siteNavigation li ul {
background-image: url(second-level.png); /*the whole sub-menu images combined into a single image/*
list-style-type:none;
padding:0;
margin:0;
position:relative;
top:43px;
width:146px;
height:112px;
visibility:hidden;
}
ul#siteNavigation li ul li {
/*adjustment to allow for different image*/
height:40px;
}
ul#siteNavigation li:hover ul {
visibility:visible;
}
</style>
</head>
<body>
<ul id="siteNavigation">
<li><a class="concave" href="home.html" title="Home">Home</a></li>
<li title="product">
<ul>
<li><a href="one.html" title="One">Item One</a></li>
<li><a href="two.html" title="two">Item Two</a></li>
<li><a href="three.html" title="three">Item Three</a></li>
</ul>
</li>
<li><a class="concave" href="herkomst.html" title="Bedrijven">Bedrijven</a></li>
<li><a class="convex" href="information.html" title="Information">Information</a></li>
<li><a class="concave" href="Contact.html" title="Contact">Contact</a></li>
</ul>
As far as the user-unfriendly absence of text is concerned: in itself I agree with your point of view, but it concerns a website for a rather small group of usersAnd I also agree with your point of view - knowing your target market is a really important part of making the best decision about what code to use, but I do urge coders to try to use solutions that are accessibility friendly as well.
Sometimes I didn't see any other solution and my theory is "make something that works instead of telling me you can't do this or that".Ahah! But then you post at WebmasterWorld and discover how to make it work ;)
Now I'm willing to believe that CSS isn't a bad tool, but I never had any troubles learning new stuff and am surprised every now and then how much trouble I still have with CSS. If it was the only field in which I was learning, I'd say I was getting old and rusty.I disagree. You are trying to do things that are quite challenging. You're asking lots of extremely technical questions things, and are trying to understand the theory and put it into practise at the same time. From your posts you are putting in a lot of time yourself, then posting here and we are suggesting something completely different so you start again. All this in a language that is not your first language. One of the reason you've been getting very long explaining posts from me is because your desire to learn and the speed you have been understanding new ideas is quite extraordinary.
Found a post somewhere that moved the text out of sight, but it didn't work.Probably because it moved the <a>/<li> - which is why I've proposed "hiding" the text instead.
The menu looks like abracadabra to me at the moment.Try it and see - it is the same menu and code you have been refining in the posts here. All I've done is take your existing menu and make the changes necessary to use the images as background-image rather than in the html itself.
Why are div's inside an ul not allowed? I don't know by heart if I used it more often, but can imagine I have a list and I want to use for example different text colors. How can I manage to do that if I may not use a div?
webprutser, remember ths is web-whiz stuff - the goal is not to push you off the edge so you splatter after a very long fall. So if you don't feel a "parachute of understanding" opening, come back with questions before you hit the bottom;)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
<meta http-equiv="X-UA-Compatible" content="IE=8" >
<title>Wereldwinkel</title>
<meta name="keywords" content="Wereldwinkel, Hoorn, Noord-Holland">
<style type="text/css">
body {
font: 16px Georgia, serif;
color: #000;
background: #000 url("background-2.png") no-repeat top center;
min-height:1505px; /* The total height of the background-image - doesn't have to be set, but means the bottom curved corners are visible */
}
#header {
background: transparent url(hagedisjes.png) no-repeat center top; /* image centred by background-position */
width:950px;
margin:0 auto; /* with width, centres the header */
border:1px solid transparent; /* to avoid collapsing margins */
}
/* hiding the text - specifying "a" is necesary for winSafari*/
#header, #header a {
/*hiding the text*/
color:transparent; /* will not validate, but a valid colour in css3, and understood by all except ie*/
font-size:0; /*for ie*/
line-height:0; /*for ie 7*/
}
h1 {
/* no need to give a width and center using margin: 0 auto as the background-position centres the image, and no-repeat stops the image repeating horizontally */
background: transparent url(wereldwinkel_hoorn_groot.png) no-repeat center top;
margin-top:188px;
height:48px;
}
ul#siteNavigation {
list-style-type:none;
/*new image created by combining all of the top-level links images into a single image*/
background: transparent url(top-level.png);
width:744px;
height:63px;
padding:0;
margin: 30px auto 40px;
}
ul#siteNavigation li {
float:left;
position: relative;
height:63px;
width:146px; /*adjust to suit actual image dimensions*/
cursor:pointer; /* changes mouse pointer to a hand when the drop-downs are hovered */
}
ul#siteNavigation li a {
position: absolute;
height:50px;
width:146px; /*adjust to suit actual image dimensions*/
}
ul#siteNavigation li ul {
/*Image created by combining all of the second-level link images into a single image file */
background: transparent url(second-level.png);
list-style-type:none;
position:relative;
top:43px;
width:146px;
height:112px;
padding:0;
margin:0;
visibility:hidden;
}
ul#siteNavigation li ul li {
height:40px; /* adjust for image heights */
}
ul#siteNavigation li:hover ul {
visibility:visible;
}
#maincontent {
width: 750px;
margin:0 auto;
padding-top:10px; /*avoids padding on the image and p */
padding-bottom:100px;
}
.img_left {
float: left;
margin: 0 20px 10px 0;
/*if you decide not to set the body to the full height of the background image, set a bottom margin on the image to push the total page height down the desired 100px */
/* margin: 0 20px 110px 0;*/
}
</style>
</head>
<body>
<div id="header">
<h1>WERELDWINKEL HOORN</h1>
<ul id="siteNavigation">
<li><a href="index.html" title="home">Home</a></li>
<li title="produkten">
<ul>
<li><a href="herkomst.html" title="herkomst">herkomst</a></li>
<li><a href="herkomst.html" title="categorie">categorie</a></li>
<li><a href="fair_trade.html" title="fair_trade">fair_trade</a></li>
</ul>
</li>
<li><a href="bedrijven.html" title="bedrijven">bedrijven</a></li>
<li title="informatie">
<ul>
<li><a href="fair_trade.html" title="fair_trade">fair_trade</a></li>
<li><a href="fair_trade.html" title="fair_trade">fair_trade</a></li>
<li><a href="fair_trade.html" title="fair_trade">fair_trade</a></li>
</ul>
</li>
<li><a href="contact.html" title="contact">contact</a></li>
</ul>
</div>
<div id="maincontent">
<img width="365" height="550" src="homepage.png" class="img_left" alt="My alternate text inc as image does not display">
<p>In onze winkel staat een enthousiaste groep vrijwilligers klaar om u van dienst te zijn met een bijzonder assortiment produkten uit niet-westerse culturen: knuffels uit Sri Lanka, trendy <b>sieraden</b> en geurige <b>wierook</b> uit India, authentieke <b>muziekinstrumenten</b>, leuke <b>woonaccessoires</b> en bijzondere bureau-artikelen.</p>
<p>Bovendien verkopen we smakelijke <b>levensmiddelen</b> zoals koffie, thee, cacao, sauzen, chutneys en wijn.</p>
<p>Om ons assortiment aantrekkelijk te houden kopen we geregeld nieuwe produkten in, zodat het de moeite waard is om onze winkel regelmatig te bezoeken.</p>
<p>Koop je iets in een Wereldwinkel dan bevorder je bovendien de <b>eerlijke handel</b> en steun je de ontwikkeling van zilversmeden, pottenbakkers en koffieboeren op het zuidelijk halfrond.</p>
</div>
</body>
</html>
background: <-- shorthand for background-color, background-image, background-repeat, background-positionSo that makes it easy to see that if you the image to the right, all you have to change is:
transparent <--- background color - transparent because you want the texture of the big background image to show through the other images
url(hagedisjes.png) <--- the image - which of course would be different from the header image
no-repeat <-- makes sure the image is only painted once, rather than being painted multiple times until it fills the whole element
center <-- position the image in the horizontal centre
top <-- position the image at the vertical top
Since the image that is shown, is in the CSS I tried to solve this by giving the 2nd submenu (ul) an id,Fantastic thinking - exactly what this example does. It's "over-engineered", but I've laid it out so you can follow the steps.
<ul id="siteNavigation">
<li><a href="index.html" title="home">Home</a></li>
<li title="produkten" >
<ul id="product"> <--- add an id
... html continues ...
<li><a href="bedrijven.html" title="bedrijven">bedrijven</a></li>
<li title="informatie">
<ul id="inform"> <-- add an id
<li><a href="fair_trade.html" title="fair_trade">fair_trade</a></li>
... html continues
<li><a href="contact.html" title="contact">contact</a></li>
</ul>
ul#siteNavigation li ul {
/*background: transparent url(second-level.png); comment out or delete */
/* leave the rest of the rules because they will apply to both submenus*/
list-style-type:none;
position:relative;
/* Just watch top, width and height - they may need adjusting if the different sub-menus images are a differnt size. If they are, delete the property from here and add it to the rules you are creating below - just the same as has been done for the background-image*/
top:43px;
width:146px;
height:112px;
padding:0;
margin:0;
visibility:hidden;
}
/* insert a rule for the things that are specific to each of the sub-menus*/
ul#siteNavigation li ul#product {
background: transparent url(first-second-level-menu.png);
}
ul#siteNavigation li ul#inform {
background: transparent url(other-second-level-menu.png);
}