【问题标题】:How to grow image height more than the height of container so that image overlaps other elements/components?如何使图像高度超过容器的高度,以使图像与其他元素/组件重叠?
【发布时间】:2021-03-14 19:54:43
【问题描述】:

我有一个水平滚动的电影海报列表,当我将鼠标悬停在图像上时,图像会变大,但仅根据容器的高度可见。我希望图像在容器之外与其他元素重叠。我尝试在图像上使用“位置:绝对”,但列表中的其他图像没有按预期运行。

list.component.html

<div class="wrapper">
     <h3>{{ heading }}</h3>
     <div class="scrolls">
          <div (click)="loadContent(content.id, content.type)" *ngFor="let content of list" class="imageDiv">
               <img [src]="content.imgSrc" />
          </div>
     </div>
</div>

list.component.css

.wrapper { 
    background:transparent; 
    box-shadow: 1px 1px 10px #999; 
    margin: auto; 
    text-align: center; 
    position: relative;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    margin-bottom: 20px !important;
    width: 100%;
    padding-top: 5px;
}

h3 {
    color: white;
    font-weight: 500;
}

.scrolls { 
    overflow-x: scroll;
    overflow-y: hidden;
    white-space:nowrap;
    height: 250px;
} 
.imageDiv { 
    margin: 0;
    height: 250px;
    width: 1200px;
    display: inline;
} 

.imageDiv img { 
    box-shadow: 1px 1px 10px #999; 
    margin: 2px;
    max-height: 250px;
    cursor: pointer;
    display: inline;
    transition: all .2s ease-in-out;
}

img:hover {
    -webkit-transform: scale(1.3);
        -ms-transform: scale(1.3);
        transform: scale(1.3);
        z-index: 1 !important;
}

::-webkit-scrollbar{
    height: 1px;
    width: 1px;
    background: gray;
}
::-webkit-scrollbar-thumb:horizontal{
    background: #000;
    border-radius: 10px;
}

图像列表

图像悬停

【问题讨论】:

    标签: css angular hover css-transforms horizontal-scrolling


    【解决方案1】:

    我怀疑您可能想要将 overflow: visible 放在您的 .imageDiv 类样式中,或者至少类似的东西。

    此设置允许内容在其容器之外增长,这正是您想要的。

    请参阅 W3Schools example

    【讨论】:

      猜你喜欢
      • 2013-04-08
      • 1970-01-01
      • 2015-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多