为什么从右向左滑动(折叠)会创建滚动条,而 LTR 却不会?

发布于 2024-11-27 21:13:26 字数 1599 浏览 3 评论 0原文

tldr:看这里:http://joon.be/dalida/ 将鼠标悬停在黄色“城镇”和蓝色“城镇”上方。黄色的不会创建滚动条,右侧的会创建滚动条。为什么?

长版: 我有一条线从左侧进入,当它悬停在某物上时指向它。 这有效。我试图从右侧做同样的事情,同样的原理只是镜像,并且已经弄清楚如何做到这一点,但它具有创建水平滚动条的奇怪副作用,因为图像部分超出屏幕。在左侧,这种情况不会发生,尽管它的工作原理几乎与我所理解的完全相同。

这是左边的工作代码:

$('.dalidatown').hover(function(){
    $('.dalidapath').stop().animate({width: '903px'});
},function(){
    $('.dalidapath').stop().animate({width: '0px'});
});

“路径”是一个以线条作为背景的 div。这是这个的 CSS:

.path {
    position: absolute;
    border: 0px;
}

.dalidapath {
    width: 0px;
    height: 83px;
    z-index: 10;
    top: 130px;
    left: 50%;
    margin-left: -1110px;
    background-image:url('bin/dalidapath.png'); 
}

现在在右侧,我不能只使用宽度,我还必须使用边距,所以它看起来像这样:

$('.therapietown').hover(function(){
    $('.therapiepath').animate({width: '903px'}, {queue: false}).animate({marginLeft: '97px'}, {queue: false});
},function(){
    $('.therapiepath').animate({width: '0px'}, {queue: false}).animate({marginLeft: '1000px'}, {queue: false});
});          

除了创建滚动条之外,这完成了我想要的一切。 .. 这是相关的CSS:

.path {
    position: absolute;
    border: 0px;
}

.therapiepath {
    width: 0px;
    height: 83px;
    z-index: 10;
    top: 130px;
    left: 50%;
    margin-left: 1000px;
    background-image:url('bin/therapiepath.png'); 
    background-position:right top;
}

所以你可以在这里看到它: http://joon.be/dalida/

tldr: look here: http://joon.be/dalida/
hover over the yellow 'town' and over the blue 'town'. The yellow one doesn't create a scrollbar, the right one does. Why?

Long version:
I have a line entering from the left side to point at something when it is hovered over.
This works. I'm trying to do the same from the right side, same principle just mirrored, and have figured out how to do this, but it has the weird side effect of creating a horizontal scroll bar, since the image is partially out of the screen. On the left side, this does not happen, even though it works almost exactly the same afai understand.

Here's the left, working, code:

$('.dalidatown').hover(function(){
    $('.dalidapath').stop().animate({width: '903px'});
},function(){
    $('.dalidapath').stop().animate({width: '0px'});
});

The 'path' is a div that has the line as background. Here's the CSS for this:

.path {
    position: absolute;
    border: 0px;
}

.dalidapath {
    width: 0px;
    height: 83px;
    z-index: 10;
    top: 130px;
    left: 50%;
    margin-left: -1110px;
    background-image:url('bin/dalidapath.png'); 
}

Now on the right side, I couldn't just use width, I had to play with the margin as well, so it looks like this:

$('.therapietown').hover(function(){
    $('.therapiepath').animate({width: '903px'}, {queue: false}).animate({marginLeft: '97px'}, {queue: false});
},function(){
    $('.therapiepath').animate({width: '0px'}, {queue: false}).animate({marginLeft: '1000px'}, {queue: false});
});          

this does everything I Want it to, other than create the scrollbar...
Here's the relevant css:

.path {
    position: absolute;
    border: 0px;
}

.therapiepath {
    width: 0px;
    height: 83px;
    z-index: 10;
    top: 130px;
    left: 50%;
    margin-left: 1000px;
    background-image:url('bin/therapiepath.png'); 
    background-position:right top;
}

So you can see it live here: http://joon.be/dalida/

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

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

发布评论

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

评论(4

灵芸 2024-12-04 21:13:26

不同之处在于,浏览器不会向左滚动超过 0。向右,页面可以根据需要扩展。您可以通过设置overflow:hidden来解决这个问题,尽管这可能最终会导致其他问题,具体取决于您的页面。

The difference is that the browser won't scroll any farther left than 0. To the right, the page can expand as far as it needs to. You can fix thsi by setting overflow: hidden, though that may end up causing other issues, depending on your page.

庆幸我还是我 2024-12-04 21:13:26

简单的答案是,左侧动画有足够的屏幕空间,不需要滚动条。您的解决方案可能是 CSS 解决方案:

尝试将 overflow-x:hidden; 添加到正文

Simple answer, there is enough screen real estate for the left side animation to not require a scrollbar. Your solution will likely be a CSS one:

Try adding overflow-x:hidden; to the body

秋千易 2024-12-04 21:13:26

idk 但 body{overflow:hidden} 可以解决滚动条出现的问题。不过,我建议不要这样做,而是创建一个宽度为 100% 的包装器。然后对其应用溢出属性。

idk but body{overflow: hidden} will do the trick for the scroll bars appearing. I would advise against that, however, and instead create a wrapper that has a width of 100%. then apply the overflow property to that.

Saygoodbye 2024-12-04 21:13:26

我的滚动条没有显示,但您可以在 bodyhtml 上添加一个 overflow-y 属性hidden 值将确保滚动条不会出现。

更新:如果您担心支持 IE,您可能只想使用 overflow:hidden;,具体取决于您希望对不同窗口宽度的支持程度。

A scrollbar didn't show up for my, but what you could do is on the body or html, add an overflow-y property with a value of hidden and that will make sure that the scrollbar doesn't appear.

Update: If you're worried about supporting IE you may want to just use overflow:hidden; depending on how supportive you want to be of varying window widths.

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