如何使用溢出滚动固定div中的高度

时间:2019-02-25 08:01:07

标签: sass flexbox overflow

我无法通过滚动应用固定高度。当我固定高度容器时,炸毁所有div的高度。如何固定div高度?修复了容器中的树项。我将修复容器的高度设置为“ 200px”,但它不起作用。也许有些简单,但我看不到。

这是我的简单代码:

Promise.all(promiseArr.map(obj => Object.values(obj)[0]))

和我的scss:

<div class="container-Atanan">
  <div class="container-Atanan-Header">
    <i class="fas fa-american-sign-language-interpreting fa-2x"></i>
    <div class="container-Atanan-Header-Title"><span>Başlık</span></div>
  </div>
  <div class="container-Atanan-ListItem">
    <a class="listItem" href="#">
      <div class="container-Atanan-ListItem-Avatar">
        <img src="https://cdn.vuetifyjs.com/images/lists/1.jpg" alt="">
      </div>
      <div class="container-Atanan-ListItem-Content">
        <div class="Content-Title">Lorem ipsum.</div>
        <div class="Content-Subtitle">
          <span>Lorem ipsum dolor sit. <span class="italic">-25.2.2019</span></span>
          <span class="italic oldline">Lorem ipsum dolor sit amet. </span>
        </div>
      </div>
    </a>
  </div>

和我的fiddle

1 个答案:

答案 0 :(得分:0)

改为使用

        display:grid;
        grid-template-columns :max-content max-content;

&-header中,从inline-flex中删除&-ListItem,然后可以将height中的.container-Atanan设置为所需的任何值

body{
    background-color:#FEFCFC;
}
.container-Atanan {
    box-shadow:0px 3px 1px -2px rgba(0,0,0,0.2), 0px 2px 2px 0px rgba(0,0,0,0.14), 0px 1px 5px 0px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    // background-color : #7AD3B1;
    width: 470px;
   height:350px;
    overflow: auto;
    padding-bottom : 30px;
    font-family: 'Roboto', sans-serif;
    &-Header {
        display:grid;
        grid-template-columns :max-content max-content;
        background-color: #e2e2e2;
        height: 50px;
        align-items: center;
        &-Title{
            padding:15px;
        }
    }
    &-ListItem{


        .listItem{
            display: inline-flex;
            width: 100%;
            height: 72px;
            text-decoration: none;
            color:black;
            padding: 15px 15px;
        }
        &-Avatar {
            margin-right: 10px;
            display: inline-flex;
            align-items: center;
            img{
                border-radius: 50%;
                width: 40px;
                height: auto;
            }
        }
        &-Content {
            display: inline-flex;
            padding-right: 30px;
            flex-direction: column;
            justify-content: center;
            padding-left:10px;
            width: 362px;
            height: 72px;
            box-shadow: 0 8px 6px -20px rgba(0,0,0,0.2), 0px 2px 2px 0px rgba(0,0,0,0.14), 0px 1px 5px 0px rgba(0,0,0,0.12);
            transition: background-color 0.5s ease-out;
            .Content-Title{
               font-weight: 500;
            }
            .Content-Subtitle {
                font-weight: 300;
                display: inline-flex;
                flex-direction: column;
                .italic{
                 font-weight : lighter;
                font-style: italic;
                font-size :1em;
                }
                .oldline{
                    text-decoration:line-through;
                }

            }
                &:hover{
                   background: rgba(0,0,0,0.05)
                }

        }
    }
    .divider{
        display: block;
        margin-left: 72px;
        border: solid;
        border-width: thin 0 0 0;
         margin-left: 0;
         margin-right: 0;
         margin-bottom : 0;
        &-Light{
            border-color: rgba(0,0,0,0.12);
        }
    }

}

JSFIDDLE