Results 1 to 2 of 2

Thread: problem with div (layers)

  1. #1
    Join Date
    Mar 2008
    Posts
    1
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default problem with div (layers)

    hello,

    i have a problem with this code :

    <HTML>
    <HEAD>



    <STYLE type=text/css>.centerdiv {
    TEXT-ALIGN: center
    }
    .centerdiv>div{
    MARGIN: 0px auto;
    }
    </STYLE>


    </SCRIPT>

    </HEAD>
    <BODY>
    <DIV class=centerdiv>
    <div id=Layer0 style="z-index: 0; position: relative;"> <IMG height=600 src="img.jpg" width=780>
    <DIV id=Layer1 style="Z-INDEX: 1; LEFT: 283px; WIDTH: 117px; POSITION: absolute; TOP: 479px; HEIGHT: 44px;">text 1</DIV>
    <DIV id=Layer2 style="Z-INDEX: 2; LEFT: 50px; WIDTH: 349px; POSITION: absolute; TOP: 218px; HEIGHT: 115px;">text 2</DIV>
    </div>
    </DIV>
    </BODY>
    </HTML>

    in internet explorer looks like i wanted to (layer0 centered and layers 1 and 2 related to 0) but in firefox layer 0 is centered and layers 1 and 2 to left...
    i read and read for two days and i can't find a solution for this so pls if anyone can help me

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Quote Originally Posted by vml79 View Post
    in internet explorer looks like i wanted to (layer0 centered and layers 1 and 2 related to 0) but in firefox layer 0 is centered and layers 1 and 2 to left...
    i read and read for two days and i can't find a solution for this so pls if anyone can help me
    It's not clear what you want to do.

    It looks like you want to center the content on the page, have the image in layer 0 as a background and the content in layer 1 and 2 above it.

    To fix YOUR code, you could simply just add a width to layer 0 so that the content within it isn't overflowing.

    Code:
    <div id=Layer0 style="z-index: 0; position: relative;width:780px;"> <IMG height="600" src="img.jpg" width="780">
    Also note the quotes that I added around the width/height of your image. You should really be using CSS for this by the way.


    Now, some suggestions:
    If what you want to do is indeed what I stated above do this:

    HTML Code:
    <div id='centerdiv'>
            <div id='layer1'></div>
            <div id='layer2'></div>
    </div>
    Center center div on the page using this technique: http://www.milov.nl/code/css/verticalcenter.html

    Next, you can add a background via CSS so you're not messing with z-index and positioning etc...
    http://www.w3schools.com/css/css_background.asp

    If you're overlapping layer 1 and 2, you will need to use the absolute positioning and z-index (make sure centerdiv as a CSS value of position:relative if you do this).
    http://www.echoecho.com/csslayers.htm

    If not, you probably don't need to add any CSS to those divs.


    HTH

  3. The Following User Says Thank You to Medyman For This Useful Post:

    vml79 (03-08-2008)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •