August 6, 200719 yr I am making a blog and as part of my template I am wanting to have my header and then another image on the side of that using the z-index: 2; to make it that layer about. so here is the css. .splash { z-index: 2; width: 135px; height: 386px; margin: 0 auto; position: relative; left: 450px; top: 0px; background: url('images/splash1.png'); } and this is the code for the header. (its a wordpress blog btw.) <!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 profile="http://gmpg.org/xfn/11"> <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" /> <title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?></title> <meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats --> <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" /> <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" /> <link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" /> <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" /> <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" /> <?php wp_get_archives('type=monthly&format=link'); ?> <?php wp_head(); ?> </head> <body>[b]<p class="splash">welcome</p>[/b] <div class="main"> <div class="top"> <div class="topl"> <h1><a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a></h1> </div> <div class="topr"> <form method="get" id="searchform" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <p><input type="text" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="search_query" /> <input type="submit" class="searchbutton" value="Search" /></p> </form> </div> </div> <div class="shortnfo"> <div class="menuitems"> <ul> <li class="page_item"><a href="<?php bloginfo('url'); ?>">Home</a></li> <?php wp_list_pages('title_li='); ?> </ul> </div> <div class="welcome"> <h2>Welcome</h2> <p><?php bloginfo('description'); ?></p> </div> </div> and the link to my site is: http://www.arctosdesign.com/blog you should see the layout as it should be but then a nice watery image above that which is the image i am wanting to move. if anyone could give me some advice or tips as to how to sort this i would really appriciate it. thanx
August 6, 200719 yr z-index only works for position: absolute. If you set the parent of .splash to position: relative; and then set .splash to position: absolute you'll be able to position .splash within the parent of .splash.
August 7, 200719 yr z-index is not only for position absolute. If you have a float-left block element of fixed width and overflow "visible", followed by something like a float-left textarea, then the text will be hidden behind the textarea. set the first element to z-index 20 or similiar and you will see the text above the textarea.
August 15, 200719 yr What you may also want to do is to use background images in the different tags to place them one on top of the other using absolute positioning and z-index. You have to rememeber hovever that if you want the images to have transparency while overlaping on each other than - again Internet Explorer v6 doesn't support transparency of the .png - so you'd have to use transparent .gifs. Demo is available here. Here's how to do it. First create a simple structure like for instance: <div id="wrapper"> <h1>Some text with the keywords</h1> <h2>Some more secondary keywords</h2> </div> Now just apply styling to it: body { font-family: Verdana, Arial, Helvetica, sans-serif; margin: 0px; padding: 20px 0px 20px 0px; text-align: center; } #wrapper { padding: 0px; width: 800px; margin: 0px auto 0px auto; height: 300px; position: relative; } h1, h2 { text-indent: -999999px; display: block; margin: 0px; padding: 0px; font-size: 11px; position: absolute; overflow: hidden; background-attachment: scroll; background-repeat: no-repeat; background-position: 0px 0px; } h1 { background-image: url(01.gif); height: 228px; width: 222px; left: 50px; top: 30px; z-index: 0; } h2 { background-image: url(02.gif); height: 201px; width: 141px; left: 210px; top: 40px; z-index: 1; } In this example we are using wrapper with relative position and h1 and h2 tags which will display our images in the background. h1 and h2 tags have absolute position, text-indent of -999999px (this is to get read of the text inside of the tags) hidden overflow and block display. These are main elements which make the whole magic. Using z-index you can control wether first or second image is display on top of the other. This is very good approach when you have some keywords and want them to be "invisible" - yes - this is completely acceptable method - Google will read you keywords and you will not get a bad mark for this. Sorry for images not being very 'sexy' but I've made them very quick for demonstrating purposes. I hope you'll find it useful.
Create an account or sign in to comment