强制 Flash 的底部边距为负值

发布于 2024-11-27 15:57:29 字数 319 浏览 0 评论 0原文

我有一个 .swf 导航轮播,高度为 650 像素,底部 200 像素保留用于轮播的反射。反射非常微妙,不被视为重要信息,因此当窗口足够高以容纳最上面的 450 个像素时,我们希望删除垂直滚动条,但不删除反射。

我尝试通过为 flash 设置 margin-bottom: -200px 来实现此目的,但这只会使容器的高度缩小 200 像素,从而导致背景图案在页面底部之前剪切。 Flash本身仍然占用650像素。

除了使用 JavaScript 主动隐藏/显示滚动条之外,是否有一些“正确”的修复方法?

I have an .swf navigation carousel that is 650 pixels high, the bottom 200 pixels being reserved for the reflection of the carousel. The reflection is very subtle and is not considered important information, so we would like to remove vertical scrollbars when the window is high enough to fit the topmost 450 pixels, but not the reflection.

I tried to accomplish this by setting a margin-bottom: -200px to the flash <object> but this only made the container's height shrink 200 pixels, causing the background pattern to cut before the bottom of the page. The Flash itself is still taking up 650 pixels.

Is there some "proper" fix to this, other than hiding/showing the scrollbars actively using javascript?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白色秋天 2024-12-04 15:57:29

您可以尝试使用 css:

#idOfElement {
    overflow-x: hidden;
    overflow-y: hidden;
}

抱歉,我以为您正在尝试从元素中删除滚动条。如果你想让它们离开窗口,只需执行 body {overflow:hidden}

只有当你执行 overflow:hidden 时,元素的某些部分才会被切断,如果元素的内容大于其容器,因此您可能需要研究一下。

当窗口高度达到 450px 时,尝试使用此方法隐藏溢出:

window.onresize = function () {
    var height = window.innerHeight;
    if (height > 450) {
        document.body.style.overflow = "hidden";
    }
}

您可能遇到的一个问题是,某些浏览器喜欢在调整大小期间触发大量调整大小事件,而不是在调整大小之后触发大量调整大小事件,这可能会影响性能。 Paul Irish 在 http://paulirish.com 上撰写了一篇关于缓解此问题的简短博客文章/2009/throttled-smartresize-jquery-event-handler/ 我认为 jQuery 的 .resize() 函数会自动执行此操作。

You could try using css:

#idOfElement {
    overflow-x: hidden;
    overflow-y: hidden;
}

My apologies, I thought you were trying to remove scrollbars from the element. If you want to get them off of the window, just do body {overflow: hidden}

Parts of the element will only get cut off when you do overflow: hidden if the content of the element is larger than its container, so you may want to look into that.

Try this to hide the overflow when the window height reaches 450px:

window.onresize = function () {
    var height = window.innerHeight;
    if (height > 450) {
        document.body.style.overflow = "hidden";
    }
}

An issue you may have with this is that some browsers like to fire a lot of resize events during resizing, instead of one after, which could impact performance. Paul Irish wrote a short blog post about mitigating this at http://paulirish.com/2009/throttled-smartresize-jquery-event-handler/ and I think that jQuery's .resize() function does this automatically.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文