{"id":3891,"date":"2015-04-28T12:15:52","date_gmt":"2015-04-28T09:15:52","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=3891"},"modified":"2018-01-09T09:13:02","modified_gmt":"2018-01-09T07:13:02","slug":"css-box-shadow-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/","title":{"rendered":"CSS Box Shadow Example"},"content":{"rendered":"<p>In this example, we will go through the box-shadow property of css.<\/p>\n<p>Just like the text-shadow property, box-shadow will give an element of html a new look by adding different styled shadows.<\/p>\n<p>As you can imagine, this is going to be more of an examples show rather than exaplanation because the property is pretty straight-forward.<\/p>\n<p>The cases you&#8217;ll see below, are of a very high usage all over the web, and I recommend you consider these shadow designs on your projects.<\/p>\n<p>They will make content on boxes in your website more catchy and attractive, so do not hesitate to use them.<br \/>\n&nbsp;<br \/>\n[ulp id=&#8217;nAkUl5IbAjqlXSla&#8217;]<\/p>\n<h2>1. Prerequisites<\/h2>\n<p>Below, I will present you to the necessary knowledge you should have to get through this.<\/p>\n<h3>1.1 Basic Set Up<\/h3>\n<p>First, go ahead and create a new html file and add the basic <code>html<\/code> and <code>css<\/code> like this:<\/p>\n<pre class=\"brush:xml\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n\t&lt;title&gt;CSS Buttons&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n\t&lt;!-- STYLE SECTION --&gt;\r\n\r\n\t&lt;style type=\"text\/css\"&gt;\r\n\r\n  \t&lt;\/style&gt;\r\n\r\n\r\n\t&lt;!-- HTML SECTION --&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h3>1.2 Pseudo-Elements :before and :after<\/h3>\n<p>A pseudo-element creates a phoney element and inserts it before or after the content of the element that you\u2019ve targeted.<\/p>\n<p>We will use the :before and :after pseudo-elements to add shadows left, right, top, bottom or combinations of these.<\/p>\n<p>See this simple example of its usage so you have a better clue:<\/p>\n<p>&#8211; HTML<\/p>\n<pre class=\"brush:xml\">\r\n&lt;!-- HTML SECTION --&gt;\r\n&lt;h1 class=\"text\"&gt;This is the first item&lt;\/h1&gt;\r\n<\/pre>\n<p>&#8211; CSS<\/p>\n<pre class=\"brush:css\">\r\n&lt;!-- STYLE SECTION --&gt;\r\n\r\n.text:before {\r\n\tcontent:\"1. \";   \/* what to display before text element *\/\r\n}\r\n\r\n.text:after {\r\n\tcontent: \"!\";   \/* what to display after text element *\/\r\n}\r\n\r\n&lt;\/style&gt;\r\n<\/pre>\n<p>This would give the number <code>1.<\/code> before the text and <code>!<\/code> after the text like this:<br \/>\n<figure id=\"attachment_3911\" aria-describedby=\"caption-attachment-3911\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box1.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box1.jpg\" alt=\":before and :after pseudo elements\" width=\"800\" height=\"183\" class=\"size-full wp-image-3911\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box1.jpg 800w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box1-300x69.jpg 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-3911\" class=\"wp-caption-text\">:before and :after pseudo elements<\/figcaption><\/figure><\/p>\n<h3>1.3 Extra properties to consider<\/h3>\n<p>Along with the pseudo-elements, there are also some properties I&#8217;d like you to understand:<\/p>\n<p><code>z-index<\/code> &#8211; specifies the stack order of an element.<\/p>\n<p><code>position<\/code> &#8211; allows you to position elements within a page.<\/p>\n<p><code>content<\/code> &#8211; used when appyling :before and :after pseudo-elements.<\/p>\n<p><code>left, right, top, bottom<\/code> &#8211; defines the left, right, top, bottom edge of an element.<\/p>\n<p><code>transform<\/code> &#8211; self-explanatory, transforms an object by degree, scale ect.<\/p>\n<h2>2. Basic Box-Shadow Property<\/h2>\n<p>Application of the box-shadow property is pretty simple. It goes like this:<\/p>\n<pre class=\"brush:css\">\r\nbox-shadow: horizontal-offset vertical-offset blur-radius spread-radius color;\r\n<\/pre>\n<h3>2.1 Attribute values explanation<\/h3>\n<p>But what do these attributes mean?<\/p>\n<p><strong>1. The horizontal offset (required):<\/strong><\/p>\n<p> &nbsp;  &#8211; A positive value  will make the shadow lie on the right of the box.<br \/>\n &nbsp;  &#8211; A negative offset will make it lie on the left of the box.<\/p>\n<p><strong>2. The vertical offset (required):<\/strong><\/p>\n<p>&nbsp;   &#8211; A negative value makes the shadow lie above the box.<br \/>\n&nbsp;   &#8211; A positive value make it lie below the box.<\/p>\n<p><strong>3. The blur radius (required):<\/strong><\/p>\n<p>&nbsp;   &#8211; Sharp shadows come with a value of 0, and the higher the number, the more blurred it will be, and the further out the shadow will extend.<\/p>\n<p><strong>4. The spread radius (optional):<\/strong> <\/p>\n<p>&nbsp;   &#8211; Positive values increase the size of the shadow.<br \/>\n&nbsp;   &#8211; Negative values decrease the size. <\/p>\n<p>Default is 0 (the shadow is same size as blur).<\/p>\n<p><strong>5. Color (required):<\/strong><\/p>\n<p>&nbsp;   &#8211; Using HEX color: e.g. #ccc, #9895AF ect.<br \/>\n&nbsp;   &#8211; Using RGBA color: e.g. rgba(192,192,192,0.3);<\/p>\n<h3>2.2 Application of the basic property <\/h3>\n<p>Create a <code>div<\/code> with a <code>class<\/code> of <code>box<\/code>.<\/p>\n<pre class=\"brush:xml\">\r\n&lt;!-- HTML SECTION --&gt;\r\n&lt;div class=\"box basic\"&gt;\r\n\t&lt;h3&gt;WEB CODE GEEKS&lt;\/h3&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<p>We are using multiple classes on an element, in this case two, because the box element will be the same for all examples, while the other class will contain distinctive attributes according to the effect we want to create.<\/p>\n<p>Now give the <code>body<\/code> a light gray color and <code>box<\/code> element these initial attributes to create a standard now.<\/p>\n<pre class=\"brush:css\">\r\n&lt;!-- STYLE SECTION --&gt;\r\nbody {\r\n\tbackground:#E6E6E6;\r\n}\r\n\r\n.box {\r\n    width:70%;\r\n    height:200px;\r\n    background:#FFF;\r\n    margin:40px auto;\r\n}\r\n<\/pre>\n<p>And the basic application of the <code>box-shadow<\/code> property would be:<\/p>\n<pre class=\"brush:css\">\r\n\r\n \/* no horizontal shadow, 10px vertical shadow, 6px blur, -6px spread radius, gray color *\/\r\n \r\n.basic{\r\n    -webkit-box-shadow: 0 10px 6px -6px #777;\r\n       -moz-box-shadow: 0 10px 6px -6px #777;\r\n            box-shadow: 0 10px 6px -6px #777;\t\r\n}\r\n<\/pre>\n<p>A basic shadow applied to a box like above will look like this:<br \/>\n<figure id=\"attachment_3929\" aria-describedby=\"caption-attachment-3929\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box3.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box3.jpg\" alt=\"Basic Box-Shadow Application\" width=\"800\" height=\"300\" class=\"size-full wp-image-3929\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box3.jpg 800w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box3-300x113.jpg 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-3929\" class=\"wp-caption-text\">Basic Box-Shadow Application<\/figcaption><\/figure><\/p>\n<h2>3. Advanced 3D Looking Box Shadows <\/h2>\n<p>Now, let&#8217;s look at some popular designs with shadows.<\/p>\n<p>For the first effect, every line of code is commented so that you know what we are doing.<\/p>\n<h3>3.1 Soft Box Shadow on Both Sides <\/h3>\n<pre class=\"brush:css\">\r\n \/* EFFECT 1 *\/\r\n\/* Here shadows are styled as elements to give impressive look *\/\r\n\/* However, the box shadow property is applied at the end to make final touches *\/\r\n\r\n.effect1\r\n{\r\n  position: relative;\t\/* relative positioning referring to before and after *\/\r\n}\r\n.effect1:before, .effect1:after  \/* apply some mutual properties before and after this element *\/\r\n{\r\n  z-index: -1;\t\t\t\/* send this element backward *\/\r\n  position: absolute;\t\/* absolute positioning referring to effect2 *\/\r\n  content: \"\";\t\t\t\/* just required, no need to put anything inside  *\/\r\n  bottom: 15px;  \t\t\/* bottom shadow alignment, less is closer to bottom *\/\r\n  left: 10px;\t\t\t\/* consider this like a margin left *\/\r\n  width: 50%;\t\t\t\/* width of the shadow element background *\/\r\n  top: 80%;\t\t\t\t\/* consider this as margin top of the shadow element *\/\r\n  max-width:300px;\t\t\/* restricts the max width of the shadow element  *\/\r\n  background: #777;\t\t\/* gives a background color to the shadow element  *\/\r\n  -webkit-box-shadow: 0 15px 10px #777;\t\/* compatibility case application *\/\r\n  -moz-box-shadow: 0 15px 10px #777;\t\/* compatibility case application *\/\r\n  box-shadow: 0 15px 10px #777;\t\/* applied the basic box-shadow property *\/\r\n  \/* rotation of shadows\/elements gives that 3D look to the box *\/\r\n  -webkit-transform: rotate(-3deg);\r\n  -moz-transform: rotate(-3deg);\r\n  -o-transform: rotate(-3deg);\r\n  -ms-transform: rotate(-3deg);\r\n  transform: rotate(-3deg);\r\n}\r\n.effect1:after\r\n{\r\n  -webkit-transform: rotate(3deg); \t\/* aligns the shadow right *\/\r\n  -moz-transform: rotate(3deg);\r\n  -o-transform: rotate(3deg);\r\n  -ms-transform: rotate(3deg);\r\n  transform: rotate(3deg);\r\n  right: 10px;\t\t\t\t\t\/* consider this like a margin right *\/\r\n  left: auto;\t\t\t\t\t\/* leave this auto to automatically set the left *\/\r\n}\r\n<\/pre>\n<p>View:<br \/>\n<figure id=\"attachment_3937\" aria-describedby=\"caption-attachment-3937\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box6.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box6.jpg\" alt=\"Soft Shadow on Both Sides\" width=\"800\" height=\"300\" class=\"size-full wp-image-3937\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box6.jpg 800w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box6-300x113.jpg 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-3937\" class=\"wp-caption-text\">Soft Shadow on Both Sides<\/figcaption><\/figure><\/p>\n<h3>3.2 Left and Right Box Shadow <\/h3>\n<p>In this effect, we take a look at the left and right box-shadows.<\/p>\n<pre class=\"brush:css\">\r\n\r\n\/* LEFT SHADOW *\/\r\n\r\n.effect2\r\n{\r\n  position: relative;\r\n}\r\n.effect2:before\r\n{\r\n  z-index: -1;\r\n  position: absolute;\r\n  content: \"\";\r\n  bottom: 15px;\r\n  left: 10px;\r\n  width: 50%;\r\n  top: 80%;\r\n  max-width:300px;\r\n  background: #777;\r\n  -webkit-box-shadow: 0 15px 10px #777;\r\n  -moz-box-shadow: 0 15px 10px #777;\r\n  box-shadow: 0 15px 10px #777;\r\n  -webkit-transform: rotate(-3deg);\r\n  -moz-transform: rotate(-3deg);\r\n  -o-transform: rotate(-3deg);\r\n  -ms-transform: rotate(-3deg);\r\n  transform: rotate(-3deg);\r\n}\r\n\r\n\/* RIGHT SHADOW *\/\r\n\r\n.effect3\r\n{\r\n  position: relative;\r\n}\r\n.effect3:after\r\n{\r\n  z-index: -1;\r\n  position: absolute;\r\n  content: \"\";\r\n  bottom: 15px;\r\n  right: 10px;\r\n  left: auto;\r\n  width: 50%;\r\n  top: 80%;\r\n  max-width:300px;\r\n  background: #777;\r\n  -webkit-box-shadow: 0 15px 10px #777;\r\n  -moz-box-shadow: 0 15px 10px #777;\r\n  box-shadow: 0 15px 10px #777;\r\n  -webkit-transform: rotate(3deg);\r\n  -moz-transform: rotate(3deg);\r\n  -o-transform: rotate(3deg);\r\n  -ms-transform: rotate(3deg);\r\n  transform: rotate(3deg);\r\n}\r\n<\/pre>\n<p>View:<br \/>\n<figure id=\"attachment_3932\" aria-describedby=\"caption-attachment-3932\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box4.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box4.jpg\" alt=\"Right and Left Box-Shadow Applied\" width=\"800\" height=\"500\" class=\"size-full wp-image-3932\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box4.jpg 800w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box4-300x188.jpg 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-3932\" class=\"wp-caption-text\">Right and Left Box-Shadow Applied<\/figcaption><\/figure><\/p>\n<h3>3.3 Hard Box Shadow on Both Sides <\/h3>\n<p>In this example, we look at a 3D like effect on both sides box shadow.<\/p>\n<pre class=\"brush:css\">\r\n\r\n\/* EFFECT 4 *\/\r\n\r\n.effect4\r\n{\r\n  position: relative;\r\n}\r\n.effect4:before, .effect4:after\r\n{\r\n  z-index: -1;\r\n  position: absolute;\r\n  content: \"\";\r\n  bottom: 25px;\r\n  left: 10px;\r\n  width: 50%;\r\n  top: 80%;\r\n  max-width:300px;\r\n  background: #777;\r\n  -webkit-box-shadow: 0 35px 20px #777;\r\n  -moz-box-shadow: 0 35px 20px #777;\r\n  box-shadow: 0 35px 20px #777;\r\n  -webkit-transform: rotate(-8deg);\r\n  -moz-transform: rotate(-8deg);\r\n  -o-transform: rotate(-8deg);\r\n  -ms-transform: rotate(-8deg);\r\n  transform: rotate(-8deg);\r\n}\r\n.effect4:after\r\n{\r\n  -webkit-transform: rotate(8deg);\r\n  -moz-transform: rotate(8deg);\r\n  -o-transform: rotate(8deg);\r\n  -ms-transform: rotate(8deg);\r\n  transform: rotate(8deg);\r\n  right: 10px;\r\n  left: auto;\r\n}\r\n<\/pre>\n<p>View:<br \/>\n<figure id=\"attachment_3934\" aria-describedby=\"caption-attachment-3934\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box5.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box5.jpg\" alt=\"Both Sides Box Shadow\" width=\"800\" height=\"300\" class=\"size-full wp-image-3934\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box5.jpg 800w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box5-300x113.jpg 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-3934\" class=\"wp-caption-text\">Both Sides Box Shadow<\/figcaption><\/figure><\/p>\n<h3>3.4 Soft Inset Shadow <\/h3>\n<p>You can also set inset shadows in a box element.<\/p>\n<pre class=\"brush:css\">\r\n\/* EFFECT 5 *\/\r\n\r\n.effect5\r\n{\r\n    position:relative;\r\n    -webkit-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;\r\n       -moz-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;\r\n            box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;\r\n}\r\n.effect5:before, .effect5:after\r\n{\r\n    content:\"\";\r\n    position:absolute;\r\n    z-index:-1;\r\n    -webkit-box-shadow:0 0 20px rgba(0,0,0,0.8);\r\n    -moz-box-shadow:0 0 20px rgba(0,0,0,0.8);\r\n    box-shadow:0 0 20px rgba(0,0,0,0.8);\r\n    top:50%;\r\n    bottom:0;\r\n    left:10px;\r\n    right:10px;\r\n    -moz-border-radius:100px \/ 10px;\r\n    border-radius:100px \/ 10px;\r\n}\r\n.effect5:after\r\n{\r\n    right:10px;\r\n    left:auto;\r\n    -webkit-transform:skew(8deg) rotate(3deg);\r\n       -moz-transform:skew(8deg) rotate(3deg);\r\n        -ms-transform:skew(8deg) rotate(3deg);\r\n         -o-transform:skew(8deg) rotate(3deg);\r\n            transform:skew(8deg) rotate(3deg);\r\n}\r\n<\/pre>\n<p>View:<br \/>\n<figure id=\"attachment_3939\" aria-describedby=\"caption-attachment-3939\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box7.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box7.jpg\" alt=\"Soft Inset Shadow\" width=\"800\" height=\"300\" class=\"size-full wp-image-3939\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box7.jpg 800w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box7-300x113.jpg 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-3939\" class=\"wp-caption-text\">Soft Inset Shadow<\/figcaption><\/figure><\/p>\n<h3>3.5 Top, Bottom and Left, Right Inset Shadow <\/h3>\n<p>These two examples show: top and bottom inset shadow, left and right inset shadow.<\/p>\n<pre class=\"brush:css\">\r\n\r\n\/* TOP AND BOTTOM INSET SHADOW *\/\r\n\r\n.effect6\r\n{\r\n    position:relative;\r\n    -webkit-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;\r\n       -moz-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;\r\n            box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;\r\n}\r\n.effect6:before, .effect6:after\r\n{\r\n    content:\"\";\r\n    position:absolute;\r\n    z-index:-1;\r\n    -webkit-box-shadow:0 0 20px rgba(0,0,0,0.8);\r\n    -moz-box-shadow:0 0 20px rgba(0,0,0,0.8);\r\n    box-shadow:0 0 20px rgba(0,0,0,0.8);\r\n    top:0;\r\n    bottom:0;\r\n    left:10px;\r\n    right:10px;\r\n    -moz-border-radius:100px \/ 10px;\r\n    border-radius:100px \/ 10px;\r\n}\r\n.effect6:after\r\n{\r\n    right:10px;\r\n    left:auto;\r\n    -webkit-transform:skew(8deg) rotate(3deg);\r\n       -moz-transform:skew(8deg) rotate(3deg);\r\n        -ms-transform:skew(8deg) rotate(3deg);\r\n         -o-transform:skew(8deg) rotate(3deg);\r\n            transform:skew(8deg) rotate(3deg);\r\n}\r\n\r\n\/* LEFT AND RIGHT INSET SHADOW *\/\r\n\r\n.effect7\r\n{\r\n    position:relative;\r\n    -webkit-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;\r\n       -moz-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;\r\n            box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;\r\n}\r\n.effect7:before, .effect7:after\r\n{\r\n    content:\"\";\r\n    position:absolute;\r\n    z-index:-1;\r\n    -webkit-box-shadow:0 0 20px rgba(0,0,0,0.8);\r\n    -moz-box-shadow:0 0 20px rgba(0,0,0,0.8);\r\n    box-shadow:0 0 20px rgba(0,0,0,0.8);\r\n    top:10px;\r\n    bottom:10px;\r\n    left:0;\r\n    right:0;\r\n    -moz-border-radius:100px \/ 10px;\r\n    border-radius:100px \/ 10px;\r\n}\r\n.effect7:after\r\n{\r\n    right:10px;\r\n    left:auto;\r\n    -webkit-transform:skew(8deg) rotate(3deg);\r\n       -moz-transform:skew(8deg) rotate(3deg);\r\n        -ms-transform:skew(8deg) rotate(3deg);\r\n         -o-transform:skew(8deg) rotate(3deg);\r\n            transform:skew(8deg) rotate(3deg);\r\n}\r\n<\/pre>\n<p>View:<br \/>\n<figure id=\"attachment_3941\" aria-describedby=\"caption-attachment-3941\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box8.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box8.jpg\" alt=\"Top, Bottom &amp; Left, Right Inset Shadow\" width=\"800\" height=\"500\" class=\"size-full wp-image-3941\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box8.jpg 800w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/box8-300x188.jpg 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-3941\" class=\"wp-caption-text\">Top, Bottom &amp; Left, Right Inset Shadow<\/figcaption><\/figure><\/p>\n<h2>4. Conclusion<\/h2>\n<p>Generally speaking, shadows are a great way to make some nice touches on elements.<\/p>\n<p>They do create interesting look and feel of elements and that&#8217;s why you should consider using them.<\/p>\n<p>Sometimes the code will be complicated, but feel free to use effects we used in this example, (just copy and paste) if you like any of them just the way they are.<\/p>\n<p>However, if you feel professional at this, you can change values according to your needs.<\/p>\n<h2>5. Download<\/h2>\n<p>Below you can find all these shadow examples in one <code>html<\/code> file.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/04\/CSS-Box-Shadow.zip\"><strong>CSS Box-Shadow<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this example, we will go through the box-shadow property of css. Just like the text-shadow property, box-shadow will give an element of html a new look by adding different styled shadows. As you can imagine, this is going to be more of an examples show rather than exaplanation because the property is pretty straight-forward. &hellip;<\/p>\n","protected":false},"author":75,"featured_media":917,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-3891","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-css"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>CSS Box Shadow Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"In this example, we will go through the box-shadow property of css. Just like the text-shadow property, box-shadow will give an element of html a new look\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CSS Box Shadow Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"In this example, we will go through the box-shadow property of css. Just like the text-shadow property, box-shadow will give an element of html a new look\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/fabiocimo\" \/>\n<meta property=\"article:published_time\" content=\"2015-04-28T09:15:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-01-09T07:13:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Fabio Cimo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fabiocimo\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fabio Cimo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/\"},\"author\":{\"name\":\"Fabio Cimo\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22\"},\"headline\":\"CSS Box Shadow Example\",\"datePublished\":\"2015-04-28T09:15:52+00:00\",\"dateModified\":\"2018-01-09T07:13:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/\"},\"wordCount\":846,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg\",\"articleSection\":[\"CSS\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/\",\"name\":\"CSS Box Shadow Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg\",\"datePublished\":\"2015-04-28T09:15:52+00:00\",\"dateModified\":\"2018-01-09T07:13:02+00:00\",\"description\":\"In this example, we will go through the box-shadow property of css. Just like the text-shadow property, box-shadow will give an element of html a new look\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CSS\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/css\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"CSS Box Shadow Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22\",\"name\":\"Fabio Cimo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g\",\"caption\":\"Fabio Cimo\"},\"description\":\"Fabio is a passionate student in web tehnologies including front-end (HTML\/CSS) and web design. He likes exploring as much as possible about the world wide web and how it can be more productive for us all. Currently he studies Computer Engineering, at the same time he works as a freelancer on both web programming and graphic design.\",\"sameAs\":[\"https:\/\/www.facebook.com\/fabiocimo\",\"https:\/\/al.linkedin.com\/in\/fabiocimo\",\"https:\/\/x.com\/fabiocimo\",\"https:\/\/www.youtube.com\/fabiocimo1\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/fabio-cimo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CSS Box Shadow Example - Web Code Geeks - 2026","description":"In this example, we will go through the box-shadow property of css. Just like the text-shadow property, box-shadow will give an element of html a new look","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/","og_locale":"en_US","og_type":"article","og_title":"CSS Box Shadow Example - Web Code Geeks - 2026","og_description":"In this example, we will go through the box-shadow property of css. Just like the text-shadow property, box-shadow will give an element of html a new look","og_url":"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_author":"https:\/\/www.facebook.com\/fabiocimo","article_published_time":"2015-04-28T09:15:52+00:00","article_modified_time":"2018-01-09T07:13:02+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg","type":"image\/jpeg"}],"author":"Fabio Cimo","twitter_card":"summary_large_image","twitter_creator":"@fabiocimo","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Fabio Cimo","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/"},"author":{"name":"Fabio Cimo","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22"},"headline":"CSS Box Shadow Example","datePublished":"2015-04-28T09:15:52+00:00","dateModified":"2018-01-09T07:13:02+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/"},"wordCount":846,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg","articleSection":["CSS"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/","url":"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/","name":"CSS Box Shadow Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg","datePublished":"2015-04-28T09:15:52+00:00","dateModified":"2018-01-09T07:13:02+00:00","description":"In this example, we will go through the box-shadow property of css. Just like the text-shadow property, box-shadow will give an element of html a new look","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/css\/css-box-shadow-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"CSS","item":"https:\/\/www.webcodegeeks.com\/category\/css\/"},{"@type":"ListItem","position":3,"name":"CSS Box Shadow Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22","name":"Fabio Cimo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g","caption":"Fabio Cimo"},"description":"Fabio is a passionate student in web tehnologies including front-end (HTML\/CSS) and web design. He likes exploring as much as possible about the world wide web and how it can be more productive for us all. Currently he studies Computer Engineering, at the same time he works as a freelancer on both web programming and graphic design.","sameAs":["https:\/\/www.facebook.com\/fabiocimo","https:\/\/al.linkedin.com\/in\/fabiocimo","https:\/\/x.com\/fabiocimo","https:\/\/www.youtube.com\/fabiocimo1"],"url":"https:\/\/www.webcodegeeks.com\/author\/fabio-cimo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/3891","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/75"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=3891"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/3891\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/917"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=3891"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=3891"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=3891"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}