【问题标题】:How can you center a swf object?如何使 swf 对象居中?
【发布时间】:2015-07-23 01:42:37
【问题描述】:

我的 swf 反应灵敏,因此很难居中,我希望找到简单的方法来做到这一点。对象可以像 img 标签一样在 CSS 中居中吗?我测试了这个理论,但没有运气。我将如何制作这个代码中心?我是否有可以响应和居中的替代方案?

看起来像这样:

下面的内容没有帮助。 X

【问题讨论】:

标签: html css flash


【解决方案1】:

尝试这些替代方法中的任何一种

css定位

.hdiv {
position: absolute; left: 0; top: 0; bottom: 0; right: 0; } object { position: absolute; left: 25%; top: 25%; width:50%; height: 50%; background:#000; }

弹性盒方法

.hdiv {
display:flex; justify-content:center; align-items:center; height:100vh; } object {
background:#000; width:50%; height:50%; }
请注意,您需要为某些浏览器添加 flexbox 类的前缀,并且语法可能会有所不同,并且旧版浏览器也不支持 vh。

使用 css 转换

.hdiv {
position: absolute; top: 50%; left: 50%;
background: #000; transform: translate(-50%,-50%);
}

【讨论】:

  • 如果您希望内容流畅,请不要尝试在 Chrome 中调整窗口大小......自 2013 年以来不是......
猜你喜欢
  • 2013-03-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-08
  • 1970-01-01
  • 1970-01-01
  • 2015-11-19
  • 2018-10-16
相关资源
最近更新 更多