box-shadow on top of children

后端 未结 3 521
独厮守ぢ
独厮守ぢ 2020-12-25 11:18

How do I get an inset CSS3 box-shadow to render on top of its children elements?

Problem:

HTML:

3条回答
  •  囚心锁ツ
    2020-12-25 11:56

    Change the background-color of any children to also be RGBA (this only gets set in browsers that understand it which, conveniently, is any browser that can handle the shadow):

    .chatmessage:nth-child(2n) {
        background : #EEE;
        background : RGBA(0, 0, 0, .066);
    }
    

    Note that the two colors (#EEE, RGBA( 0, 0, 0, .066)) are identical as long as the background behind them is white.

    Demo since people seem to be down voting this for no reason: http://jsfiddle.net/6NrkR/

提交回复
热议问题