0

我在浏览器窗口的一侧有一个选项卡,单击该选项卡时使用 jquery 将其滑入并显示它。问题是因为我有绝对定位,它溢出了身体,我似乎无法停止。当它被 jQuery 拉入时,它不再溢出。只有当它被隐藏时。

JS:

        $(tabs).click(function(event) {
        event.preventDefault();
        var block = '#block-webform-client-block-12';
        if($(tabs).hasClass("isDown")) {
            $(block).animate({ right: '+=380'}, 500 ),
            //$(block).css({ position: 'absolute' });
            $(tabs).removeClass("isDown");
            $('.block-webform .quote-tab.open').hide();
            $('.block-webform .quote-tab.close').show();
        } else {
            $(block).animate({ right: '-=380' }, 500 )
            //$(block).css({ position: 'fixed'});
            $(tabs).addClass("isDown");
            $('.block-webform .quote-tab.open').show();
            $('.block-webform .quote-tab.close').hide();
        }
        return false;
    });

CSS:

#block-webform-client-block-12 {
position: absolute;
top: 20%;
right: -380px;
background: $button-color;
padding: 15px;
width: 350px;
color: white;
z-index: 99;
@include zen-grid-container();
.quote-tab {
    position: absolute;
    top: 0;
    left: -46px;
}

HTML:

    <div id="block-webform-client-block-12" class="block block-webform contextual-links-region last even">
<h2 class="block-title">
  Get a Quote
</h2>
<article class="node-12 node node-webform node-promoted contextual-links-region view-mode-full node-by-viewer clearfix" about="/get-quote" typeof="sioc:Item foaf:Document">
  <div class="field field-name-body field-type-text-with-summary field-label-hidden">
    <div class="field-items">
      <div class="field-item even" property="content:encoded">
        <img src="/sites/domain.com/files/close-quote-tab.png" class="quote-tab close"> <img src="/sites/domain.com/files/open-quote-tab.png" class="quote-tab open">
        <p>
          Fill out this form to request a quote or set up an appointment. For more information, <strong>call 123-456-7890</strong>.
        </p>
      </div>
    </div>
  </div>
  <form class="webform-client-form" enctype="multipart/form-data" action="/get-quote" method="post" id="webform-client-form-12" accept-charset="UTF-8">
    ...form_components...

截屏 破碎的绝对

我想这样做,以便当表单关闭屏幕时仅显示选项卡,您无法滚动查看表单的其余部分

4

2 回答 2

0

你需要overflow-x: hidden一种或另一种方式。

如果您确定没有其他内容会溢出页面宽度,您可以简单地将其设置在其body自身上。如果没有,您将需要某种带有overflow-x: hidden.

http://jsfiddle.net/aZU3S/1

于 2013-06-25T20:03:24.513 回答
0

您是否尝试将溢出设置为滚动?

overflow-x: scroll;
于 2013-06-25T20:12:53.907 回答