【问题标题】:Attempting to use CSS top property on a SWF file, but it's not working尝试在 SWF 文件上使用 CSS 顶部属性,但它不起作用
【发布时间】:2010-05-24 22:22:06
【问题描述】:

我正在尝试定位我的 Flex 应用程序,使其位于页面下方,但我无法使其正常工作。它仍然出现在左上角。这是 HTML,任何帮助将不胜感激!

<html lang="en">
<head>
   <title>Page</title>
   <style type="text/css">
       body { margin: 0px; overflow: hidden; }
       #swf {top:50%;}
   </style>

   <script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
   <script type="text/javascript">

   swfobject.embedSWF( "link_to_the_swf", "swf", "100%", "100%", "10.0.0", "playerProductInstall.swf", flashVars, params );
   </script>
</head>
<body scroll="no">

   <div id="swf">
      <p>Alternative content</p>
    </div>

</body>
</html>

编辑:阅读this message 后,我尝试将 swf div 包装在另一个 div 中,并在父 div 上设置 top 属性,但它不起作用。

【问题讨论】:

    标签: css flash flex4 swfobject


    【解决方案1】:

    您不能单独使用top。您需要将div 提供给position: relative 或使用margin-top / padding-top

    【讨论】:

    • 非常感谢,效果很好。其他答案也很方便!
    【解决方案2】:

    top 需要静态以外的定位,这是默认设置。试试:

    #swf {position:relative; top:50%;}
    

    但是,如果你想把它放在一个大容器的中间并让它居中而不是从中间开始向下你可以这样做:

    #swf {margin-top: auto; margin-bottom: auto;}
    

    【讨论】:

      【解决方案3】:

      尝试给身体position: relative。然后将position: absolute(或relative我想)添加到#swf

      【讨论】:

        【解决方案4】:

        试着给身体一个高度。像 body { height: 100%; }

        【讨论】:

          猜你喜欢
          • 2012-07-20
          • 2020-09-07
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2022-01-05
          • 2021-12-19
          • 1970-01-01
          相关资源
          最近更新 更多