Fading out text at bottom of a section with transparent div, but height stays under section after overlaying div

后端 未结 5 1587
情话喂你
情话喂你 2020-12-02 17:22

I\'m trying to get a nice fade-out effect at the bottom of a section of text as a \'read more\' indicator.

I\'ve been following a bit off this and other tutorials,

5条回答
  •  旧时难觅i
    2020-12-02 17:54

    A relatively position element is not removed from the normal html flow, so if you move it around the initial space reserved for it still remains, however with absolute positioning this is not the case

    .fadeout {
        position: absolute; 
        bottom: 0em;
        width:100%;
        height: 4em;
        background: -webkit-linear-gradient(
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 1) 100%
        ); 
        background-image: -moz-linear-gradient(
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 1) 100%
        );
        background-image: -o-linear-gradient(
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 1) 100%
        );
        background-image: linear-gradient(
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 1) 100%
        );
        background-image: -ms-linear-gradient(
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 1) 100%
        );
    } 
    section {position:relative}     
    

    DEMO

提交回复
热议问题