Search code examples
cssglowbox-shadow

How to make an empty div or container glow with pure CSS?


I want an empty container to glow so I use this code:

box-shadow: 0 1px 20px 1px lightcyan;

The problem with this is that only the borders glow and there is a big hole in the center which is not the effect I want. I know I can move the position of the shadow so is not overlapped by the container itself but I don't want that because it would be out of place.

Is there any other alternative to achieve this effect with pure CSS?

Something like this, but without the background:

enter image description here


Solution

  • box-shadow can do it, just crank up the blur and the spread (the 3rd and 4th parameters).

    For a circle, add border-radius: 50%; and give a small width and height.

    div {
      margin: 100px;
      width: 1px;
      height: 1px;
      background-color: lime; /* for the 1px in the center */
      border-radius: 50%;
      box-shadow: 0 0 50px 70px lime;
    }
    <div></div>