Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: DIV over flash - absolute position problem

  1. #1
    Join Date
    Aug 2007
    Location
    MO USA
    Posts
    106
    Thanks
    37
    Thanked 0 Times in 0 Posts

    Default DIV over flash - absolute position problem

    I am placing an image over the flash. There is no other work around other than placing the div on top of the flash movie. The problem i face is, i am setting "position:absolute" - when i maximize my window on a larger screen, the image (div) is nowhere near the flash file, it is way apart. How to position the image (div) over the flash so that no matter the browser is maximized or shrinked, it stays in the same place.

    Please help.

    Thanks.

  2. #2
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    You can put the image inside the same div as the flash and position relative to the div.

  3. #3
    Join Date
    Aug 2007
    Location
    MO USA
    Posts
    106
    Thanks
    37
    Thanked 0 Times in 0 Posts

    Default

    Snookerman, thanks for the reply. The problem is half the image needs to be outside the flash please see the image below.


  4. #4
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    There's no problem, here are the basics of what you need to do:
    HTML Code:
    <div>
      <div id="image">Insert image here</div>
      <div id="flash">Insert flash here</div>
    </div>
    Code:
    #image {
    	background-color:#0099ff;
    	height:200px;
    	width:300px;
    	position:fixed;
    	margin-left:100px;
    	z-index:2;
    }
    #flash {
    	background-color:#ccff33;
    	height:300px;
    	width:600px;
    	position:fixed;
    	margin-top:100px;
    }
    Last edited by Snookerman; 11-14-2008 at 07:57 AM.

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    There is no fixed positioning in IE 6, and it may even behave oddly in some browsers that do support it, especially with a container that isn't positioned, try:

    HTML Code:
    <div id="flashimage">
      <div id="flash">Insert flash here</div>
      <div id="image">Insert image here</div>
    </div>
    Code:
    #flashimage {
    position: relative;
    height: 300px;
    width: 600px;
    }
    #flash {
    height: 300px;
    width: 600px;
    }
    #image {
    height: 200px;
    width: 300px;
    position: absolute;
    left: 50px;
    top: -100px;
    }
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    I think your solution will put the image 100px off the page.

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Snookerman View Post
    I think your solution will put the image 100px off the page.
    It might. It will put it 100px toward the top relative to the container (id="flashimage" division). As long as the container isn't at the top of the page though, it will work out fine.

    What I think that you might not understand is that once an absolutely positioned element is placed inside a relatively positioned one, its positioning is relative to the that container, not to the page in general.

    We could always ensure that it won't go off the top of the page by adding:

    Code:
    #flashimage {
    margin-top: 100px;
    position: relative;
    height: 300px;
    width: 600px;
    }
    But that may or may not be needed, and may or may not be desirable.
    Last edited by jscheuer1; 11-14-2008 at 03:51 PM. Reason: spelling
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. The Following User Says Thank You to jscheuer1 For This Useful Post:

    me_myself (11-14-2008)

  9. #8
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    I see what you mean, but is it really necessary to position the outer container, or even have one? Would this work?
    HTML Code:
    <div id="image">Insert image here</div>
    <div id="flash">Insert flash here</div>
    Code:
    #image {
    	height:200px;
    	width:300px;
    	position:relative;
    	margin-left:100px;
    	z-index:2;
    }
    #flash {
    	height:300px;
    	width:600px;
    	position:relative;
    	margin-top:-100px;
    }

  10. The Following User Says Thank You to Snookerman For This Useful Post:

    me_myself (11-14-2008)

  11. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The problem with using only relative positioning is that the elements so positioned still require layout space. This may be OK, even desirable in certain cases. But consider that the image in our example will require 200px of vertical layout, but visually (since we are moving it) it only appears to need 100px vertical space. What using absolute positioning does is to allow the image to take up no layout space. This then allows you to have it overlay other content on the page (not just the flash, but that too) without adding any height to the document.

    Now, you try to deal with that with:

    Code:
    #image {
    	height:200px;
    	width:300px;
    	position:relative;
    	margin-left:100px;
    	z-index:2;
    }
    #flash {
    	height:300px;
    	width:600px;
    	position:relative;
    	margin-top:-100px;
    }
    That will 'neutralize' the added 100px vertical layout space in a different way, by removing it from the flash div. However, we will still have the added 100px horizontal layout space created by the image's division's left margin. This may or may not prove problematical in relation to the rest of the markup, particularly if anything is to the immediate right of the image/flash combo.

    Once you have a container to represent the layout of these two combined divisions, it is a bit easier to adjust its margins as needed to get optimal document flow.

    So it really is a matter of what works out best in the overall layout.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  12. The Following 2 Users Say Thank You to jscheuer1 For This Useful Post:

    me_myself (11-14-2008),Snookerman (11-14-2008)

  13. #10
    Join Date
    Jul 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    This maybe the answer your looking:

    First adjust the Z-index (z-index:-1; generally works)

    Specify the flash window mode:

    'wmode', 'opaque', or something like this:

    <script type="text/javascript">
    var so = new SWFObject("myFlashBanner.swf", "mymovie", "770", "150", "7", "#336699");
    so.addParam("wmode", "opaque");
    so.write("flashcontent");
    </script>

    EXPLANATION:

    In Flash There are three window modes. Windowless mode allows you to take advantage of the transparent movie, absolute positioning, and layering capabilities available in the browser. They are controlled with the wmode parameter in the object tag. The default mode is available by either choosing not to specify any wmode, or by using wmode="window". We'll look briefly at the explanation of the three modes

    Window: Use the Window value to play a Flash Player movie in its own rectangular window on a web page. This is the default value for wmode and it works the way the classic Flash Player works. This normally provides the fastest animation performance. This will cause the flash movie to play on top and ignore any Z-Order settings. It is the default so if you do not specify anything this is what you get. This why some of use have no hair left in our heads.

    Opaque: By using the Opaque value you can use JavaScript to move or resize movies that don't need a transparent background. Opaque mode makes the movie hide everything behind it on the page. Additionally, opaque mode moves elements behind Flash movies (for example, with dynamic HTML) to prevent them from showing through. You can also layer items on top of movie by setting its ZOrder down in the stacking order. Opague is faster than transparent. So use this setting you do not need transparency.

    Transparent: Transparent mode allows the background of the HTML page, or the DHTML layer underneath the Flash movie or layer, to show through all the transparent portions of the movie. This allows you to overlap the movie with other elements of the HTML page. Animation performance might be slower when you use this value.

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
  •