How to get box-shadow on left & right sides only
NOTE: I suggest checking out @Hamish's answer below; it doesn't involve the imperfect "masking" in the solution described here.
You can get close with multiple box-shadows; one for each side
box-shadow: 12px 0 15px -4px rgba(31, 73, 125, 0.8), -12px 0 8px -4px rgba(31, 73, 125, 0.8);
http://jsfiddle.net/YJDdp/
Edit
Add 2 more box-shadows for the top and bottom up front to mask out the that bleeds through.
box-shadow: 0 9px 0px 0px white, 0 -9px 0px 0px white, 12px 0 15px -4px rgba(31, 73, 125, 0.8), -12px 0 15px -4px rgba(31, 73, 125, 0.8);
http://jsfiddle.net/LE6Lz/
Box-Shadow Only on Left and Right
Use a negative value on spread-radius (4th value) to shrink the shadow. This can hide the unwanted top and bottom shadow.
box-shadow: inset 25px 0px 25px -25px rgba(0,0,0,0.45), inset -25px 0px 25px -25px rgba(0,0,0,0.45);
See DEMO.
Box Shadow only in the middle(Left-right) horizontaly
One very simple way of doing this would be to make use of pseudo-elements and put a shadow on those. Then position them absolute
ly relative
to the left and right of your main div
, with a lower z-index
. Add border-radius
for extra radial effect.
For example:
#login { position: relative; width: 200px; height: 200px; margin: 32px; background: rgb(247, 247, 247); border: 1px solid rgba(147, 184, 189, 0.8);}#login::before, #login::after { content: ''; position: absolute; z-index: -1; box-shadow: 0 0 30px rgba(0, 0, 0, 0.5); border-radius: 50%;}#login::before { top: 15%; left: 0; width: 10%; height: 70%; }#login::after { top: 15%; right: 0; width: 10%; height: 70%; }
<div id="login"></div>
How can I add a box-shadow on one side of an element?
Yes, you can use the shadow spread property of the box-shadow rule:
.myDiv{ border: 1px solid #333; width: 100px; height: 100px; box-shadow: 10px 0 5px -2px #888;}
<div class="myDiv"></div>
Related Topics
How to Not Underline an Element in a Link
Getting the Source HTML of the Current Page from Chrome Extension
How to Display an Unordered List in Two Columns
Display Pdf Within Web Browser
Absolute Urls Omitting the Protocol (Scheme) in Order to Preserve the One of the Current Page
Add a Background Image (.Png) to a Svg Circle Shape
Why Does HTML Require That Multiple Spaces Show Up as a Single Space in the Browser
Overlay Opaque Div Over Youtube Iframe
:After and :Before CSS Pseudo Elements Hack For Internet Explorer 7
Clear All Fields in a Form Upon Going Back With Browser Back Button
Limit Scope of External CSS to Only a Specific Element
Position Footer At Bottom of Page Having Fixed Header
Matching the First/Nth Element of a Certain Type in the Entire Document
Generate an HTML Response in a Java Servlet
Putting ≪Div≫ Inside ≪P≫ Is Adding an Extra ≪P≫
How to Have Multiple ≪Tbody≫ in Same ≪Table≫
How to Create a Circle With Links on Border Side
Make a Grid Item Span to the Last Row/Column in Implicit Grid