So I'm trying to create a div element that upon hovering, will "pop" out, and appear as a 2.5D box. Basically, what this person was looking for:
3D Box Shadow effect
Except animated with a transition, so when not hovered upon, its a simple 2D box, and when hovered on, it appears like the second image in that person's question.
Here's a fiddle with what I have so far:
http://jsfiddle.net/78m3nzv6/
<div class="cat-box bot-row">
<h4>Hello World!</h4>
<p>Info</p>
</div>
.
.bot-row:hover {
transition: all 0.3s ease-in-out;
transform: translate(10px,10px);
}
.cat-box {
background-color: grey;
outline: #DDD8D4 solid 3px;
padding: 3px 5px 5px 5px;
margin: 10px 30px 10px 30px;
transition: all 0.3s ease-in-out;
}
You can actually do this in a very similar way to the answer that you linked to, by using multiple box-shadow declarations.
I also took the liberty of converting your outline to a border and setting box-sizing: border-box so that the border doesn't stick out from the effect.
Here is a Live Demo:
.bot-row:hover {
transition: all 0.3s ease-in-out;
transform: translate(10px, 10px);
box-shadow: -1px -1px 0px #999, -2px -2px 0px #999, -3px -3px 0px #999, -4px -4px 0px #999, -5px -5px 0px #999, -6px -6px 0px #999, -7px -7px 0px #999, -8px -8px 0px #999, -9px -9px 0px #999, -10px -10px 0px #999, -11px -11px 0px #999, -12px -12px 0px #999;
}
.cat-box {
box-sizing: border-box;
background-color: grey;
border: #DDD8D4 solid 3px;
padding: 3px 5px 5px 5px;
margin: 10px 30px 10px 30px;
transition: all 0.3s ease-in-out;
}
<div class="cat-box bot-row">
<h4>Hello World!</h4>
<p>Info</p>
</div>
JSFiddle Version: http://jsfiddle.net/78m3nzv6/3/
Related
So I have a button with initial shadow set. I want to transition the shadow on hover into another value of shadow.
button {
height:100px;
width:200px;
padding:10px;
margin:5px;
border:none;
border-radius:10px;
box-shadow: 10px 10px 20px #dde4ef, -10px -10px 20px white;
transition: box-shadow 0.5s ease-in;
}
button:hover{
box-shadow: inset 10px 10px 20px #dde4ef, inset -10px -10px 20px white;
}
<button>This Button</button>
Its not working
Prepare your inset shadows by using inset 0 0 0 transparent, inset 0 0 0 transparent,
button {
height:100px;
width:200px;
padding:10px;
margin:5px;
border:none;
border-radius:10px;
display: inline-block;
box-shadow:
inset 0 0 0 transparent, inset 0 0 0 transparent, /* Prepared inset shadows */
10px 10px 20px #dde4ef, -10px -10px 20px white; /* Outer shadows */
transition: box-shadow 0.5s ease-in;
}
button:hover{
box-shadow: inset 10px 10px 20px #dde4ef, inset -10px -10px 20px white;
}
<button type="button">HOVER ME</button>
I would like to create an animation starting when my div's attribute changed using pure CSS.
The div's initial state is:
display: none;
Changing display attribute to a value unequal none,
a animation should be played (inner glow effect using an inset box shadow).
The change of the attribute can occour multiple times. After every change the animation
should be played.
Is this possible using pure css? Or do I need to use javascript additionally?
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.0);
animation-duration: 5s;
animation-name: card-appear;
#keyframes card-appear{
0% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.0);
}
10% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.2);
}
20% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.4);
}
30% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.6);
}
40% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.8);
}
50% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,1.0);
}
60% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.8);
}
70% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.6);
}
80% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.4);
}
90% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.2);
}
100% {
box-shadow: inset 0px 0px 20px 5px rgba(255,255,255,0.0);
}
}
I want to set box shadow inside a box or div but only at right and left sides.
I want something like this below. Please help me.
To get it to appear only on the sides you need to essentially have two different sets:
box-shadow:inset 5px 0 8px -5px #000,inset -5px 0 8px -5px #000;
You can create one inner div and one outer div. Then you need to set the shadow separately for both divs.
.outer, .inner {
width: 200px;
height: 50px;
display: inlin-block;
}
.outer {
-webkit-box-shadow: inset 10px 0px 23px -9px rgba(0,0,0,0.75);
-moz-box-shadow: inset 10px 0px 23px -9px rgba(0,0,0,0.75);
box-shadow: inset 10px 0px 23px -9px rgba(0,0,0,0.75);
}
.inner {
-webkit-box-shadow: inset -10px 0px 23px -9px rgba(0,0,0,0.75);
-moz-box-shadow: inset -10px 0px 23px -9px rgba(0,0,0,0.75);
box-shadow: inset -10px 0px 23px -9px rgba(0,0,0,0.75);
}
<div class="outer">
<div class="inner"></div>
</div>
Or you can use also one div, with 2 inset parameters:
.outer {
width: 200px;
height: 50px;
display: inlin-block;
-webkit-box-shadow: inset 10px 0px 23px -9px rgba(0,0,0,0.75), inset -10px 0px 23px -9px rgba(0,0,0,0.75);
-moz-box-shadow: inset 10px 0px 23px -9px rgba(0,0,0,0.75), inset -10px 0px 23px -9px rgba(0,0,0,0.75);
box-shadow: inset 5px 0 8px -5px #000,inset -5px 0 8px -5px #000, inset -10px 0px 23px -9px rgba(0,0,0,0.75);
}
<div class="outer">
</div>
And what about a linear-gradeint solution:
.box {
width:200px;
height:100px;
background:
linear-gradient(to left,#ccc , transparent 20%),
linear-gradient(to right,#ccc , transparent 20%);
}
<div class="box">
</div>
You can do this using the two div's. check the below code.
But it will great if you can use the background image.
<div class="div1">
<div class="div2"><div>
<div>
.div1 {
width: 200px;
height: 100px;
border: 1px solid #c51e1e;
margin: 50px;
overflow: hidden;
}
.div2 {
width: 80%;
height: 100px;
margin: 0 auto;
box-shadow: 0px 0px 27px 17px #d6cdcd;
}
try this with html:
<div id="box"></div>
and css:
#box {
border: 1px solid;
position: relative;
overflow: hidden;
}
#box:before {
content: "";
box-shadow: 0px 0px 20px 10px #888888;
position: absolute;
height: 100%;
width: 0px;
}
#box:after {
content: "";
box-shadow: 0px 0px 20px 10px #888888;
position: absolute;
height: 100%;
width: 0px;
right: 0px;
top: 0;
}
<div class="myContainer">
Some text...
</div>
Now I only want on the left side and the top of the element a box-shadow.
How can I do this?
I tried this:
.myContainer {
box-shadow: 10px 10px 5px #888888;
}
But this doesn't work.
Like this, See fiddle: https://jsfiddle.net/DIRTY_SMITH/7oe5kh9L/25/
1st number - is the horizontal position (negative is left, positive right)
2nd number - is the vertical position (negative is up, positive down)
3rd number - is the blur radius
4th number - is spread radius
-webkit-box-shadow: -12px -9px 5px 0px rgba(0, 0, 0, 0.75);
-moz-box-shadow: -12px -9px 5px 0px rgba(0, 0, 0, 0.75);
box-shadow: -12px -9px 5px 0px rgba(0, 0, 0, 0.75);
HTML
<div class="someDiv"></div>
CSS
.someDiv {
width: 400px;
height: 400px;
background-color: lightblue;
margin-left: 50px;
margin-top: 50px;
-webkit-box-shadow: -12px -9px 5px 0px rgba(0, 0, 0, 0.75);
-moz-box-shadow: -12px -9px 5px 0px rgba(0, 0, 0, 0.75);
box-shadow: -12px -9px 5px 0px rgba(0, 0, 0, 0.75);
}
This should work :
div
{
width:400px;
height:400px;
left:45px;
box-shadow:-10px -5px 4px #ccc;
}
You can use negative values for the positioning.
box-shadow: -10px -10px 5px 0px #888888;
Use a CSS3 generator to try it out, like this one
Remember to also include the vendor specific prefixes to ensure cross browser compatibility.
-webkit-box-shadow: -10px -10px 5px 0px #888888;
-moz-box-shadow: -10px -10px 5px 0px #888888;
You can check it out with this jsfiddle
If you want to know more about the box-shadow property, then check out MDN box-shadow
Try this
div{
width:200px;
height:200px;
background-color:red;
margin:50px;
box-shadow:-10px -5px 4px #ccc;
}
<div></div>
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