CSS - Dynamic Background Images?
Is it possible without any client side scripting to load in backgrounda.gif for 800x600 resolution and backgroundb.gif for any other resolution?
Server side scripting is ok but I was hoping for a CSS method although I am pretty sure it's not possible. Similar TutorialsThe 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. Given an element of a fixed width but varying heights, is there a way to give that element a gradient background that would scale to the height? I would be really impressed if someone could show me a way. Thanks. I'm not sure if the title describes exactly what I mean, but here it goes. I'm working on this website: http://denartcc.org/d/ The menu along the top has images that change position when you hover over them. The thing that I'm trying to do is create something that looks like this site's menu: http://www.aopa.org/ Notice how hovering over one of the menu items reveals another blue bar that contains more links. This is what I'm trying to create. Unfortunately I'm stuck when it comes to comparing these side-by-side, and I just don't know how to create that secondary set of links. The code I'm using is below. CSS: Code: #amenu { list-style: none; padding: 0; margin:auto 0 0 0; width: 930px; height: 30px; background-color: black; position: relative; border-bottom:medium solid white; float:left; } #amenu ul { display: none; position: absolute; } #amenu ul li { } #amenu li a { display: block; text-indent: -900%; position: absolute; outline: none; } .home { width: 120px; height: 30px; background: url(../images/menu/home.png) no-repeat; left: 20px; top: 0px; } .airspace { width: 163px; height: 30px; background: url(../images/menu/airspace.png) no-repeat; left:160px; top:0; } .community { width: 174px; height: 30px; background: url(../images/menu/community.png) no-repeat; left:343px; top:0; } .controllers { width: 195px; height: 30px; background: url(../images/menu/controllers.png) no-repeat; left:537px; top:0; } .pilots { width: 174px; height: 30px; background: url(../images/menu/pilots.png) no-repeat; left:752px; top:0; } #amenu a:hover { background-position: left bottom; } #amenu a:hover span{ display: block; } HTML Code: <div> <ul id="amenu"> <li><a href="#" class="home">Home<span></span></a></li> <li> <a href="#" class="airspace">Airspace<span></span></a> <ul> <li>ZDV Airports</li> <li>Preferred Routing</li> <li>Try Something New</li> </ul> </li> <li><a href="#" class="community">Community<span></span></a></li> <li><a href="#" class="controllers">Controllers<span></span></a></li> <li><a href="#" class="pilots">Pilots<span></span></a></li> </ul> </div> this was my target I got a image with two transparant shapes. Behind those shapes I would like to show 2 other images. |-------1-------| | |-----| |----| | | |...2..| |..3..| | | |____| |____| | |_____________| Image 1 should be on top z-Index Image 2 should under image 1, a part of the image should be visible. Image 3 should under image 1, a part of the image should be visible. Image 2 and 3 should be dynamically replaceable. My solution The image in front has transparant spaces at 20,40 and 20,120 both 60,60 sized. Each Image do have a offset, in case a part of the image should be displayed not starting from 0,0. Code: This is a drawing. _____1_____ | _____ | | | | | | |..2..| | | |_____| | |__________| 1. whole image ( should be bigger then 60,60 ). 2. the part that I want to show ( 60, 60 ). With javascript I can hide/unhide the images and I use the imageLn or imageRn as selector id I hope you can use it also. My Style Code: #headerContainer { float: left; position: relative; z-index:4; width: 200px; height: 100px } #headerImageLeft { position: absolute; z-index: -1; top: 20px; left: 40px; width: 60px; height: 60px; display: inline } #headerImageRight { left: 120px; top: 20px; width: 60px; height: 60px; z-index:-2; position: absolute; display: inline; } Html code Code: <td> <div id="headerContainer"> <img src="header-kop-test.gif" alt="" width = "200" height="100" /> <div id="headerImageLeft" > <div id="imageL1" style="top:-8px;left:-20px;position:absolute;"> <img src="header-links-test.gif" alt="" /> </div> <div id="imageL2" style="top:-10px;left:-10px;position:absolute;"> <img src="header-links-test2.gif" alt="" /> </div> </div> <div id="headerImageRight" > <div id="imageR1" style="top:-30px;left:0px;position:absolute;"> <img src="header-rechts-test.gif" alt="" /> </div> <div id="imageR2" style="top:-10px;left:-18px;position:absolute;"> <img src="header-rechts-test2.gif" alt="" /> </div> </div> </div> </td> My questions: Can I optimize this code? Is this working on the most browsers? or are there know issues? Greetz and thanks R Hello, as the subject states I have a question about whether IE can display a background image on a tr and a td correctly. I have a table row with a repeating background then in the first cell in that row I have another background image that goes in the top left corner with a transparent background color on the cell so that the tr background can show though. This works as it should in all browsers except IE where only the td background image appears and its transparent to the page background not the tr background. This is the css: Code: .professor_forum_row { background: #ffffff url(../images/author_post_background.jpg) repeat top left; } .professor_corner_tab { background: transparent url(../images/article_sticky_author.jpg) no-repeat top left; } the html is just a table with those classes assigned to the row and first td. Any ideas on why this is happening? Thanks, Ryan Hi there, hopefully someone can help me out with some background image issues. I simply want a right hand section on my site, where i can fill it with content and it can expand appropriately as per the content and display a top, middle and bottom background image. this is because the style of the site has curved edges, so this will be a top image with the curves, a centre image and a bottom image with bottom curves. here is my code but none of the top or bottom background images show. please help, thanking you in advance. css: #feature { float:right; width: 287px; height: auto; } .featuretop { background-image:url(../images/css/featuretop.gif); background-position:top; background-repeat:no-repeat; } .featuremiddle { background-image:url(../images/css/feature.gif); background-position:center; background-repeat:repeat-y; } .featurebottom { background-image:url(../images/css/featurebottom.gif); background-position:bottom; background-repeat:no-repeat; } html code: <div id="feature"> <div class="marTOP10"> <div class="featuretop"></div> <div class="featuremiddle"></div> <div class="featurebottom"></div> </div> </div> K. I have my content bg which is to repeat, but I want to put like another background image set to the right in the content box. HTML Coding ************* <div id="special_feature_top"> <img src="images/specialfeatures.jpg" width="800" height="30" alt="" /> </div> <div id="special_feature_mid"> <img src="images/imagegalleryfeature.jpg" width="193" height="178" alt="Image Gallery" /> <img src="images/jointodayfeature.jpg" width="193" height="178" alt="Join Battle Glory Today!" /> <img src="images/forumsfeature.jpg" width="193" height="178" alt="Forums" /> </div> <div id="special_feature_btm"> <img src="images/specialfeatures_btm.jpg" width="800" height="30" alt="" /> </div> CSS Coding ************* #special_feature_mid { padding: 1px 0px 1px 10px; background-image: url('images/content_bg.jpg'); } That's the coding for the image now just with the content_bg. Now the other image I just want set to the background also so text can over lap or other images. It's a really nice opacity image that blends in perfect. I just want it in background also positioned to the right. thanks Matta Hello, I'm new to Dev Shed, I hope I won't seem like a fool here Is there any way to have to background images? I mean, I want to have a heading background image, and a footer background image to the same table. longing to your replies>>>> Is there some way to rig CSS to display 2 separate background images. I wanted to put the 2 images on opposite sides. I tried, but both IE 6 and Firefox 1.0.2 displayed only 1 bg image. Anyone got a suggestion? Edit - Oh yeah...this is for the BODY tag. I thought I ought to mention that. I have a site that will be relying heavily on background images sitting behind all the tables. These backgrounds will work in concert with the overall background-color: property. My question is this, on the style sheet, of which I would like to have ONE. Is there a way to change entire background-images for each page within the site. In another post, we went over how to change images within the same <div> by simply making the <div> a holder and swapping the image on each page by using something like: <div id="image" class="page_two"> Is there a way to do something similar using an entire background image? Or do I need a separate style sheet for each page? Perhaps the main style sheet which has a body like this body { margin:0px; } and then attach an additional style sheet to each page that supersedes the body tag in the main sheet? I hope I am making sense... thanks jon Hi Folks, I've designed an H1 page heading within a DIV with rounded ends. and HTML text inbetween. It should appear as a horizontally expanding and contracting capsule. I can make one end rounded with a CSS background image in the DIV or the H1 - but how can I do the other? No tables allowed here and it has to be done only in the stylesheet. I've tried a BG in the DIV and a BG in the H1 but they don't line-up, even when there's no padding or margins. Is it possible to somehow attach an image to one side of an element? Thanks John Hi I have a table which i want to add 2 background images too. what i have is. one image with no-repeat at the top. Then for the rest of the table, i want to have a gradient background. Is this possible? Help please. When I add the extra <div> the background disappears. Background image appears behind "Testing" <body> <div id="siteinfo"> <div id="fullinfo"> <h1>Testing</h1> </div> </div> </body> Background image disappears <body> <div id="siteinfo"> <div id="fullinfo"> <div id="myinfo"> <h1>Testing</h1> </div> </div> </div> </body> Stylesheet entries: body { background-color: #DADADA; background-image: url(/background2.gif); background-position: center; background-repeat: repeat-y; } #siteinfo { position: relative; margin-right: auto; margin-left: auto; width: 800px; } #fullinfo { position: relative; top: 10px; padding-left: 0px; padding-right: 25px; } #myinfo { position: inherit; float: right; width: 600px; } All help appreciated. http://www.brendanclements.com/UPS/ Code: @charset "utf-8"; /* CSS Document */ body{ background-color:#000; text-align:center; min-width:800px; background-image:url(images/lft.jpg), url(images/rht.jpg); background-repeat:repeat-y, repeat-y; background-position:top left, top right; } table{ background-color:#000; border:none; border-style:none; min-width:800px; width:75%; margin-left:auto; margin-right:auto; } td{ color:#FFF; border:none; border-style:none; text-align:center; } WHY WHY WHY WHY! lol, this is very frustrating. I have 2 background images, one for the left side to repeat down and a mirrored one on the right. I have done my research, I have tried multiple ways posted online to layer background images to have more than one. But it won't work. I have verified the background url's which work when there is only one, but not when I try to have two. I know I could get a workaround with a div but I want to know why this is not working and don't want to make my code more sloppy. Thank you. Hey all I'm trying to get to images to go to the sides of my content div. I've been looking on Google and everyone says you cant have 2 background images on 1 div (well is CSS2 anyways) is there any other ways of achieving this? also firefox is putting a space between my nav div and my content div, but IE7 doesn't, any ideas? Heres my HTML: Quote: <!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=utf-8" /> <title>RWD</title> <link href="rewebdesstyle.css" rel="stylesheet" type="text/css" /> </head> <body> <!-- Container --> <div id="l_container"> <!-- Banner --> <H1>Reflective Web Design</H1> <!-- Navigation --> <div id="l_nav"> <br /> Home News Bio Portfolio Gallery Links Contact</div> <!-- close nav --> <!-- content --> <div id="l_content" class="l_cont_left"> <p> </p> <p> </p> </div> <!-- close content --> </div> <!-- close container --> Heres my CSS: Quote: body { text-align: center; margin: 0px; padding: 0px; background-color: #666666; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: #FFFFFF; } h1 { background-color: #666666; background-image: url(images/l_banner.jpg); background-repeat: no-repeat; height: 150px; width: 1024px; color: #FFFFFF; text-indent: -9999em; margin: 0px; padding: 0px; } #l_container { margin-left: auto; margin-right: auto; width: 1024px; text-align: left; } #l_nav { position: relative; height: 60px; width: 1024px; background-image: url(images/l_nav.jpg); color: #666666; font-size: 14px; font-weight: bold; text-align: center; word-spacing: 4ex; } .l_cont_left { background-image: url(images/l_left.jpg); background-repeat: repeat-y; background-position: left top; position: relative; width: 25px; } .l_cont_right { background-image: url(images/l_right.jpg); background-repeat: repeat-y; background-position: right top; position: relative; width: 25px; } #l_content { position: relative; width: 1024px; background-color: #7F969E; margin: 0px; padding: 0px; } #l_footer { position: relative; height: 67px; width: 1024px; } Here's where its hosted what i want it to look like (different fonts tho) What ive got so far Cheers Lance Hi all. I've tried searching the net but every solution either isn't applicable or doesn't work. My problem is that all my CSS background images are not displaying at all in ie7. they are called in via link id. so: PHP Code: <a href="javascript:void(0)" id="cus" onClick="changeCus()"><img src="/images/space.gif" height="30" width="50" alt="" title="Customer Ratings" /></a> fairly simple stuff. the corresponding css is PHP Code: a#cus{background:url("../images/custM.png")no-repeat;left:-140px} I have treid changing the link as in ../../images... but that was dumb. Adding a background position. Adding display:inline. Adding display:block. Can anyone please aligten me as to why all my css images are failing. It works fine in FireFox. My doctype is set to strict. It is the correct path to the images. The images are on the server. Any help would be greatly apprcieated. Thanks in advance Jaza I am writing my site in XHTML 1.1 (application/xhtml+xml) entirely using ems. The page scales really nicely with browser text resizes however all of my rounded corners (background images), image bullet points, and any other background images do not. Is there any way to specify the background image width in ems? I think I'm going to have to mix presentational images with content otherwise. I have a website that I am trying to add some graphical enhancements to. I made them, and I think they look great! The problem is that they do not look the same when viewed in IE and I am not even sure where to start fixing them, as the problem doesn't make sense to me. starcraft-source.com/sandbox/ That is the URL to the page. It works great in FF but as I have said IE is messed up. Any help anyone can offer would be awesome. Thank you in advance. This puzzles me for this is the first time EVER that it is not working. I have "background-image" coding and NONE of those images are even showing up, yet when i add them on the index file as a normal image all is well... Any ideas? Ive got three divs all nested in a row. The idea is to have the main div (body tag) contain the background image that composes the color. Then the next div contains the upper left hand image and the next div contains the lower right hand image. The problem is this. When I specify "top-left" for the image the image is positioned to the top left. When I specify "bottom-right" for the image in the next div, instead of going to the bottom right, the image ends up all the way over on the top left. why is that? here are my three divs: Code: body { font-family: Arial, Helvetica, sans-serif; font-size: 12px; text-align: center; margin: 0px; border: 3px solid black; background-image: url(http://www.doublethinkdesigns.com/pics/dtdbg.jpg); background-repeat: repeat; /* */ } div#outer { margin: 0px; border: 3px solid white; background-image: url(http://www.doublethinkdesigns.com/pics/upper-left-fan.gif); background-position: top-left; background-repeat: no-repeat; } div#inner { margin: 0px; border: 3px solid black; background-image: url(http://www.doublethinkdesigns.com/pics/lower-right-samurai.gif); background-position: right; background-repeat: no-repeat; } |