【问题标题】:css overflow x not workingcss溢出x不工作
【发布时间】:2016-08-06 03:32:31
【问题描述】:

我正在尝试将多个 div(图像 -> 黑色块)放入一个容器(图像 -> 蓝色块)中。我需要在容器中放置尽可能多的 div。容器有一个“浮动”宽度,所以它在每个屏幕上都有不同的大小。 “1”(在图片中)代表我今天拥有的东西,它正在工作。

问题是我在整个站点中使用引导弹出窗口,但容器中的溢出不允许它出现。如果我删除溢出属性(图像中的“2”),所有 div 都会出现在“下”行中。我不想滚动,只是隐藏不适合容器的 div。

图中的“3”代表我想要的。

这是我的代码:

// CSS
.content-bar{
        max-width:100%;
        height: 3.5em;
        white-space:nowrap;
        display: inline-block;
        overflow-x: hidden;
        overflow-y: visible;
}

.photo-bar{
        width: 2.5em;
        height: 3.5em;
        margin-right: -.55em;
        padding: 0;
        display: inline-block;
        white-space: normal;                
}

// JS
<div class="content-bar">
        <div class="photo-bar" ng-repeat="...">                    
             // image goes here
        </div>
</div>

【问题讨论】:

    标签: angularjs css overflow


    【解决方案1】:

    如果你希望它是可滚动的,那么你需要这样做:

    overflow-x: scroll;
    

    【讨论】:

    • 您好,感谢您的关注!但我不是在找卷轴,我只是想躲起来!
    • 啊,我想我知道你在找什么。你的问题是你的弹出框没有出现,因为你的溢出覆盖了它。对吗?
    【解决方案2】:

    选项 1: 您可以从样式中删除溢出属性。弹出窗口将按预期出现。内联应用属性可以解决代码 sn-p 中的问题,请查看下面显示的 sn-p。

    选项 2: 如果您的情况可行:您可以使用溢出隐藏,但您需要为“.content-bar”类设置 padding-top。填充顶部应该是弹出窗口的高度。

    // CSS
    .content-bar{
      max-width: 100%;
      height: 3.5em;
      white-space: nowrap;
      display: block;
      overflow-x: scroll;
      /*overflow-y: visible;*/
    }
    .photo-bar {
      width: 2.5em;
      height: 3.5em;
      margin-right: -.55em;
      padding: 5px;
      display: inline-block;
      white-space: normal;
      background-color: lightblue;
      border: 1px solid;
    }
    <div class="content-bar" style="white-space: nowrap;overflow-x: scroll;">
      <div class="photo-bar">
        <img src="http://placehold.it/50x10" />
      </div>
      <div class="photo-bar">
        <img src="http://placehold.it/50x10" />
      </div>
      <div class="photo-bar">
        <img src="http://placehold.it/50x10" />
      </div>
      <div class="photo-bar">
        <img src="http://placehold.it/50x10" />
      </div>
      <div class="photo-bar">
        <img src="http://placehold.it/50x10" />
      </div>
      <div class="photo-bar">
        <img src="http://placehold.it/50x10" />
      </div>
      <div class="photo-bar">
        <img src="http://placehold.it/50x10" />
      </div>
      <div class="photo-bar">
        <img src="http://placehold.it/50x10" />
      </div>
      <div class="photo-bar">
        <img src="http://placehold.it/50x10" />
      </div>
      <div class="photo-bar">
        <img src="http://placehold.it/50x10" />
      </div>
      <div class="photo-bar">
        <img src="http://placehold.it/50x10" />
      </div>
      <div class="photo-bar">
        <img src="http://placehold.it/50x10" />
      </div>
      <div class="photo-bar">
        <img src="http://placehold.it/50x10" />
      </div>
      <div class="photo-bar">
        <img src="http://placehold.it/50x10" />
      </div>
      <div class="photo-bar">
        <img src="http://placehold.it/50x10" />
      </div>
      <div class="photo-bar">
        <img src="http://placehold.it/50x10" />
      </div>
    
    </div>

    【讨论】:

      【解决方案3】:

      相信你在找overflow-x:scroll;

      【讨论】:

      • 您好,感谢您的关注!但我不是在找卷轴,我只是想躲起来!
      猜你喜欢
      • 1970-01-01
      • 2020-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-04
      • 2014-01-21
      • 1970-01-01
      • 2013-07-20
      相关资源
      最近更新 更多