Soft Edges using CSS?

前端 未结 3 1905
我在风中等你
我在风中等你 2021-02-05 02:50

I am using RGBA to create a transparent background that overlays on top of an image. Works just fine. My questions is this: Is there a way to \"soften\" the edges of the box to

3条回答
  •  Happy的楠姐
    2021-02-05 03:35

    Another option is to use one of my personal favorite CSS tools: box-shadow.

    A box shadow is really a drop-shadow on the node. It looks like this:

    -moz-box-shadow: 1px 2px 3px rgba(0,0,0,.5);
    -webkit-box-shadow: 1px 2px 3px rgba(0,0,0,.5);
    box-shadow: 1px 2px 3px rgba(0,0,0,.5);
    

    The arguments are:

    1px: Horizontal offset of the effect. Positive numbers shift it right, negative left.
    2px: Vertical offset of the effect. Positive numbers shift it down, negative up.
    3px: The blur effect.  0 means no blur.
    color: The color of the shadow.
    

    So, you could leave your current design, and add a box-shadow like:

    box-shadow: 0px -2px 2px rgba(34,34,34,0.6);
    

    This should give you a 'blurry' top-edge.

    This website will help with more information: http://css-tricks.com/snippets/css/css-box-shadow/

提交回复
热议问题