CSS-Tricks*

A Web Design Community curated by Chris Coyier

A little dab'll do ya

Code Snippets

Code Snippets > CSS > Top Shadow Submit one!

Top Shadow

Shadow along the top edge of the website, like this:

body:before {
          content: "";
          position: fixed;
          top: -10px;
          left: 0;
          width: 100%;
          height: 10px;

          -webkit-box-shadow: 0px 0px 10px rgba(0,0,0,.8);
              -moz-box-shadow: 0px 0px 10px rgba(0,0,0,.8);
                         box-shadow: 0px 0px 10px rgba(0,0,0,.8);

          z-index: 100;
}

Reference URL

Subscribe to The Thread

  1. myst says:

    yeah, but browser slow down if use position:fixed on site with content. maybe you know reason?

    • I did some testing with that and didn’t seem to find any slowdown. Do you have a test page showing the problem?

    • myst says:

      No, i try add code in my site with other content & get slowdown, i think code with position: fixed; work fine if is demo page with no-content )) in real sites it slow.

    • With content, with scrolling: http://jsbin.com/ejora3

      No slowdown.

      What matters is doing tests. Make a test page with different content that DOES slow it down, and we can troubleshoot from there.

      “Reduced Test Cases” http://css-tricks.com/reduced-test-cases/

    • myst says:

      Go to my home page please, you see. With other skins for cms it works fine.

    • Scrolls fine for me. If it doesn’t for you, that means it’s either 1) the browser/version 2) the platform/version 3) your computer in general and all of that in conjunction with the HTML/CSS/JavaScript on your page. That’s the point of the reduced test case. Add the top shadow, experience slowness, remove things from the page slowly until it fixes the problem, then that was the thing that was causing the problem. Or do it in reverse, add the top shadow, then add things back into an otherwise empty page until it breaks. The last thing you added is the problem.

    • myst says:

      I use different browsers for testing on machine with 1GB of memory & Win-x64. Opera -11 (very-very slow), Safary (no smooth scrolling) =( Thanks for any way. Thanks anyway. I’ll try to find the cause.

    • myst says:

      I’ve found. lot of text-shadow on my site for any text. Sorry, it is my fault

  2. It works damn fine at my side should i use it or not

It's Your Turn

At this moment, you have an awesome opportunity* to be the person your mother always wanted you to be: kind, helpful, and smart. Do that, and we'll give you a big ol' gold star for the day (literally).

Posting tips:
  • You can use basic HTML
  • When posting code, please turn all
    < characters into &lt;
  • If the code is multi-line, use
    <pre><code></code></pre>
Thank you,
--- The Management ---