2

I am relatively new to CSS .And I am facing the following problem in my page lay out .

I have looked at other posts but could not find an answer . The problem is when I specify

position:absolute within #logo #logoimg it does not load . However If I remove

position:absolute #logoimg is loaded correctly . I am trying to learn how to position divs by

creating absolute divs within relative divs .

My html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>New Web Project</title>
        <link rel="stylesheet" href="style.css" type="text/css" media="screen"  charset="utf-8"/>
    </head>
    <body>
        <div id = "wrapper">
            <div id = "header"> <img  src="images/banner.png" /> </div>
            <div id = "content">
                <div id="logo">
                    <div id="logoimg" > czcz </div>
                </div>
            </div>
        </div>
    </body>
</html>

My CSS

body {
  margin: 0;
  padding: 0;
}


#header {
    background: url('images/banner_tile.jpg') ;
    height: 96px;
    width: 100% ;
}

#header img {
    display:block;
    margin: auto ;
}

#content img {
    display:block;
    margin: auto ;
}

#content {
    /*overflow:auto ;*/
    background: url('images/body_tile.png') ;
    height: 100% ;  
    width: 100%  ;
}

 #logo { position:relative; height: 100px ; }

 #logo #logoimg {
    position:absolute ; 
    top:300px ;
    left:700px ;
    width:398px ;
    height:200px ;
    background: url('images/body_sprite.png');
    z-index: 1;
 }
4

1 回答 1

0

与猴子一起玩的整洁小提琴:http: //jsfiddle.net/TjQLf/

于 2012-08-03T14:07:08.870 回答