Is it possible to create shadow like that in CSS3? - html

I'm almost sure that it's not possible to create shadows like that in CSS3 but I'm asking just in case anybody tried that and found a way:
I have sidebar to the right (limited height) and longer content the the left. The shadow fades in at the beginning and fades out at the end. Can this shadow be purely procedural (no raster images at all)?

You can use radial gradients like so:
#leftshadow
{
margin-left: 10px;
height: 200px;
width: 20px;
border-left:1px solid #ebebeb;
border-left:1px solid rgba(0,0,0,0.4);
background:-webkit-gradient(linear,left top,right top,from(rgba(0,0,0,.3)),to(rgba(0,0,0,0)));
-webkit-mask-box-image:-webkit-gradient(linear,left top,right bottom,color-stop(0.0,rgba(0,0,0,0)),color-stop(0.5,rgba(0,0,0,.8)),color-stop(1.0,rgba(0,0,0,0)));
background-image:-moz-radial-gradient(left,ellipse farthest-side,rgba(0,0,0,.3),rgba(0,0,0,0));
}​
jsFiddle here
Different tweak is here
Original Answer
If you require a "simple" inset shadow you can also achieve this like so:
#leftshadow
{
-webkit-box-shadow: inset 5px 0px 5px -2px rgba(0,0,0,0.4);
-moz-box-shadow: inset 5px 0px 5px -2px rgba(0,0,0,0.4);
box-shadow: inset inset 5px 0px 5px -2px rgba(0,0,0,0.4);
}​
jsFiddle here

here's the trick I talked about, that is, layering a secondary div with a white shadow:
http://jsfiddle.net/dmezK/
it is not perfect but you can tweak it to fit your needs, I think.
here's the HTML:
<div id="main">
<div id="cheat"></div>
</div>​
here's the CSS:
#main
{
width: 100px;
height: 300px;
-webkit-box-shadow: inset 10px 0px 5px -2px #888 ;
position: relative;
}
#cheat {
width: 300px;
height: 300px;
-webkit-box-shadow: inset 10px 0px 5px -50px white ;
position: absolute;
left: -100px;
}
note: maybe you could use multiple box shadows, but it isn't as widely supported.

This is the closest I could make:
div {
width: 300px;
height: 600px;
border: solid 1px;
box-shadow:
inset 0px 10px 10px #fff,
inset 0px -10px 10px #fff,
inset 10px 0px 20px rgba(0, 0, 0, .3);
}
Live demo: Tinkerbin

try this
http://jsfiddle.net/6QSEc/1/
div{
height:200px;
width:100px;
background-color:white;
border:1px solid #f1f1f2;
box-shadow:10px 0px 20px -10px rgba(0,0,0,0.5) inset;
}

.box {
z-index: 100;
border: none;
padding: 0 0 0 10px;
background-image: url("images/topShadow"), url('images/bottomShadow'), url('images/shadow');
background-position: 0 top, left top, 0 bottom;
background-repeat: no-repeat, repeat-x, no-repeat;
}
Ok this is untested but should work with some tweaking that I don't have time for at the moment. You have 3 images, top, middle, and bottom. You use CSS3 multiple background images to use this as your left border, just add some padding to the left of the box. The order is important as it handles the layering of the images. The 1st one will be on top of all the others. The order acts as z-index for the images.

Related

How to make a pure CSS full height and truly transparent folding effect over an image?

Inspired by this link and this link, I am trying to make pure CSS folding effect with two requirements:
fully transparent background to show an <IMAGE> behind it (!)
being able to use the FULL height of the <DIV> element inside it (!)
I've tried making mine work but the topright corner doesnt become transparent. If I replace...
border-top: 60px solid red;
with
border-top: 60px solid transparent;
then the background of the rectangle box appears through it. Is there a way to solve this with pure CSS solution? If yes how? If not, then what alternatives are they that come close to CSS? The code/coordinations should be readable, interpretable and easily changeable by humans without the need of a vector based program such as inkscape.
The DEMO where I'm stuck:
https://jsfiddle.net/cg7hoyt3/
Perhaps use a linear-gradient instead of an solid color as a background to your primary div.
The border-width and the gradient stop have a ratio of 1 / sqrt(2) = .7071.
If you're using CSS Custom Properties or a CSS preprocessor this becomes much simpler.
Codepen Demo of variable use
body {
background-image: url("http://hdbackgroundspic.com/wp-content/uploads/2017/09/drop-of-water-background.jpg");
}
div {
width: 230px;
height: 230px;
margin: 50px auto;
background: linear-gradient(-135deg, transparent, transparent 45px, gold 45px, gold);
position: relative;
}
div::after {
content: " ";
position: absolute;
top: 0;
right: 0;
height: 0px;
width: 0px;
z-index: 2;
border-width: 30px; /* note .7071 of gradient-stop */
border-style: solid;
border-color: transparent transparent yellow yellow;
filter: drop-shadow(-2px 6px 6px rgba(0, 0, 0, .5));
}
<div></div>
As suggested in the comments, this can be done with a clipping mask:
clip-path: polygon(0 0, 210px 0, 100% 60px, 100% 100%, 0 100%);
While this can look rather daunting, it is actually really easy to read: just read the points one-by-one, starting from the top left. The points draw a polygon around what will be visible.
Note that clip-mask will only work with modern browsers (IE + Edge not included). See Can I use for up-to-date browser support and Mozilla Plotform Status for up-to-date development status.
Here is the code:
body {background-image: url("http://hdbackgroundspic.com/wp-content/uploads/2017/09/drop-of-water-background.jpg")}
.page {
width: 230px;
height: 230px;
margin: 50px auto;
background: gold;
padding: 20px;
}
.fold {
position: relative;
-webkit-box-shadow: -5px 7px 5px rgba(0,0,0,0.8);
-moz-box-shadow: -5px 7px 5px rgba(0,0,0,0.8);
box-shadow: -5px 7px 5px rgba(0,0,0,0.8);
-webkit-clip-path: polygon(0 0, 210px 0, 100% 60px, 100% 100%, 0 100%);
clip-path: polygon(0 0, 210px 0, 100% 60px, 100% 100%, 0 100%);
}
.fold:before, .fold:after {
content: "";
position: absolute;
top: 0%;
right: 0%;
width: 0px;
height: 0px;
}
.fold:before {
border-bottom: 60px solid #BBB;
border-right: 60px solid transparent;
-webkit-box-shadow: -5px 5px 5px 5px rgba(0,0,0,0.1);
-moz-box-shadow: -5px 5px 5px 5px rgba(0,0,0,0.1);
box-shadow: -5px 5px 5px 5px rgba(0,0,0,0.1);
}
.fold:after {
border-top: 60px solid transparent;
border-left: 60px solid yellow;
}
<div class="page fold">
<h2>Dear Bettie</h2>
Will you please erase that darn red corner from this folded note love?<br><br>
Thanks xxx<br>Sandra
</div>

is it possible to give the shadow inside the container?

.part-two{
float: left;
height:300px;
width: 200px;
background-color:green;
box-shadow: -10px -10px 1px red;
}
<div id="part-two" class="part-two">
</div>
in the above code i have given an outer shadow using box-shadow property,instead of that i want to give the shadow on inside of the container,is it possible to give inner shadow using box-shadow method?if yes,how?
else ,is there any methods exists to giver inner shadow using css?
Yes it is possible to add inner-shadow to an element, you just need to add inset along with your properties in box-shadow.
The presence of the inset keyword changes the shadow to one inside the
frame (as if the content was depressed inside the box). Inset shadows
are drawn inside the border (even transparent ones), above the
background, but below content.
.part-two{
float: left;
height:300px;
width: 200px;
background-color:green;
box-shadow: inset 0px 1px 10px 20px orange;
}
<div id="part-two" class="part-two">
</div>
Use this box-shadow: 10px 10px 0px 0px red inset;
.part-two{
float: left;
height:300px;
width: 200px;
background-color:green;
box-shadow: 10px 10px 0px 0px red inset;
}
<div id="part-two" class="part-two">
</div>
used to this
box-shadow:inset 5px 5px 1px red, inset 15px 15px 1px yellow;
inset as like this
.part-two{
float: left;
height:300px;
width: 200px;
background-color:green;
box-shadow:inset 5px 5px 1px red, inset 15px 15px 1px yellow;
}
<div id="part-two" class="part-two">
</div>
you looking for something like this?
.part-two
{
float: left;
height:300px;
width: 200px;
background-color:green;
box-shadow: -10px -10px 1px red;
-moz-box-shadow: inset 0 0 10px red;
-webkit-box-shadow: inset 0 0 10px red;
box-shadow: inset 0 0 10px red;
}
<div id="part-two" class="part-two">
</div>
Try this:
.part-two{
float: left;
height:300px;
width: 200px;
background-color:green;
box-shadow: inset -10px -10px 1px red;
}

Box-shadow over border

I have this problem where I want to have a border and a box-shadow, but the shadow must be over the border.
The box-shadow property starts when the border ends, is it possible to move it over the border?
.border
{
border: solid rgba(128,42,42,.98) 16px;
}
.img-box-shadow
{
-moz-box-shadow: 0px 0px 20px #000000;
-webkit-box-shadow: 0px 0px 20px #000000;
box-shadow: 0px 0px 20px #000000;
}
My HTML:
<img class="border img-box-shadow" src="img.png">
Already tried inset in my box shadow, but it didn't work!
I'm looking for this effect:
And I'm getting this result:
I think this would be much more easily achieved with two overlayed box shadows
Something like this approaches what you're looking for
box-shadow: 0 0 20px 5px #000000,
0 0 0 16px rgba(128,42,42,.98);
Seem like you want an inset box shadow, then you can use:
box-shadow: inset 0 -15px 10px -10px #444;
-moz-box-shadow: inset 0 -15px 10px -10px #444;
-webkit-box-shadow: inset 0 -15px 10px -10px #444;
Fiddle Demo
How about this one?
.ds-bottom {
position:relative;
overflow:hidden;
border-bottom:1px solid #ddd;
}
.ds-bottom:before {
content: "";
position:absolute;
z-index: 1;
width:96%;
bottom: -10px;
height: 10px;
left: 2%;
border-radius: 100px / 5px;
box-shadow:0 0 18px rgba(0,0,0,0.6);
}
You can try using inset and then lowering the alpha value of your border. It may not exactly be what you want, but it's close.
.border
{
border: solid rgba(128,42,42,.5) 4px;
}
.img-box-shadow
{
-moz-box-shadow: inset 0px 0px 20px #000000;
-webkit-box-shadow: inset 0px 0px 20px #000000;
box-shadow: inset 0px 0px 20px #000000;
}
Alternate option (borrowed from this question). Don't use the .border and just use this (you can play around with pixel values):
.img-box-shadow
{
box-shadow: rgba(0,0,0,.98) 0px 0px 3px, inset rgba(0,0,0,.98) 0px -2px 3px;
}
Here's a JSFiddle
First, you have mistake in box shadow format.
box-shadow: 0px 0px 20px #000000;
Change to
box-shadow: 0px 0px 20px 0 #000000;
Due to the right format of Box Shadow Properties
box-shadow: horizontal-length vertical-length blur-radius
spread-radius;
Next, to make it works with your requirement you must wrap your image inside div. Box-shadow wont works over border.
Here's the style
div {
display:inline-block;
padding:4px; /* Act as border width */
background:rgba(128,42,42,.98); /* Act as border color */
}
.img-box-shadow
{
box-shadow: inset 0px 0px 20px 0 #000000;
-webkit-box-shadow: inset 0px 0px 20px 0 #000000;
-moz-box-shadow: inset 0px 0px 20px 0 #000000;
}
And the HTML Markup
<div class="img-box-shadow">
<img src="http://graph.facebook.com/715380382/picture?type=large">
</div>
Check live demo http://jsbin.com/hex/1/edit

Image box shadow border styling in CSS

I would like to achieve a CSS border similar to the one seen around the Tim Cook image on this page: http://www.macstories.net/news/tim-cook-at-d11/ — however, I would only like the border around images in the body text on my own site, not, for instance, images in the sidebar of my site.
What code would I need to achieve the cool border, and how can I target only images in the body text?
If your "body text" is, say, in a div classed as "main", you can target the images just in that section like so:
.main img {
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0 0 5px rgba(0,0,0,0.2);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
margin: 30px 0;
padding: 10px;
background: #FFF;
border: 1px solid #CCC;
position: relative;
display: block;
}
img{
-webkit-box-shadow:0 0px 7px rgba(0,0,0,0.3);
box-shadow:0 0 5px rgba(0,0,0,0.2);
padding:10px;
background:#fff;
border:1px solid #ccc;
width:auto;
height:auto;
}
Well i think it would be something like this for just a generic shadow effct.
The HTML:
<div id="example" class="outerglow">Full Shadow</div>
The CSS:
#example {
font-size: 1.4em;
color: #CCCCCC;
line-height: 40px;
text-align: center;
background-color: #333333;
margin: 25px auto;
padding: 5px 10px;
height: 40px;
width: 80%;}
.outerglow {
box-shadow: 0px 0px 3px 2px rgba(0,0,0,0.6);
-moz-box-shadow: 0px 0px 3px 2px rgba(0,0,0,0.6);
-webkit-box-shadow: 0px 0px 3px 2px rgba(0,0,0,0.6);}
and here is the jsfiddle to look see..
http://jsfiddle.net/KMtc6/
Forgive me if my code is sloppy or jumbled.

CSS - Corner Radius with Box Shadow Inset, ugly corners

When I try to apply a box shadow to my element that has a 3px border radius I get ugly corners with pixels of the elements background.
HTML
<div id="wrapper">
</div>
CSS
body {
background: #fff;
}
#wrapper {
background: black;
width: 300px;
height: 300px;
margin: 40px auto;
border-radius: 3px;
-moz-box-shadow: inset 0 0 5px 4px yellow;
-webkit-box-shadow: inset 0 0 5px 4px yellow;
box-shadow: inset 0 0 5px 4px yellow;
}
JSFIDDLE
http://jsfiddle.net/PCzFC/1/
If you look at the fiddle you see that the black background is in the corners. Is it supposed to be like this or is it a bug? I use Firefox.
This is a known bug in Google Chrome, perhaps it's present in Firefox as well.
http://code.google.com/p/chromium/issues/detail?id=29427
You can create the same effect without the inset. Make a yellow wrapper around it.
body {
background: #fff;
}
#wrapper {
background: black;
width: 290px;
height: 290px;
border-radius: 3px;
-moz-box-shadow: 0 0 5px 1px black;
-webkit-box-shadow: 0 0 5px 1px black;
box-shadow: 0 0 5px 1px black;
margin: 5px;
}
.yellow {
background: yellow;
border-radius: 6px;
overflow: hidden;
width: 300px;
height: 300px;
margin: 40px auto;
}​
<div class="yellow">
<div id="wrapper">
</div>
</div>
http://jsfiddle.net/PCzFC/65/
What shadow: inset does is to add shadows inside the box. If you remove inset on all the box shadows, the shadows will move to the outside of the box.
it is not a bug this will happen because you use inset shadow effect and if you can understand css then inset meaning is inside so it's normal if u remove inset from your code then it should be look fine or if you need shadow effect inside the box then you have to choose color and matched it to box color
or you can remove border radius from your code then it should be look fine
#wrapper {
background: black;
width: 300px;
height: 300px;
margin: 40px auto;
-moz-box-shadow: inset 0 0 5px 4px yellow;
-webkit-box-shadow: inset 0 0 5px 4px yellow;
box-shadow: inset 0 0 5px 4px yellow;
}