现在的位置: 首页 > 综合 > 正文

[ZT]100% height and 100% width XHTML Flash embed

2012年08月09日 ⁄ 综合 ⁄ 共 1238字 ⁄ 字号 评论关闭

I’ve been asked this question a few times in the last couple of months, so I thought I would put together an example page to show how you can get Flash content to stretch to 100 percent height and width without using tables.

It’s actually pretty simple. Here’s some of the CSS I used:

代码

/* hide from ie5 mac \*/
html
{
height
: 100%;
overflow
: hidden;
}
#flashcontent
{
height
: 100%;
}
/* end hide */
body
{
height
: 100%;
margin
: 0;
padding
: 0;
background-color
: #eee;
}

Setting the html tag to 100% height and then placing the Flash movie inside a div that is also set to 100% height does the trick.

Notice the overflow: hidden on the html element since IE will show the scrollbar even if the page doesn’t need to scroll. This line will force IE to hide any content that is outside of the browser window, and therefore hide the scrollbar as well.

To embed the Flash movie, I used my FlashObject Javascript embed so the page will validate and I have access to all the various Flash parameters I might need to pass to the Flash movie.

UPDATE (01-05-2005): Someone pointed out a bug with this in IE 5 on Macintosh, so I’ve updated the CSS a bit to make it work. Current verified working browsers are: IE 6 (PC), IE 5 (Mac), Safari, Firefox (PC, Mac), Mozilla (PC, Mac), Opera 7.54 (Mac).

If you have other browsers available for testing I would love to know if this displays properly or not. I’m mainly interested in IE 5 and 5.5 on a PC.

UPDATE (1-17-05): Tested in IE 5.01 sp2 and IE 5.5 sp2 on a pc today, and it works great.

抱歉!评论已关闭.