Languages
[Edit]
EN

CSS - box-shadow effect at the top only

0 points
Created by:
Kenya-Spears
860

In this article, we would like to show you how to add box-shadow effect at the top only using CSS.

Quick solution:

.element {
    box-shadow: 0px -5px 5px gray; /* box-shadow: offset-x offset-y blur-radius color; */
}

 

Practical example

In this example, we use box-shadow with three values offset-x, offset-y and blur-radius to create shadow effect at the top of .element class.

// ONLINE-RUNNER:browser;

<!DOCTYPE html>
<html>
<head>
  <style>

	.element {
        margin-top: 20px;
        box-shadow: 0px -5px 5px gray;  /*   <----- required   */
    }

  </style>
</head>
<body>
  <div class="element">
    some text here...
  </div>
</body>
</html>

 

See also

  1. CSS - box-shadow effect on bottom only

  2. CSS - box-shadow example

References

  1. box-shadow - CSS: Cascading Style Sheets | MDN

Alternative titles

  1. CSS - add box-shadow effect on top side only
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join