fca*_*ran 59
codepen上的示例:http://codepen.io/anon/pen/sbHAc/
相关的CSS
ol {
border : 1px #d8d8d8 dashed;
position : relative;
}
ol:after {
content : "";
position : absolute;
z-index : 1;
bottom : 0;
left : 0;
pointer-events : none;
background-image : linear-gradient(to bottom,
rgba(255,255,255, 0),
rgba(255,255,255, 1) 90%);
width : 100%;
height : 4em;
}
Run Code Online (Sandbox Code Playgroud)
产生的效果
如果浏览器支持该pointer-events
属性(除了所有主要浏览器IE<=10
),则渐变下的文本也将是可选择/可点击的.
Ale*_*izi 13
I (personally) find that using a secondary element as an "overlap" works pretty well. I do this by defining a new tag
. This makes it really easy to add the desired fade out effect to any element you want using <fade/>
at the end.
div {
position: relative;
}
fade {
position: absolute;
bottom: 0px;
display: block;
width: 100%;
height: 50px;
background-image: linear-gradient(to bottom,
rgba(255, 255, 255, 0),
rgba(255, 255, 255, 0.9)
100%);
}
Run Code Online (Sandbox Code Playgroud)
<div>
text
<br>
text
<br>
text
<fade/>
</div>
Run Code Online (Sandbox Code Playgroud)
Giving the fade
element an absolute
position with a gradient
background works just as expected. As long as you remember to set the parent's position to relative
.
小智 5
<style>
.fade {
position: relative;
bottom: 4em;
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%
);
}
</style>
Run Code Online (Sandbox Code Playgroud)
这是您的示例http://jsfiddle.net/nrgx7/