html阴影向上,HTML – 纯css滚动阴影

对于文本也会发生这种情况,但您无法看到它,因为它们具有相同的颜色.一个解决方案是:儿童的z-index低于父母的z-index.为此,您需要另外两件事:

>孩子和父母的静态位置

> .scrollbox的透明背景

.scrollbox li * {

z-index:0;

position:relative;

}

.scrollbox {

z-index:1;

position:relative;

background-color:transparent;

}

/**

* Scrolling shadows by @kizmarh and @leaverou

* Only works in browsers supporting background-attachment: local; & CSS gradients

* Degrades gracefully

*/

html {

background: white;

font: 120% sans-serif;

}

.scrollbox {

overflow: auto;

width: 200px;

max-height: 200px;

margin: 50px auto;

background:

/* Shadow covers */

linear-gradient(white 30%, rgba(255, 255, 255, 0)), linear-gradient(rgba(255, 255, 255, 0), white 70%) 0 100%,

/* Shadows */

radial-gradient(50% 0, farthest-side, rgba(0, 0, 0, .2), rgba(0, 0, 0, 0)), radial-gradient(50% 100%, farthest-side, rgba(0, 0, 0, .2), rgba(0, 0, 0, 0)) 0 100%;

background:

/* Shadow covers */

linear-gradient(white 30%, rgba(255, 255, 255, 0)), linear-gradient(rgba(255, 255, 255, 0), white 70%) 0 100%,

/* Shadows */

radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, .2), rgba(0, 0, 0, 0)), radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, .2), rgba(0, 0, 0, 0)) 0 100%;

background-repeat: no-repeat;

background-color: transparent;

background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;

/* Opera doesn't support this in the shorthand */

background-attachment: local, local, scroll, scroll;

z-index:1;

position:relative;

}

.scrollbox li * {

z-index:0;

position:relative;

}

CSS-only shadow-scrolling effect.

  • Ah! Scroll below!
  • Button
  • Button
  • Button
  • Button
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • The end!
  • No shadow there.

剩下的唯一问题是你需要一个坚实的背景颜色才能工作.

编辑:

子项的z-index需要低于父项的z-index,但如果你使用负z-index,就像我建议的那样,点击和悬停等事件就会停止工作.我正确地更改了代码.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值