如何在一个已经插入SWF或IMG的DIV上再层叠一个DIV?由于对CSS定位一直学艺不精,因而被这个问题困扰了很久,今天终于悟出了解决方法,小小的为自己HIGHT一个。
比如
<DIV id=topright> <script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','254','height','114','src','images/top','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','wmode','transparent','movie','images/top' ); //end AC code </script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="254" height="114"> <param name="movie" value="images/top.swf" /> <param name="quality" value="high" /> <param name="wmode" value="transparent" /> <embed src="images/top.swf" width="254" height="114" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="transparent"></embed> </object> </noscript> <DIV id=topnav><a class="topIcon1" href="#">设为首页</a><a class="topIcon2" href="#">加入收藏</a></DIV></DIV>
需要将topright也就是父级定义一个position:relative,这就是我通常用绝对定位时left或top值总是以body为绝对值的源头了,一旦不给父级定义position,自然出不来想要的效果。而有了它,也就简简单单仅需
#topright { width:254px; height:114px; float:right; text-align:left; position:relative; } #topnav { width:146px; height:24px; color:#24589D; line-height:24px; position:absolute; top:0px; right:0px; z-index:800; }
这样一切就搞定了。