CSS - Menu Background Image Help
Hi:
I am having some problems getting the background image of a drop-down menu to do what I want. The drop-down menus have different lengths, and I have a gradient image which I would like to have repeat across (repeat-x) but on the y-axis, I want it to be scaled to fit the menu height which differs from drop-down to drop-down. I have the following code in my CSS file. Code: transparent url(../images/style1/submenu_bg.png) repeat-x 0 bottom I cannot figure out how to have the image scale on the y-axis. Any assistance would be appreciated. Similar TutorialsI've tried everything, with no luck. It's pointing to the right address, the css is loading. Why does the image not appear? div#main_menu { float: left; clear: both; width: 100%; height: 73px; background-image: url (images/button-banner.png) no-repeat; } div#main_menu ul { float: left; list-style: none; margin: 0; padding: 0; } div#main_menu ul li { float: left; height: 73px; margin: 0 15px; } div#main_menu ul li a { color: #7A5A46; float: left; margin-top: 17px; text-decoration: none; text-align: center; HTML: <div id="main_menu"> <ul> <li><a class="" href="#">Menu<br/></a></li> <li><a class="" href="/ordering/">Ordering Info<br/></a></li> <li><a class="" href="/photos/">Photos<br/></a></li> <li><a class="" href="/blog/">Blog<br/></a></li> <li><a class="" href="/about/">About Me<br/></a></li> <li><a class="" href="/contact/">Contact Info<br/></a></li> } Hi, I learned css a couple of years ago but am real rusty...anyways, here is an image that i wanted as the background to the top of the page. in the white space, i simply want a horizontal menu with 4 links. i cannot figure out how to position my links in that space correctly. any help appreciated! [/IMG]http://img251.imageshack.us/img251/1333/toplogoinfo.jpg[/IMG] here is the code i have so far: Code: !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Precision Truck Painting and Repair</title> <style type="text/css"> .body{ margin:0; padding:0; } #page { width: 800px; margin: 0 auto 0 auto; } #banner { background-image:url(images/jpegs/top_logo_info.jpg); height: 140px; background-repeat:no-repeat; } ul.nav { list-style-type: none; padding-left: 0; margin:0px 0 0 360px; font-family:Arial, Helvetica, sans-serif; } ul.nav li { display: inline; width:115px;} ul.nav a { text-decoration:none; } </style> </head> <body> <div id="page"> <div id="banner"> <div id="top"> <ul class="nav"> <li class="index"><a href="index.html">Home</a></li> <li class="painting"><a href="pages/painting_collision.html">Painting/Collision</a></li> <li class="painting"><a href="pages/body_trailer_repairs.html">Trailer & Body Repairs</a></li> <li class="index"><a href="pages/Contact_us.html">Contact Us</a></li> </ul> </div> </div> </div> </body> </html> I am looking to make a navigation menu similar to the following: http : / / www . coremediadesign.co.uk/website_design_company/about_core_media_design.html This is the sprite image they use. http : / / img819.imageshack.us/img819/8185/menuo.png I would like to accomplish the same thing. I am NOT looking for one long image with my entire menu in image format. I want a three-part background image/sprite like the one I posted above that is used as the background/hover/active by repeating it on the x-axis. I have tried for a long time to get this working but have not been able to. Please help me out. The layout I have going is a bit difficult to explain. Here's a diagram.. The area of importance is the header. The content and main head area are centered. The area to the left and right of the header are a <div>. However, as you can see, the background image on the left is different than the one on the right. I'm having difficulty making this work. the images can be stretched horizontally without a problem, but the two sides must meet in the middle beneath the header. I hope this makes sense. What I've got to do, I think, is tell the background image of the underlying <div> to stretch to 100%, and make this image 300px wide or so including both sides of the image and a split. The split would hide behind the header. I can't find a method to stretch the background image, though. Does anybody know of a better way, or a way to achieve this method at all without getting into completely different layouts? Thanks in advance for any assistance/suggestions. In short, I'm trying to get this one image to tile down the page to the bottom, underneath a static background image. Basically, it's a 2pixel high image that's ready to tile vertically, just having a tough time getting it to work. You can clearly see the problem here, a gap at the bottom: http://www.groundedgroup.com/clients/NWR/ Here's the relevant css: http://www.groundedgroup.com/client...WR-GG/style.css I've googled and subsequently tried out some solutions, but no luck. Got any ideas? Thanks in advance. PS - Is there a way to keep the spiders from indexing my links above? The site is on a test server, so I don't want the url indexed. Hi, I have a question about setting up the Body background-image via a linked external stylesheet. I have a index.html file and a myStyle.css file. I want to setup the background to load an image file, test.JPG. When I embed the following in my index.html, I see the background show up: ** inside index.html file ** <BODY STYLE="background-image: url(test.JPG);"> blah </BODY> BUT, when I define my background in the externally linked myStyle.css file, the background does not load: ** inside myStyle.css file ** BODY { background-image: url(test.JPG); } ** inside index.html file ** <LINK REL="stylesheet" TYPE="text/css" HREF="myStyle.css"> <BODY> blah </BODY> </LINK> Please help. thanks! Hi. Really hoping someone can help me with this... I'll try and explain this as best I can(!) Basically I've got a page containing a block of 9 images, with each linking to a video clip. At the moment I've got the CSS coded so that whenever the mouse is hovered over the 'infobar' (at the bottom of each image) it goes from having a transparent background with black text to having a grey background with white text. What I'm trying to achieve is that same effect whenever the mouse is hovered over any part of the image and infobar. The live online link can be found at: www.markmcm.co.uk/test/test.html The CSS is as as follows: Code: /* * Page Stylesheet */ body { font-family: Arial, Helvetica, sans-serif; background-color: #eaeaea; border:0; margin:0; padding:0; height: 100%; } a:link { text-decoration: none; } a:visited { text-decoration: none; } a:hover { text-decoration: none; } a:active { text-decoration: none; } #container { margin-left: auto; margin-right: auto; min-height: 100%; width: 936px; } * html #container { height: 100%; } #content { float:left; position: relative; height: 528px; width: 936px; z-index: 0; } .miniscreen1, .miniscreen2, .miniscreen3, .miniscreen4, .miniscreen5, .miniscreen6, .miniscreen7, .miniscreen8, .miniscreen9 { position: absolute; float: left; display: block; width: 312px; height: 176px; } .miniscreen1 { top: 0; left: 0; } .miniscreen2 { top:0; left: 312px; } .miniscreen3 { top: 0; left: 624px; } .miniscreen4 { left: 0; top:176px; } .miniscreen5 { left: 312px; top:176px; } .miniscreen6 { left: 624px; top:176px; } .miniscreen7 { left: 0; top:352px; } .miniscreen8 { left: 312px; top:352px; } .miniscreen9 { left: 624px; top:352px; } .info { height: 30px; top:3px; left: 40px; width: 265px; float: left; position: absolute; } .infobar { left:0px; position: absolute; top: 140px; width: 312px; height: 36px; outline: none; color:#000; background: url("data/infobar.png") no-repeat 0 0; z-index: 650; } .infobar:hover { background-position: 0 -36px; outline: none; color:#fff; } #infobar span { display: none; outline: none; } .clip_title { outline: none; font-size: 85%; font-weight: 700; vertical-align: top; text-align: left; } .clip_sub { outline: none; height: 13px; font-size: 80%; line-height: 13px; font-weight: 700; vertical-align: top; text-align: left; } And the HTML is: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Test Page</title> <meta name="description" content=" " /> <meta name="keywords" content=" " /> <meta name="generator" content=" " /> <link rel="stylesheet" type="text/css" href="page.css" media="screen" /> </head> <body> <div id="container"> <div id="content"> <span class="miniscreen1"> <a href="#"> <img src="img/clip1.jpg" width="312" height="176" border="0"> <span class="infobar"><span class="info clip_title">Test Clip 1<br><span class="clip_sub">123 Productions</span></span></span></a> </span></span> <span class="miniscreen2"> <a href="#"><img src="img/clip2.jpg" width="312" height="176" border="0"> <span class="infobar"><span class="info clip_title">Test Clip 2<br><span class="clip_sub">123 Productions</span></span></span></a> </span></span> <span class="miniscreen3"> <a href="#"><img src="img/clip3.jpg" width="312" height="176" border="0"> <span class="infobar"><span class="info clip_title">Test Clip 3<br><span class="clip_sub">123 Productions</span></span></span></a> </span></span> <span class="miniscreen4"> <a href="#"><img src="img/clip4.jpg" width="312" height="176" border="0"> <span class="infobar"><span class="info clip_title">Test Clip 4<br><span class="clip_sub">123 Productions</span></span></span></a> </span></span> <span class="miniscreen5"> <a href="#"><img src="img/clip5.jpg" width="312" height="176" border="0"> <span class="infobar"><span class="info clip_title">Test Clip 5<br><span class="clip_sub">123 Productions</span></span></span></a> </span></span> <span class="miniscreen6"> <a href="#"><img src="img/clip6.jpg" width="312" height="176" border="0"> <span class="infobar"><span class="info clip_title">Test Clip 6<br><span class="clip_sub">123 Productions</span></span></span></a> </span></span> <span class="miniscreen7"> <a href="#"><img src="img/clip7.jpg" width="312" height="176" border="0"> <span class="infobar"><span class="info clip_title">Test Clip 7<br><span class="clip_sub">123 Productions</span></span></span></a> </span></span> <span class="miniscreen8"> <a href="#"><img src="img/clip8.jpg" width="312" height="176" border="0"> <span class="infobar"><span class="info clip_title">Test Clip 8<br><span class="clip_sub">123 Productions</span></span></span></a> </span></span> <span class="miniscreen9"> <a href="#"><img src="img/clip9.jpg" width="312" height="176" border="0"> <span class="infobar"><span class="info clip_title">Test Clip 9<br><span class="clip_sub">123 Productions</span></span></span></a> </span></span> </div> </div> </body> </html> There must be a better (and easier?) way to do this. Any help would be very-much appreciated - and save an old bloke from tearing too much of his hair out(!) Hi I am redesigning my blog and took it down completely. I want to place the day's text post on the day's photo post on top of the latter, while graying out the photo. Is that possible without using flash? Hi Hoping someone might be able to help me. I'm working on a site but i can't for the life of me figure out how to get the background color to show. They sent me the index page and the two css style sheets for it. I can get the menu to do anything i want except the red background bar to show up. Hope someone can point me in the right direction. Thanks in advance for any help MsKazza This is the menu on the index page Code: <div id="menu"> <ul> <li class="active"><a href="index.html">home</a></li> <li><a href="design.html">design</a></li> <li><a href="printing.html">printing</a></li> <li><a href="websites.html">websites</a></li> <li><a href="marketing.html">marketing</a></li> <li><a href="prepress.html">prepress</a></li> <li><a href="contact.asp">contact</a></li> <li><a href="clients.html">clients</a></li> <li><a href="links.html">links</a></li> <li><a href="login.html">login</a></li> </ul> </div> this is the related css: Code: /* Menu */ #menu { width: 802px; height: 45px; margin: 0 auto; border-right: 1px solid #EDEBD5; } #menu ul { margin: 0; padding: 0; list-style: none; } #menu li { display: inline; } #menu a { display: block; float: left; width: 79px; height: 28px; border-left: 1px solid #EDEBD5; text-transform: lowercase; text-decoration: none; text-align: center; font-size: 1.2em; color: #FFFFFF; vertical-align: middle; font-family: Geneva, Arial, Helvetica, sans-serif; padding-top: 15px; padding-right: 0; padding-bottom: 0; padding-left: 0; } #menu a:hover { background: #F7F7F4; color: #990000; } #menu .active a { color: #FFFFFF; background-color: #600000; } Once again, Firefox displays my code correctly and IE does not. I wasn't going to bother working on it further if IE 7 displayed it correctly, but it does not either. Here's my menu. The HTML code is CMS generated, but I have taken out the links. http://www.jimandkris.com/menuoutput.html The problem is within the submenu background as shown he I found this fix on the PIE site, but it just made it worse, not better. Can anyone suggest an IE hack to me to fix this? Hey Guys, I have validated both my html and css. The only errors that come back for my css is that I have the same colour background and whatnot. BUT that's what I want. So there aren't really errors. Here is my page: jacenta.com/whichsbc What I have been attempting to achieve and been utterly failing is: If you goto the menu on the side and hover over you will see a light grey background show up. Basically I want that to extend to ethier ends of the box. Is there anyway for this to be done??? I've tried everything and I just can't seem to figure this one out. A good example of what I am looking for is in my drop down menu at the top when you select a heading and a dropdown comes down, hover over an item and a light blue background will show up. It's probally something simple... I know. But ahh. It's just so frusterating! If someone could help me out I would apperciate it so much! You all are such a great help. - Jacenta Code: div.top { border: 10px solid #CCCCCC; border-bottom-width: 0px; padding: 0px; background-image: url(menutile.jpg); } The code above yields this . It is uneven with the normal image, though both are the same size. I simply want to tile the bg image to the border even with the normal menu images. What am I doing wrong? I am trying to put labels below images on my new site design. See: www.jwsuretybonds*com/jw09 I figured out how to get them vertically aligned, but I am having problems with the horizontal, as when I change the browser size, they move. Here is one of the examples: Code: #homepage-bar h2.construction { position:fixed; top:225px; left:505px; } I tried changing to position: absolute; I also tried to use percentages on the left: I know this is easy, but I can't find the fix after googling for 30 minutes. Help! I'm trying to create a little background image for each image on this page. A kind of crappy looking polaroid type background image. It works fine in Firefox, but not in IE. Any ideas? http://www.rhizaowns.com/holly/index.php If you take at the link below I'm having trouble with the top menu. http://departments.brooklands.ac.uk/ifp/test/ I'm trying to use background images as buttons with normal xhtml text links. But I can't seem to get the text in the middle of the buttons. I think I may be going about this in the wrong way, so if anyone could take a look that would be great. Thanks Jemes Code: #topbar{ padding-top:18px; border: 0px solid #000000; background-image:url(../images/top.gif); background-repeat:no-repeat; height:120px; margin-left:16px; } #topmenu{ margin:32px 0px 0px 30px; font-size: 10pt; font-weight:bold; height:30px; } #topmenu ul{ margin:0px; padding:0px; list-style-type: none; } #topmenu ul li{ padding-right:4px; } .home{ float:left; display:inline; background-image: url(../images/home.gif); background-repeat: no-repeat; height:33px; width:45px; } .active{ float:left; display:inline; background-image: url(../images/top_active.gif); background-repeat: no-repeat; height:33px; width:106px; } .norm{ float:left; display:inline; background-image: url(../images/top_norm.gif); background-repeat: no-repeat; height:33px; width:106px; } #topmenu li a{ text-decoration: none; color: #AC5BA0; padding-right: 0.7em; height:30px; } I have a fairly simple page that is composes of a header and two cols. The left hand col is the menu which I would like to use with background images but these seem not to work. Any advice is appreciated. [Code] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "(URL address blocked: See forum rules)"> <html xmlns="(URL address blocked: See forum rules)"> <head> <!--Don't add anything above this line, you may change the DTD to match your page--> <title>Test Page</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <!--Uncomment the following line and remove the embedded style sheet if your style is external--> <style type="text/css"> body { min-width: 760px; margin: 0; padding: 0; text-align: center; } #wrapper { width: 720px; margin:0 auto; text-align: left; background-color: #CDCDCD; } #branding { width:720px; height:120px; } #content { width: 520px; float: right; } #mainNav { width: 180px; float: left; } ul { list-style: none; margin: 0; padding: 0; } /* =-=-=-=-=-=-=-[Menu Eight]-=-=-=-=-=-=-=- */ #menu8 { width: 200px; margin-top: 10px; } #menu8 li a { text-decoration: none; height: 32px; voice-family: "\"}\""; voice-family: inherit; height: 24px; } #menu8 li a:link, #menu8 li a:visited { color: #000000; font-weight: bold; display: block; background: url(images/menu8.gif); padding: 8px 0 0 20px; } #menu8 li a:hover { color: #257EB7; background: url(images/menu8.gif) 0 -32px; padding: 8px 0 0 25px; } #menu8 li a:active { color: #fff; background: url(images/menu8.gif) 0 -64px; padding: 8px 0 0 25px; } #footer { clear: both; width: 720px; background-color: #CDCDCD; border: 2px solid; } body{ background-color:#ffffff; } </style> </head> <body> <div id="wrapper"> <div id="branding"> <img border="0" src="images/Top Bar.gif" width="720" height="120" alt="Hawkesley Publishing Solutions"/> </div><!--End Branding--> <div id="content"> <p>Spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam.</p> <p>Spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam.</p> <p>Spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam.</p> <p>Spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam.</p> </div><!-- End of Content --> <div id="mainNav"> <div id="menu8"> <ul> <li><a href="home.php" title="Home"><b>Home</b></a></li> <li><a href="e-books.php" title="E-Books"><b>E-Books</b></a></li> <li><a href="e-learninig.php" title="E-Learing"><b>E-Learning</b></a></li> <li><a href="hoe.php" title="How To Books"><b>How To Books</b></a></li> <li><a href="about.php" title="About Us"><b>About Us</b></a></li> </ul> </div><!-- End menu8--> </div><!-- End of mainNav --> <div id="footer"> <p>spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam.</p> </div><!-- End Footer--> </div><!--End Wrapper--> </body> </html> [Code] I want to use php to get images from a database and display them as css background-image attributes I know that the css Code: #id { background-image: url ('path/file'); } works (obviously) and the html Code: <img src='image-generator-script.php'> also works but the css Code: #id { background-image: url ('image-generator-script.php'); } doesn't work for me. It seems as though it should work. Why place such a seemingly arbitrary limitation on CSS as only being able to display images from existing files? I've done lots of searching through documentation and on forums, but not found anything conclusive either way. A couple of people have said it works. But it doesn't for me. Is there some extra configuration step I'm missing? Does anyone know for a fact that it works? -- so I can know for sure that somewhere I'm making a blunder in my code. But the code is simple, and I don't see where it could go wrong. (As is always the case!!) I can see the image in the browser just by pasting in the script link to the address bar. I know that url() specifiers are relative to the location of the stylesheet, not the html document, but in this case the html, the css, and the php are all in the same directory. I can't see what I could be doing wrong, so it really looks like you can't do it. But why?? And why isn't it mentioned in the documentation? (At least in the placers I've looked.) If you store all your images in a database, how on earth can you display any of them in CSS except by using a script in the url() specifier? I've seen plenty of tips about generating css files from php (I already do it), but that won't help in this case. All I can think of is to have php write the image data from the database into a temporary file, and put that file name into the url() specifier. But what a horrible kludge!! I will be very grateful to anyone who can give me solid facts on this question. Andrew Blake I have a .jpg I am using as a background image. This is the code I am using for it. Code: <style type="text/css"> span.blacktext12{display:none} body{background-image:url(MY.JPG); background-attachment:fixed; background-repeat: no-repeat; background-color:FFFFFF;} table, td, a, body, input{background-color:transparent;border:none;border-width:0} </style> So I have it set up as a image that floats with you as you scroll. I also wanted to set up another image to float with the user while they scroll but HYPERLINK it and have it float in the bottom right corner. I do not want to achieve this by removing the first background but by adding it on top... Does anyone know how to accomplish this? Bottom right corner of the screen and float with the user as they scroll? im redoing my website to try and make a version of it that is more clean because i got sloppy and fixing up sloppy code for me is alot harder than just starting over. i havent been working on my site for a few weeks or too much scripting in general so i might be making a dumb mistake, heres my problem http://mrsako.gotdns.com/newest.php this is where im making the newest version of my site, its going to be using css you can view the html if you want, you can see i included <link rel="stylesheet" type="text/css" href="stylesheet.css" /> inside it some of the lines include a class im making for a <td> of the table Code: .topbarTD{ border-style: none; border-width: thin; padding:0; height:187px; max-width:1024px; width: expression(document.body.clientWidth > 1024 ? "1024" : "auto" ); background-image:url("images/banner.jpg"); background-repeat: no-repeat; text-align:right; vertical-align:bottom; } which sort of works. the text align attributes applied to the page as you can see the text get put on the bottom right and also theres a blcok of space showing theres 187px there where the image would be, but its not showing up, mrsako.gotdns.com/images/banner.jpg DOES exist this is the table Code: <table class="container" cellpadding="0" cellspacing="0"> <tr> <td class="topbarTD" colspan="2">should be here</td> </tr> <tr> <td rowspan="2"> <img src="images/leftspace.png" width="165" height="472" alt=""></td> <td> <img src="images/topspace.png" width="859" height="95" alt=""></td> </tr> <tr> <td> <img src="images/mainspace.png" width="859" height="377" alt=""></td> </tr> <tr> <td colspan="2"> <img src="images/bottombanner.png" width="1024" height="107" alt=""></td> </tr> </table> |