How to move "+" to right i n css? - css

My Css is as below i try to move the "+" icon to the right a bit but failed to move it, can anyone help?
.button-sec-icon {
background-color: #fdfdfd;
cursor:pointer;
background: transparent url("images/basicsetup/plus.png") no-repeat left!important;
margin-right: 5px;
border: 2px solid #EEEEEE;
border-radius: 5px 5px 5px 5px;
box-shadow: 0 3px 1px rgba(0, 0, 0, 0.2);
color: #ca2b2b;
display: block;
height: 28px;
margin: 10px 0 0 60px;
transition: all 0.5s ease 0s;
min-width: 150px;
width: 121px;
}
.button-sec-icon:hover {
border :1px solid #888;
box-shadow: 0 4px 1px rgba(0, 0, 0, 0.2);
}

You need to use background-position
background: transparent url("images/basicsetup/plus.png") no-repeat left!important;
So instead of using left, use
background-position: 10px 0; /* Parameters are X and Y respectively */

Can you just set the background-position to top right?
background: transparent url("images/basicsetup/plus.png") top right no-repeat !important;
Or even if you need it across a bit, use percentages or fixed widths:
background: transparent url("images/basicsetup/plus.png") 0 5% no-repeat !important;
background: transparent url("images/basicsetup/plus.png") 0 5px no-repeat !important;

You used the margin tag twice. "margin-right" and "margin". Delete the first "margin-right" and see what happens.

background-position: 10px 0px;
This should do the trick, background-position can be used in many ways.
Take a read here:
http://www.css3.com/css-background-position/

Related

Triangle with box shadow and not equal width

I am looking to have a left arrow that is 40px by 20px with a box-shadow. I have tried
The single right border approach -- the dimensions work perfectly, but then there is a square box border:
.item {
...
&::before {
content: '';
border-bottom: 20px solid transparent;
border-right: 20px solid #fff;
border-top: 20px solid transparent;
box-shadow: -3px 3px 3px 0 rgba(0, 0, 0, 0.4);
height: 0;
left: -20px;
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 0;
}
}
and the double border approach -- box shadow works great, but the dimensions are incorrect since it needs to be a perfect square for the triangle to work:
.item {
...
&::before {
border: 20px solid black;
border-color: transparent transparent #fff #fff;
transform-origin: 0 0;
transform: rotate(45deg);
box-shadow: -3px 3px 3px 0 rgba(0, 0, 0, 0.4);
}
}
Is it possible to achieve with CSS or do I just need to a use an SVG?
You can use filter: drop-shadow instead of box-shadow:
filter: drop-shadow(-3px 3px 3px rgba(0, 0, 0, 0.4));
ref: https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/drop-shadow

box shadow to left and right doesn't work

I want to make box-shadow to the left and right sides,however there is alway a shadow in the top of the box,I have checked my code many times.
#box {
margin: 0 auto;
margin-top: 0px;
border: 1px solid #ffffff;
border-top-color: #e99f2e;
overflow: hidden;
box-shadow: 2px 0 20px 2px #7f7e7f, -2px 0 20px 2px #7f7e7f;
}
<div id="box"></div>
First understand the syntax of box-shadow and then it get's easy to apply box-shadow at any side as you have planned your design,
syntax -
box-shadow : offset-x | offset-y | blur-radius | spread-radius | color
#box {
margin: 0 auto;
margin-top: 0px;
overflow: hidden;
box-shadow: -10px 0 2px -2px #7f7e7f, 10px 0 2px -2px #7f7e7f;
height: 150px;
width: 50%;
background:#cff;
margin-top:20px;
}
<div id="box"></div>
There is a hack actually.
You can achieve this by adding an "empty" top and bottom shadow.
box-shadow: 0 9px 0px 0px white, 0 -9px 0px 0px white, 12px 0 15px -4px rgba(30, 53, 125, 0.9), -12px 0 15px -4px rgba(30, 53, 125, 0.9);
I don't think this is as good as the other answers, but this is an alternative approach using absolute positioned pseudo elements with shadows.
.lr-shadow {
background:#fff;
border: 1px solid #fff;
border-top-color: #e99f2e;
width:100%;
max-width:500px;
height:200px;
position:relative;
margin:0 auto;
}
.lr-shadow:before, .lr-shadow:after {
box-shadow: 0 0 20px 2px #7f7e7f;
content:" ";
position:absolute;
top:50%;
transform:translateY(-50%);
height:90%;
z-index:-1;
}
.lr-shadow:before {
left:5px;
}
.lr-shadow:after {
right:5px;
}
<div class="lr-shadow"></div>
You can achieve this effect if you set the spread to the negative of blur parameter. For the left box shadow, set position to negative blur and the right box shadow, position to positive blur. I used 20px in this demo:
#box {
margin: 0 auto;
margin-top: 40px;
border: 1px solid #ffffff;
border-top-color: #e99f2e;
overflow: hidden;
width: 150px;
height: 150px;
box-shadow: 20px 0px 20px -20px #7f7e7f, -20px 0px 20px -20px #7f7e7f;
}
<div id="box"></div>
Check out this CSS Box-shadow generator to explore further.

lighter background-image CSS3

I have want to have a background-image one frame, but i need to make the image lighter. I have tried using opacity, but then a background image from another frame shines throungh. I also have some text in the same frame, and i don't want that text to get lighter.
I write in CSS3, here is my code;
.frameContent
{
background-image: url(/image/and_02.jpg);
background-size: 100%;
vertical-align: top;
border-left: #FFFFFF 20px solid;
border-right: #FFFFFF 20px solid;
border-top: #FFFFFF 15px solid;
padding: 25px 10px 10px 10px;
height:100%;
box-shadow: 2px 2px 2px;
}
As Bappi Das said, there is no background-opacity property. But background-image can take multiple parameters. We can use this to add some white in front of the image. Unfortunately, we cannot simply specify a color, but we can specify a gradient. So if we specify a gradient with two times the same color and make that color slightly transparent using rgba, we can alter the color of an image.
background-image: linear-gradient(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.5)),
url("/image/and_02.jpg");
Do this to the container element:
yourImageContainer:after {
content: "";
position: fixed;
top: 0; bottom: 0; left: 0; right: 0;
background: hsla(180,0%,50%,0.25);
pointer-events: none;
}
this will put a darker/lighter mask depending on what color you chose.
Add following css to your class ()
.frameContent
{
background-image: url(/image/and_02.jpg);
background-size: 100%;
vertical-align: top;
border-left: #FFFFFF 20px solid;
border-right: #FFFFFF 20px solid;
border-top: #FFFFFF 15px solid;
padding: 25px 10px 10px 10px;
height:100%;
box-shadow: 2px 2px 2px;
opacity: 0.2;
filter: alpha(opacity=20);
}
and check if it works for you. You can also check following links for your reference
http://css-tricks.com/snippets/css/transparent-background-images/
http://nicolasgallagher.com/css-background-image-hacks/demo/opacity.html
How about create nested elements?
.frame = Plain white;
.frameContent = your partially transparent Background
<div class="frame"><div class="frameContent">My Content here</div></div>
There is no CSS property background-opacity, but you can achieve it by inserting a pseudo element (::after) behind it.
.frameContent{
position:relative;
border-left: #FFFFFF 20px solid;
border-right: #FFFFFF 20px solid;
border-top: #FFFFFF 15px solid;
padding: 25px 10px 10px 10px;
height:100%;
box-shadow: 2px 2px 2px;
}
.frameContent::after{
content: "";
background: url(/image/and_02.jpg);
background-size:cover;
opacity: 0.5;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
z-index: -1;
}

CSS3 Buttons with icon

I am following this tutorial to create CSS 3 button with Icon. But the problem in this tutorial Icon height depends on font-size. If I increase font-size of text, icon fits well but if I try to reduce the font-size, it doesn't fit well.Image I am using is 40x30
a.button {
background-image: -moz-linear-gradient(top, #ffffff, #dbdbdb);
background-image: -webkit-gradient(linear,left top,left bottom,
color-stop(0, #ffffff),color-stop(1, #dbdbdb));
filter: progid:DXImageTransform.Microsoft.gradient
(startColorStr='#ffffff', EndColorStr='#dbdbdb');
-ms-filter: "progid:DXImageTransform.Microsoft.gradient
(startColorStr='#ffffff', EndColorStr='#dbdbdb')";
border: 1px solid #fff;
-moz-box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.4);
-webkit-box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.4);
box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.4);
border-radius: 2px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
padding: 5px 5px;
text-decoration: none;
text-shadow: #fff 0 1px 0;
float: left;
margin-right: 15px;
margin-bottom: 15px;
display: block;
color: #597390;
line-height: 38px;
font-size: 15px;
font-weight: bold;
}
a.button:hover {
background-image: -moz-linear-gradient(top, #ffffff, #eeeeee);
background-image: -webkit-gradient(linear,left top,left bottom,
color-stop(0, #ffffff),color-stop(1, #eeeeee));
filter: progid:DXImageTransform.Microsoft.gradient
(startColorStr='#ffffff', EndColorStr='#eeeeee');
-ms-filter: "progid:DXImageTransform.Microsoft.gradient
(startColorStr='#ffffff', EndColorStr='#eeeeee')";
color: #000;
display: block;
}
a.button:active {
background-image: -moz-linear-gradient(top, #dbdbdb, #ffffff);
background-image: -webkit-gradient(linear,left top,left bottom,
color-stop(0, #dbdbdb),color-stop(1, #ffffff));
filter: progid:DXImageTransform.Microsoft.gradient
(startColorStr='#dbdbdb', EndColorStr='#ffffff');
-ms-filter: "progid:DXImageTransform.Microsoft.gradient
(startColorStr='#dbdbdb', EndColorStr='#ffffff')";
text-shadow: 0px -1px 0 rgba(255, 255, 255, 0.5);
margin-top: 1px;
}
a.button {
border: 1px solid #979797;
}
a.button.icon {
padding-left: 11px;
}
a.button.icon span{
padding-left: 48px;
display: block;
background: url(../img/gmail2.png) no-repeat;
}
Your statement is a little ambiguous and lacks a question, but I'll take a stab.
In this scenario, font-size will always play a small factor, as it will determine the height of the icon. At some point you are going to need to know some details about the button size, but it doesn't have to be affected by font. If you set the button height and the img{ height:100%; } the image will scale to fit the area.
<div id="container">
<h1><img src="http://placedog.com/50/50" alt="" />Button</h1>
</div>
combined with
#container{
border: 2px solid black;
width: 200px;
height: 20px;
}
#container img{
height:100%;
}
Should get you something you close to what you're looking for. I've whipped up a small jsfiddle to demonstrate one way to accomplish this.
It would be helpful if you could share your code.
In the css3 buttons examples of the link you provided, if I decrease font-size and set the following CSS style, works.
span { display: block; }
span is the tag that wraps the text inside the buttons.

How to create a drop shadow only on one side of an element?

Is there a way to drop the shadow only on the bottom?. I have a menu with 2 images next to each other. I don't want a right shadow because it overlaps the right image. I don't like to use images for this so is there a way to drop it only on the bottom like:
box-shadow-bottom: 10px #FFF; or similar?
-moz-box-shadow: 0px 3px 3px #000;
-webkit-box-shadow: 0px 3px 3px #000;
box-shadow-bottom: 5px #000;
/* For IE 8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=180, Color='#000000')";
/* For IE 5.5 - 7 */
filter: progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=180, Color='#000000');
UPDATE 4
Same as update 3 but with modern css (=fewer rules) so that no special positioning on the pseudo element is required.
#box {
background-color: #3D6AA2;
width: 160px;
height: 90px;
position: absolute;
top: calc(10% - 10px);
left: calc(50% - 80px);
}
.box-shadow:after {
content:"";
position:absolute;
width:100%;
bottom:1px;
z-index:-1;
transform:scale(.9);
box-shadow: 0px 0px 8px 2px #000000;
}
<div id="box" class="box-shadow"></div>
UPDATE 3
All my previous answers have been using extra markup to get create this effect, which is not necessarily needed. I think this is a much cleaner solution... the only trick is playing around with the values to get the right positioning of the shadow as well as the right strength/opacity of the shadow. Here's a new fiddle, using pseudo-elements:
http://jsfiddle.net/UnsungHero97/ARRRZ/2/
HTML
<div id="box" class="box-shadow"></div>
CSS
#box {
background-color: #3D6AA2;
width: 160px;
height: 90px;
margin-top: -45px;
margin-left: -80px;
position: absolute;
top: 50%;
left: 50%;
}
.box-shadow:after {
content: "";
width: 150px;
height: 1px;
margin-top: 88px;
margin-left: -75px;
display: block;
position: absolute;
left: 50%;
z-index: -1;
-webkit-box-shadow: 0px 0px 8px 2px #000000;
-moz-box-shadow: 0px 0px 8px 2px #000000;
box-shadow: 0px 0px 8px 2px #000000;
}
UPDATE 2
Apparently, you can do this with just an extra parameter to the box-shadow CSS as everyone else just pointed out. Here's the demo:
http://jsfiddle.net/K88H9/821/
CSS
-webkit-box-shadow: 0 4px 4px -2px #000000;
-moz-box-shadow: 0 4px 4px -2px #000000;
    box-shadow: 0 4px 4px -2px #000000;
This would be a better solution. The extra parameter that is added is described as:
The fourth length is a spread
distance. Positive values cause the
shadow shape to expand in all
directions by the specified radius.
Negative values cause the shadow shape
to contract.
UPDATE
Check out the demo at jsFiddle: http://jsfiddle.net/K88H9/4/
What I did was to create a "shadow element" that would hide behind the actual element that you would want to have a shadow. I made the width of the "shadow element" to be exactly less wide than the actual element by 2 times the shadow you specify; then I aligned it properly.
HTML
<div id="wrapper">
<div id="element"></div>
<div id="shadow"></div>
</div>
CSS
#wrapper {
width: 84px;
position: relative;
}
#element {
background-color: #3D668F;
height: 54px;
width: 100%;
position: relative;
z-index: 10;
}
#shadow {
background-color: #3D668F;
height: 8px;
width: 80px;
margin-left: -40px;
position: absolute;
bottom: 0px;
left: 50%;
z-index: 5;
-webkit-box-shadow: 0px 2px 4px #000000;
-moz-box-shadow: 0px 2px 4px #000000;
box-shadow: 0px 2px 4px #000000;
}
Original Answer
Yes, you can do this with the same syntax you have provided. The first value controls the horizontal positioning and the second value controls the vertical positioning. So just set the first value to 0px and the second to whatever offset you'd like as follows:
-webkit-box-shadow: 0px 5px #000000;
-moz-box-shadow: 0px 5px #000000;
box-shadow: 0px 5px #000000;
For more info on box shadows, check out these:
http://www.css3.info/preview/box-shadow/
https://developer.mozilla.org/en/css/-moz-box-shadow#Browser_compatibility
http://www.w3.org/TR/css3-background/#the-box-shadow
Just use the spread parameter to make the shadow smaller:
.shadow {
-webkit-box-shadow: 0 6px 4px -4px black;
-moz-box-shadow: 0 6px 4px -4px black;
box-shadow: 0 6px 4px -4px black;
}
<div class="shadow">Some content</div>
Live demo: http://dabblet.com/gist/a8f8ba527f5cff607327
To not see any shadow on the sides, the (absolute value of the) spread radius (4th parameter) needs to be the same as the blur radius (3rd parameter).
If you have a fixed color on the background, you can hide the side-shadow effect with two masking shadows having the same color of the background and blur = 0, example:
box-shadow:
-6px 0 white, /*Left masking shadow*/
6px 0 white, /*Right masking shadow*/
0 7px 4px -3px black; /*The real (slim) shadow*/
Note that the black shadow must be the last, and has a negative spread (-3px) in order to prevent it from extendig beyond the corners.
Here the fiddle (change the color of the masking shadows to see how it really works).
div{
width: 100px;
height: 100px;
border: 1px solid pink;
box-shadow: -6px 0 white, 6px 0 white, 0 7px 5px -2px black;
}
<div></div>
You could also use clip-path to clip (hide) all overflowing edges but the one you want to show:
.shadow {
box-shadow: 0 4px 4px black;
clip-path: polygon(0 0, 100% 0, 100% 200%, 0 200%);
}
See clip-path (MDN). The arguments to polygon are the top-left point, the top-right point, the bottom-right point, and the bottom-left point. By setting the bottom edge to 200% (or whatever number bigger than 100%) you constrain your overflow to only the bottom edge.
Examples:
.shadow {
box-shadow: 0 0 8px 5px rgba(200, 0, 0, 0.5);
}
.shadow-top {
clip-path: polygon(0% -20%, 100% -20%, 100% 100%, 0% 100%);
}
.shadow-right {
clip-path: polygon(0% 0%, 120% 0%, 120% 100%, 0% 100%);
}
.shadow-bottom {
clip-path: polygon(0% 0%, 100% 0%, 100% 120%, 0% 120%);
}
.shadow-left {
clip-path: polygon(-20% 0%, 100% 0%, 100% 100%, -20% 100%);
}
.shadow-bottom-right {
clip-path: polygon(0% 0%, 120% 0%, 120% 120%, 0% 120%);
}
/* layout for example */
.box {
display: inline-block;
vertical-align: top;
background: #338484;
color: #fff;
width: 4em;
height: 2em;
margin: 1em;
padding: 1em;
}
<div class="box">none</div>
<div class="box shadow shadow-all">all</div>
<div class="box shadow shadow-top">top</div>
<div class="box shadow shadow-right">right</div>
<div class="box shadow shadow-bottom">bottom</div>
<div class="box shadow shadow-left">left</div>
<div class="box shadow shadow-bottom-right">bottom right</div>
I think this is what you're after?
.shadow {
-webkit-box-shadow: 0 0 0 4px white, 0 6px 4px black;
-moz-box-shadow: 0 0 0 4px white, 0 6px 4px black;
box-shadow: 0 0 0 4px white, 0 6px 4px black;
}
<div class="shadow">wefwefwef</div>
Another idea based on the answer of #theengineear where I will use inset instead of polygon. It's easier since it works the same way as margin or padding. I will also rely on CSS variable to easily define all the different cases.
.shadow {
box-shadow: 0 0 8px 5px rgba(200, 0, 0, 0.5);
clip-path:inset(var(--t,0) var(--r,0) var(--b,0) var(--l,0))
}
.top { --t:-100%; }
.right { --r:-100%;}
.bottom { --b:-100%; }
.left { --l:-100%;}
/* layout for example */
.box {
display: inline-block;
vertical-align: top;
background: #338484;
color: #fff;
width: 4em;
height: 2em;
margin: 1em;
padding: 1em;
}
<div class="box">none</div>
<div class="box shadow top right left bottom">all</div>
<div class="box shadow top">top</div>
<div class="box shadow right">right</div>
<div class="box shadow bottom">bottom</div>
<div class="box shadow left">left</div>
<div class="box shadow bottom right">bottom right</div>
<div class="box shadow bottom top">top bottom</div>
<div class="box shadow left top right">top left right</div>
<div class="box shadow left right"> left right</div>
It's always better to read the specs. There is no box-shadow-bottom property, and as Lea points out you should always place the un-prefixed property at the bottom, after the prefixed ones.
So it's:
.shadow {
-webkit-box-shadow: 0px 2px 4px #000000;
-moz-box-shadow: 0px 2px 4px #000000;
box-shadow: 0px 2px 4px #000000;
}
<div class="shadow">Some content</div>
How about just using a containing div which has overflow set to hidden and some padding at the bottom? This seems like much the simplest solution.
Sorry to say I didn't think of this myself but saw it somewhere else.
Using an element to wrap the element getting the box-shadow and a overflow: hidden on the wrapper you could make the extra box-shadow disappear and still have a usable border.
This also fixes the problem where the element is smaller as it seems, because of the spread.
Like this:
#wrapper { padding-bottom: 10px; overflow: hidden; }
#elem { box-shadow: 0 0 10px black; }
Content goes here
Still a clever solution when it has to be done in pure CSS!
As said by Jorgen Evens.
I also needed a shadow but only under an image and set in slightly left and right. This worked for me:
.box-shadow {
-webkit-box-shadow: 5px 35px 30px -25px #888888;
-moz-box-shadow: 5px 35px 30px -25px #888888;
box-shadow: 5px 35px 30px -25px #888888;
}
The element this is applied to is a page-wide image (980px x 300px).
If it helps when fiddling with the settings, they run as follows:
horizontal shadow, vertical shadow, blur distance, spread (i.e. shadow size), and color.
It is better to look up shadow:
.header{
-webkit-box-shadow: 0 -8px 73px 0 rgba(0,0,0,0.2);
-moz-box-shadow: 0 -8px 73px 0 rgba(0,0,0,0.2);
box-shadow: 0 -8px 73px 0 rgba(0,0,0,0.2);
}
this code is currently using on stackoverflow web.
If your background is solid (or you can reproduce it using CSS), you can use linear gradient that way:
div {
background-image: linear-gradient(to top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.3) 5px, #fff 5px, #fff 100%)
}
<div>
<p>Foobar</p>
<p>test</p>
</div>
This will generate a 5px gradient at the bottom of the element, from black at 30% opacity to completely transparent. The rest of the element has white background. Of course, changing the last 2 color stops of the linear gradient, you could make the background completely transparent.
This code pen (not by me) demonstrates a super simple way of doing this and the other sides by themselves quite nicely:
box-shadow: 0 5px 5px -5px #333;
https://codepen.io/zeckdude/pen/oxywmm
You could also just do a gradient on the bottom - this was helpful for me because the shadow I wanted was on an element that was already semi-transparent, so I didn't have to worry about any clipping:
&:after {
content:"";
width:100%;
height: 8px;
position: absolute;
bottom: -8px;
left: 0;
background: linear-gradient(to bottom, rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%);
}
Just make the "bottom" and "height" properties match and set your rgba values to whatever you want them to be at the top / bottom of the shadow
You can do that like this:
General syntax:
selector {
box-shadow: topBoxShadow, bottomBoxShadow, rightBoxShadow, leftBoxShadow
}
Example: we want to make only a bottom box shadow with red color,
so to do that we have to set all the sides options where we have to set the bottom box shadow options and set all the others as empty as follow:
.box {
-moz-box-shadow: 0 0 0 transparent ,0 0 10px red, 0 0 0 transparent, 0 0 0 transparent
-o-box-shadow: 0 0 0 transparent ,0 0 10px red, 0 0 0 transparent, 0 0 0 transparent
-webkit-box-shadow: 0 0 0 transparent ,0 0 10px red, 0 0 0 transparent, 0 0 0 transparent
box-shadow: 0 0 0 transparent ,0 0 10px red, 0 0 0 transparent, 0 0 0 transparent
}
You need fist to know each value is for what:
/* offset-x | offset-y | blur-radius | spread-radius | color */
box-shadow: 2px 2px 2px 1px rgba(0, 0, 0, 0.2);
To apply a shadow effect only on one side of an element set the blur value to a positive number and set the spread value to the same size but with a negative sign. Depending on which side you want the shadow on, set the offset value as follows:
Top shadow: offset-x: 0 and offset-y: -5px
Right shadow: offset-x: 5px and offset-y: 0
Bottom shadow: offset-x: 0 and offset-y: 5px
Left shadow: offset-x: -5px and offset-y: 0
.box{
margin: 2rem;
padding: 1rem;
}
.shadow-all{
box-shadow: 2px 2px 2px 1px rgba(0, 0, 0, 0.2);
}
.shadow-top {
box-shadow: 0 -5px 3px -3px #00000030;
}
.shadow-right {
box-shadow: 5px 0 3px -3px #00000030;
}
.shadow-bottom {
box-shadow: 0 5px 3px -3px #00000030;
}
.shadow-left {
box-shadow: -5px 0 3px -3px #00000030;
}
<div class="box shadow-all">
Shadow All
</div>
<div class ="box shadow-top">
Shadow Top
</div>
<div class ="box shadow-right">
Shadow Right
</div>
<div class ="box shadow-bottom">
Shadow Bottom
</div>
<div class ="box shadow-left">
Shadow left
</div>
Read more here and here
inset top and bottom box-shadow
.cont{
position: relative;
border: 1px solid black;
margin: 0 auto;
width: 200px;
height: 200px;
overflow: hidden;
}
.shadow {
position: absolute;
width: 100%;
height:100%;
box-shadow: inset gray 0px 50px 15px 0px,inset gray 0px -50px 15px 0px;
padding-right: 30px;
margin-left: -15px;
}
<div class=cont>
<div class=shadow></div>
</div>
update on someone else his answer transparant sides instead of white so it works on other color backgrounds too.
body {
background: url(http://s1.picswalls.com/wallpapers/2016/03/29/beautiful-nature-backgrounds_042320876_304.jpg)
}
div {
background: url(https://www.w3schools.com/w3css/img_avatar3.png) center center;
background-size: contain;
width: 100px;
height: 100px;
margin: 50px;
border: 5px solid white;
box-shadow: 0px 0 rgba(0, 0, 0, 0), 0px 0 rgba(0, 0, 0, 0), 0 7px 7px -5px black;
}
<div>
</div>
inner shadow
.shadow {
-webkit-box-shadow: inset 0 0 9px #000;
-moz-box-shadow: inset 0 0 9px #000;
box-shadow: inset 0 0 9px #000;
}
<div class="shadow">wefwefwef</div>

Resources