SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: DIV disaster

Hybrid View

  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2001
    Location
    Texas
    Posts
    598
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    DIV disaster

    I'm designing a new page to show picture one after the other. it uses Div tags all on the same page to display them: heres the code:


    <style type=text/css>.slides {align: center; position: absolute; top: 227px; left: 88; visibility: hidden}</style>
    ....
    <A href="javascript:showPreviousSlide()" target="_self">
    <img alt="Previous Slide" border=0 src="/Photo_Essay/photo_essay_back.gif"></A>
    <A href="javascript:showNextSlide()" target="_self">
    <img alt="Next Slide" border=0 src="/Photo_Essay/photo_essay_next.gif"></A>

    <div class=slides id=image1 style="VISIBILITY: visible"><img border=1 src="/Photo_Essay/christmas_walk01/christmaswalk01_11.jpg"></div>
    <div class=slides id=image2><img src="/Photo_Essay/christmas_walk01/christmaswalk01_02.jpg" border=1></div>
    <div class=slides id=image3><img border=1 src="/Photo_Essay/christmas_walk01/christmaswalk01_03.jpg"></div>
    <div class=slides id=image4><img border=1 src="/Photo_Essay/christmas_walk01/christmaswalk01_04.jpg"></div>



    Of course there is a javascript part but i'm having problems getting this to align correctly. It has a major discrepency in positioning in different browsers. Any ideas?
    and also if i put this inside a cell can i use relative position and if so how?

    Hope thats not too much to ask.

  2. #2
    .net install meltdown
    Join Date
    May 2001
    Location
    View Ridge
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think align:center; is valid CSS, although using html align="center" will work(in theory CSS margin-auto should work, but its not well supported, particularly by IE) but not when you set the CSS position to absolute. Depending on the layout your trying to achieve, you'll have to choose one.

    To position block level elements like div relative to the parent cell use percentage units for width, margin, padding etc. Check out the CSS "box model" at the w3c for some good info. Glish.com also has some good info on page layout techniques w/CSS.

    HTH

  3. #3
    No. Phil.Roberts's Avatar
    Join Date
    May 2001
    Location
    Nottingham, UK
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The correct way to center a block element is:

    margin-right:auto;
    margin-left:auto;

    Although this will more than likely have varying results.

    <div align="center"> is not allowed in XHTML Strict documents but I believe it is still allowed under XHTML Transitional.
    THE INSTRUCTIONS BELOW ARE OLD AND MAY BE INACCURATE.
    THIS INSTALL METHOD IS NOT RECOMMENDED, IT MAY RUN
    OVER YOUR DOG. <-- MediaWiki installation guide


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
  •