html 文字如何和阴影齐平,css – 如何使用z-index对盒子阴影进行分层?

演示:

http://codepen.io/anon/pen/vLgKC

有关z-index和堆栈上下文以及优先级的更多信息,请参阅我的答案here.

以上,结合了盒子阴影的插图

inset

If not specified (default),the shadow is assumed to be a drop shadow (as if the Box were raised above the content).

The presence of the inset keyword changes the shadow to one inside the frame (as if the content was depressed inside the Box).

Inset shadows are drawn inside the border (even transparent ones),above the

background,but below content.

而负面的传播

spread-radius

This is a fourth value. Positive values will cause the shadow to expand and grow bigger,negative values will cause the

shadow to shrink. If not specified,it will be 0 (the shadow will be the same size as the element).

(两者都是here)

会给你你想要的效果.

因此,您需要更改阴影应用于元素的位置.

所以最终的CSS:

#b {

background: orange;

z-index: 2;

position: relative;

}

#c {

background: red;

-webkit-Box-shadow: inset 0 10px 10px -10px black;

-moz-Box-shadow: inset 0 10px 10px -10px black;

Box-shadow: inset 0 10px 10px -10px black;

z-index: 1;

position: relative;

}

ul {

list-style: none;

margin: 0;

padding: 0;

z-index: 1;

position: relative;

}

li {

display: inline-block;

padding: 2px 5px;

}

.current {

background-color: orange;

z-index: 3;

position: relative;

}

#d {

Box-shadow: 0 0 10px black;

z-index: 2;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值