I have come humbly to you big brains, as my little ol' brain just is not engaging on this one.
I have a need to do a lifted corner effect on all 4 sides of an image.
I've found 3 different methods to accomplish the lifted corners:
with box shadow and rotate
http://jsfiddle.net/zuul/mPnTP/
.drop-shadow {
position:relative;
float:left;
width:40%;
padding:1em;
margin:2em 10px 4em;
background:#fff;
-webkit-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
-moz-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
}
.drop-shadow:before,
.drop-shadow:after {
content:"";
position:absolute;
z-index:-2;
}
.drop-shadow p {
font-size:16px;
font-weight:bold;
}
/* Lifted corners */
.lifted {
-moz-border-radius:4px;
border-radius:4px;
}
.lifted:before,
.lifted:after {
bottom:15px;
left:10px;
width:50%;
height:20%;
max-width:300px;
-webkit-box-shadow:0 15px 10px rgba(0, 0, 0, 0.7);
-moz-box-shadow:0 15px 10px rgba(0, 0, 0, 0.7);
box-shadow:0 15px 10px rgba(0, 0, 0, 0.7);
-webkit-transform:rotate(-3deg);
-moz-transform:rotate(-3deg);
-ms-transform:rotate(-3deg);
-o-transform:rotate(-3deg);
transform:rotate(-3deg);
}
.lifted:after {
right:10px;
left:auto;
-webkit-transform:rotate(3deg);
-moz-transform:rotate(3deg);
-ms-transform:rotate(3deg);
-o-transform:rotate(3deg);
transform:rotate(3deg);
}
<div class="drop-shadow lifted">
<p>Lifted corners</p>
</div>
with linear gradient and rotate
http://cssdeck.com/labs/page-curl-box-shadow
with box shadow and skew
http://www.readitsideways.com/css3_demos/shadows/.
The skew example seems to deform more on zoom than the rotate. There is probably one method that is cleaner than the others?
All the examples show only two sides with the effect - and my diddling to try and add the other two sides appears to cancel out the original two. I have also been unsuccessful with applying the styling directly to the image, though that's probably a padding or margin issue.
My questions:
Can this be done on 4 sides?
Two divs, one div nested and stacked on top of another with the image in the inner div?
Or, can it be done with one div and an image?
I'd appreciate any help in sorting this out because I am totally adrift.
Thanks!
UPDATE 12/1
#Vals
Thanks for your contribution! So many different methods to get a similar result! I posted 3 methods above, then found a 4th that uses box shadow and linear gradient, no rotate or skew:
http://cjwainwright.co.uk/webdev/liftedcorners/
Yours uses box shadow and transform, and I'm calling it method #5. I note that this covers 2 sides, top and bottom, where I was seeking a 4 sided solution.
I received a 4 sided solution (#6) that uses box shadow and rotate with spans, thankyou to Danny Williams from the WW list:
http://codepen.io/dsongman/pen/PPMdpb?editors=110
I am not sure if this is a duplicate , there are lots of examples about this.
But I don't see any with all 4 corners, so here is my solution
.test {
width: 700px;
height: 300px;
margin: 50px;
position: relative;
background-color: lightgreen;
}
.test:before {
content: "";
position: absolute;
width: 30%;
height: 96%;
top: 2%;
left: 40px;
transform: perspective(500px) rotateY(10deg);
transform-origin: left center;
box-shadow: 0px 0px 30px 10px black;
z-index: -1;
}
.test:after {
content: "";
position: absolute;
width: 30%;
height: 96%;
top: 2%;
right: 40px;
transform: perspective(500px) rotateY(-10deg);
transform-origin: right center;
box-shadow: 0px 0px 30px 10px black;
z-index: -1;
}
<div class="test"></div>
Related
I need to create an element with shadow like in the mockup:
http://take.ms/UdLFk
But I created only
http://take.ms/lns0J .
I have next styles:
.shadow {
width: 45px;
left: 37px;
position: relative;
box-shadow: 0 0px 2px 2px rgba(0,0,0,0.5);
}
My markup:
<div class=" shadow"></div>
So, how i can get a shadow like in mockup? I searched many articles but they did not help me.
Adding a border-radius (with a small height and a background-color that fits the shadow) to the element will give the shadow a nice rounded effect. Maybe decrease the opacity a little and you'll get pretty close. Also try using z-index: -1 to put the shadow behind the image.
.shadow {
width: 45px;
left: 37px;
position: relative;
box-shadow: 0 0px 4px 2px rgba(0, 0, 0, 0.1);
border-radius: 50%;
height: 3px;
background: rgba(0, 0, 0, 0.1);
}
<div class="shadow"></div>
In CSS is there a way to make the border transparent, but the box (inside) with the border the same?
Please see this link:
http://jsfiddle.net/xiiJaMiiE/LfWBn/14/
#white_box {
position:absolute;
min-width:90%;
max-width:90%;
margin:0 auto;
height:92%;
top:0%;
left:5%;
right:5%;
background:white;
z-index:1;
width:80%;
border:5px #0F0 solid;
}
I would like to know if I can make the green border 0.6 opacity and keep the white inside normal.
Is that possible or would I have to make 2 divs on top each other?
Thanks in advance!
You could just use: border: 5px rgba(0, 255, 0, 0.6) solid;
UPDATED EXAMPLE
#white_box {
position: absolute;
min-width: 90%;
max-width: 90%;
margin: 0 auto;
height: 92%;
top: 0%;
left: 5%;
right: 5%;
background: white;
z-index: 1;
width: 80%;
border: 5px rgba(0, 255, 0, 0.6) solid;
}
Alternatively, you could use outline too; both have different results.
outline: 10px solid rgba(0, 255, 0, 0.6);
EXAMPLE HERE
Here if you want fully transparent than, you can use border-color: transparent-
border: 5px solid transparent;
Try in fiddel
Unfortunately, in Explorer, border-color: transparent is rendered as black.
Or if you you only want partially-transparent border, than you can use rgb with alpha transparency-
border: 5px solid rgba(255, 255, 255, 0.5); // 0.5 means 50% of opacity
The alpha transparency variate between 0 (0% opacity = 100% transparent) and 1 (100 opacity = 0% transparent)
Try in fiddle
this answer to add some info only. (3 ways : box-shadow:outset x x x ; or box-shadow: inset x x x; , or background-clip )
if you want opacity on borders and see through background of parent container, and not mixe with the background of the element itself, you can draw the background-color with inset shadow. http://jsfiddle.net/Y78Ap/1/ (increased voluntary border-width and added a gradient to body to have it more 'telling')
html,body {
Background-color:rgba(255,165,0,0.5);
background-image:linear-gradient(to bottom, rgba(0,0,0,0.3), rgba(255,255,255,0.3));
}
#white_box {
position:absolute;
min-width:90%;
max-width:90%;
margin:0 auto;
height:92%;
top:0%;
left:5%;
right:5%;
box-shadow:inset 0 0 0 2000px white;
z-index:1;
width:80%;
border: 15px rgba(0, 255, 0, 0.6) solid;
}
You can as well just draw borders with box-shadow: 0 0 5px rgba(0,255,0,0.6); instead border
The easiest way suppose to be, nowdays, is background-clip : http://css-tricks.com/transparent-borders-with-background-clip/
I'm trying to position an element (a button) relative to the element 2 elements before it (a picture). There is a varying amount of text between the picture and the button. Take a look at my site:
http://gorilla-gym.com/product-category/fitness-attachments/
What I'm trying to achieve is having the "Shop Now" buttons align horizontally for each product listing regardless of how much text is underneath the picture.
It seemed to me the most logical way to do this way to position the button relative to the picture, but I can't figure out how to do this. Let me know if you guys have an idea of how to do this, or if there's a better way to achieve what I want to do.
Thanks in advance.
check this one i think you want something like this
http://jsfiddle.net/FWzzR/1/
css
ul.products {
display:table;
width:100%;
table-layout:fixed;
border-collapse:separate;
border-spacing:10px;
}
.products > li {
background-color: #4F81BD;
border:2px solid #385D8A;
position: relative;
width: 22.05%;
display: table-cell;
padding:10px;
padding-bottom:50px;
text-align:center;
vertical-align:top;
}
.products > li >a {
display:block;
}
.products a.button {
position:absolute;
bottom:10px;
left:50%;
margin-left:-40px;
font-size: 100%;
line-height: 1em;
cursor: pointer;
text-decoration: none;
padding: 6px 10px;
font-family: inherit;
font-weight: bold;
color: #FFF;
text-shadow: 0 1px 0 #FF6311;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.8);
border: 1px solid #973100;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
background: #FD5200;
background: -webkit-gradient(linear, left top, left bottom, from(#FD5200), to(#CA4100));
background: -webkit-linear-gradient(#FD5200, #CA4100);
background: -moz-linear-gradient(center top, #FD5200 0%, #CA4100 100%);
background: -moz-gradient(center top, #FD5200 0%, #CA4100 100%);
-webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.075), inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 1px 2px rgba(0, 0, 0, 0.1);
-moz-box-shadow: inset 0 -1px 0 rgba(0,0,0,0.075), inset 0 1px 0 rgba(255,255,255,0.3), 0 1px 2px rgba(0,0,0,0.1);
box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.075), inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 1px 2px rgba(0, 0, 0, 0.1);
}
If all you want is to center align the "Shop Now" button at the bottom, then
.shopnow_button{
display: block;
margin: 0 auto; //something was overriding so I had to do !important here
width: 57px; // can be any value < the width of the parent container(Ofcourse !)
}
If there is a varying amount of text underneath the picture, then the elements will all be of varying height and you cannot align the "Shop Now" button horizontally beneath the picture. The only way to accomplish this is by making sure that all the divs are the same height, then you just position the shop now button as follows:
<div class="shop-now-div">
<img src="yourimage.jpg">
Lorem ipsum....
<a class="button" href="#">Shop Now</a>
</div>
.button { position: absolute; bottom: 5px; right: 5px; }
.shop-now-div { position: relative; }
There are two ways to make your div's the same height
1) JavaScript (not recommended, it's a pain)
2) A table (do it in CSS so you aren't messing with semantics)
UNFORTUNATELY, some modern browsers (Firefox, I believe) will not support position: relative on table-cell's (which you will need), so you are stuck with having to use JS to make your div's the same height....
Easiest solution:
Stick your shop now button on top of the image - that way you can easily align them horizontally. :)
This question is better answered here How to set relative position with Grandfather! element? simply setting position: relative on the grandfather element and position: absolute on the subject element.
That solution does rely on there being no positioning set on intermediate elements.
I have two questions about creating shadows like www.apple.com/ipodshuffle...
On the website, you'll see the main section with a white background - it contains all the information about the iPod Shuffle. The right, left and bottom of this main section have a shadow, but the top does not. How do I code this?
Just above the 2nd image of the iPod Shuffles (where they're all stacked on top of each other, and the text reads "Design. As beautiful as it is wearable.") there is a shadow border that looks like it's popping out of the page, and then fading back into the page. How do I code this?
Here's the code you're searching for :
.box{
padding: 20px;
border-radius: 5px;
-webkit-box-shadow: rgba(0, 0, 0, 0.3) 0 1px 3px;
-moz-box-shadow: rgba(0,0,0,0.3) 0 1px 3px;
box-shadow: rgba(0, 0, 0, 0.3) 0 1px 3px;
}
<div class="box">
Lorem ipsum
</div>
More informations about box-shadow here : http://www.css3.info/preview/box-shadow/
For the central shadow, they just used an image.
.box {
width: 200px;
height: 100px;
margin: auto;
padding: 20px;
border-radius: 5px;
background-color: #e4e4e4;
border: 1px solid #adadad;
-webkit-box-shadow: 0 20px 70px rgba(0, 0, 0, 0.55);
-moz-box-shadow: 0 20px 70px rgba(0, 0, 0, 0.55);
box-shadow: 0 20px 70px rgba(0, 0, 0, 0.55);
}
<div class="box">
Lorem ipsum
</div>
I have a site that will have a column of images and divs (a mix of both) that will always be the same size.
On all of these I want to add a certain kind of drop shadow (as seen here):
I've worked with CSS drop shadows but I've never seen one like this in CSS. Can this be done in CSS? Assuming it cannot then I'm guessing I would use just a drop shadow slice as a graphic, possibly a background. If that is the only route to go, how do I apply this to every image or div?
Right now what I'm doing is putting a div under each image or div:
<div class="rightimgdropshadow"> </div>
...and doing this in CSS:
.rightimgdropshadow
{
background-image: url(../images/site-structure/right-col-image-shadow.jpg);
background-repeat: no-repeat;
background-position: center top;
width 100%
height: 20px;
}
Is there a better way to do this? Thanks!
If you prefere to use CSS to create that type of shadows, you can use CSS3 as seen here!
CSS
/* Lifted corners */
.lifted {
-moz-border-radius:4px;
border-radius:4px;
}
.lifted:before,
.lifted:after {
bottom:15px;
left:10px;
width:50%;
height:20%;
max-width:300px;
-webkit-box-shadow:0 15px 10px rgba(0, 0, 0, 0.7);
-moz-box-shadow:0 15px 10px rgba(0, 0, 0, 0.7);
box-shadow:0 15px 10px rgba(0, 0, 0, 0.7);
-webkit-transform:rotate(-3deg);
-moz-transform:rotate(-3deg);
-ms-transform:rotate(-3deg);
-o-transform:rotate(-3deg);
transform:rotate(-3deg);
}
.lifted:after {
right:10px;
left:auto;
-webkit-transform:rotate(3deg);
-moz-transform:rotate(3deg);
-ms-transform:rotate(3deg);
-o-transform:rotate(3deg);
transform:rotate(3deg);
}
Made a Fiddle!
Something along the lines of
border: 1px solid #333;
border-bottom: none;
padding: 10px 10px 20px;
background: url('insert_image') no-repeat;
background-position: left bottom;
The extra padding at the bottom allows the background to sit in the correct place.
Does that help?
You can use box-shadow:
.rightimgdropshadow {
box-shadow: 0px 2px 3px rgba(0,0,0,.3);
}
This will create a similar effect, but it won't look just the same.
Some info on that.