My question is how can I blur only the border of an image?
The image itself should not be blured, just the border.
EDIT: done..thanks!
You can do it by using box-shadow property like below
TIP: you need to match the shadow color to your background or image border for the desired effect.
.image-blurred-edge {
background-image: url('http://visitwabashcounty.com/wp-content/uploads/6056710418_03fda4569b_z-150x150.jpg');
width: 200px;
height: 200px;
box-shadow: 0 0 8px 8px #fff inset;
}
<div class="image-blurred-edge"></div>
Using img tag you have to use pseudo element that is :before
.shadow
{
display:inline-block;
position:relative;
width: 150px;
height: 150px;
}
.shadow:before
{
display:block;
content:'';
position:absolute;
width:100%;
height:100%;
-moz-box-shadow:inset 0px 0px 8px 4px #fff;
-webkit-box-shadow:inset 0px 0px 8px 4px #fff;
box-shadow:inset 0px 0px 8px 4px #fff;
}
<div class="shadow">
<img src="http://visitwabashcounty.com/wp-content/uploads/6056710418_03fda4569b_z-150x150.jpg" />
</div>
Considering your last comment Try this solution.
.shadow img{
border:2px solid #000;
box-shadow:1px 1px 10px 2px;
}
<div class="shadow">
<img src="http://visitwabashcounty.com/wp-content/uploads/6056710418_03fda4569b_z-150x150.jpg" />
</div>
Looking at your comments on Sagar Kodte's answer, is this what you wanted?
img {
border: 2px solid #000;
box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.8);
}
<img src="http://visitwabashcounty.com/wp-content/uploads/6056710418_03fda4569b_z-150x150.jpg" />
I added a border of 2px to the images and a box shadow.
"Out there" idea:
I'll preface this by saying css variables are coming in fast but are not everywhere yet (Just IE lagging behind I think).
That being said I think they are a wonderful idea and will put this answer here just so you know of their existence.
.red {
--border-color: #900;
}
.green {
--border-color: #090;
}
.blue {
--border-color: #009;
}
.clown {
--border-color-top: green;
--border-color-right: yellow;
--border-color-bottom: red;
--border-color-left: blue;
}
img {
border-top: 2px solid var(--border-color-top, var(--border-color, #000));
border-bottom: 2px solid var(--border-color-bottom, var(--border-color, #000));
border-right: 2px solid var(--border-color-right, var(--border-color, #000));
border-left: 2px solid var(--border-color-left, var(--border-color, #000));
box-shadow: 0 -4px 10px -1px var(--border-color-top, var(--border-color, #000)), 4px 0 10px -1px var(--border-color-right, var(--border-color, #000)), 0 4px 10px -1px var(--border-color-bottom, var(--border-color, #000)), -4px 0 10px -1px var(--border-color-left, var(--border-color, #000));
margin: 10px;
}
.img {
border: 2px solid var(--border-color, #000);
box-shadow: 0 0 10px var(--border-color, #000);
margin: 10px;
}
<b>Standard:</b>
<br>
<img src="http://visitwabashcounty.com/wp-content/uploads/6056710418_03fda4569b_z-150x150.jpg" />
<br>
<b>Single color:</b>
<br>
<img class="red" src="http://visitwabashcounty.com/wp-content/uploads/6056710418_03fda4569b_z-150x150.jpg" />
<img class="green" src="http://visitwabashcounty.com/wp-content/uploads/6056710418_03fda4569b_z-150x150.jpg" />
<img class="blue" src="http://visitwabashcounty.com/wp-content/uploads/6056710418_03fda4569b_z-150x150.jpg" />
<br>
<b>Mulitple colors:</b>
<br>
<img class="clown" src="http://visitwabashcounty.com/wp-content/uploads/6056710418_03fda4569b_z-150x150.jpg" />
HTML
<img class="borderBlur" src="http://visitwabashcounty.com/wp-content/uploads/6056710418_03fda4569b_z-150x150.jpg" />
CSS
.borderBlur {
border: 2px solid #000;
box-shadow: 0 0 15px 5px rgba(0, 0, 0, 0.8);
}
As long as you wrap the image in a div you can apply a box-shadow to that.
It will appear under the image to start, so you need to apply a lower z-index to the image
body {
text-align: center;
}
.img-wrap {
display: inline-block;
margin: 2em;
box-shadow: inset 0 0px 4px 4px black;
}
img {
display: block;
position: relative;
z-index: -1;
}
<div class="img-wrap">
<img src="http://www.fillmurray.com/284/196" alt="" />
</div>
Related
I'm trying correctly shadow the tabs on this site. Not sure If the issue are the values or the html markup.
div.ui-tabs-panel.ui-widget-content.ui-corner-bottom {
background-color: #ffffff;
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
}
div.variableselector_valuesselect_variabletitle_panel {
background-color: #ffffff;
}
a.ui-tabs-anchor {
box-shadow: 1px 4px 2px rgba(0,0,0,0.16), 1px 0px 5px rgba(0,0,0,0.23);
}
here's a screenshot:
I think you are looking for this.
<div class="tabs">
<div class="tab"></div>
<div class="tab"></div>
</div>
<div class="box-container">
</div>
.box-container{
position: absolute;
top:72px;
left:4em;
tansform: translate(0,-50%);
height: 50%;
width:60%;
border: 2px solid #ddd;
z-index:0;
background: #fff;
filter:drop-shadow(2px 2px 5px #555)
}
.tabs{
position: absolute;
display:flex;
left:4em;
top:1.5em;
justify-content: space-between;
z-index:999;
}
.tab{
height:50px;
width:150px;
border:1px solid #ddd;
border-bottom:0;
background-color: #fff;
margin-right: 10px;
box-shadow: 0 -5px 18px -5px #555;
box-shadow: 18px 0 18px -5px #555;
box-shadow: -5px 0 18px -5px #555;
}
I am trying to replicate canvas frame effect on paintings on images using CSS.
I can do shadows and rounded corners but I couldn't figure out how to do the 3D effect of "rounded/wrapping sides".
My actual is left image while I am trying to replicate the effect of the right one. Please ignore the background of the expected image.
Any help?
Thanks.
.image{
display:flex;
justify-content:space-evenly;
}
#actual {
border-radius: 4px;
box-shadow: 20px 4px 10px rgba(0,0,0,0.35), 40px 8px 10px rgba(0,0,0,0.15);
}
<div class="image">
<img id="actual" src="http://lorempixel.com/output/cats-q-c-640-480-10.jpg">
<img id="expected" src="https://i.imgur.com/XD8Vdvv.jpg">
</div>
You can approximate it using inset shadow:
.image{
display:inline-block;
border-radius: 4px;
box-shadow:
-2px -2px 1px rgba(0,0,0,0.5) inset,
20px 4px 10px rgba(0,0,0,0.35),
40px 8px 10px rgba(0,0,0,0.15);
width:320px;
height:240px;
margin:10px;
background:url(http://lorempixel.com/output/cats-q-c-640-480-10.jpg) center/cover;
}
<div class="image">
</div>
Just want to get creative with box-shadow layering... Cheers;
figure {
display: block;
margin: 1rem auto;
height: 10rem;
width: 10rem;
border: gray 1px solid;
border-radius: 3px;
background: lightgray url('https://i.stack.imgur.com/BVW9D.jpg') no-repeat center center;
background-size: cover;
box-shadow: 2px 2px 0 gray,
3px 3px 4px rgba(0,0,0,.9),
6px 6px 12px 4px rgba(0,0,0,.25),
0 0 14px 4px rgba(0,0,0,.15);
}
<figure></figure>
How to give shadow to a border?
css codes:
p{
border-right:2px solid black;
line-height:4em
}
Now is it possible to give shadow to this border?
Depends on what type of shadow do you want to achieve
Dynamically generate the border and add the shadow
p {
line-height:4em;
position: relative;
}
p::after {
content: ' ';
width: 2px;
height: 4em;
background-color: black;
display: block;
position: absolute;
top: 0;
right: 0;
box-shadow: 3px 3px 2px red;
}
<p>Stack Overflow</p>
Simple offset shadow to the right
p {
border-right:2px solid black;
line-height:4em;
box-shadow: 2px 0px red;
}
<p>Stack overflow</p>
You can do this with box-shadow
p {
border-right: 2px solid black;
line-height:4em;
display: inline-block;
-webkit-box-shadow: 15px 0px 10px -10px rgba(0,0,0,0.51);
-moz-box-shadow: 15px 0px 10px -10px rgba(0,0,0,0.51);
box-shadow: 15px 0px 10px -10px rgba(0,0,0,0.51);
}
<p>Lorem ipsum dolor.</p>
Or try :after and linear-gradient
p {
border-right: 2px solid black;
line-height:4em;
display: inline-block;
position: relative;
}
p:before {
position: absolute;
z-index: -1;
top: 10%;
right: -5px;
width: 5px;
height: 100%;
background: linear-gradient(transparent, #aaa, transparent);
content: '';
}
<p>Lorem ipsum dolor.</p>
p{
border-right:2px solid black;
line-height:4em;
box-shadow: 10px 10px 5px #000000;
}
Just add box-shadow property, like below
p{
border-right:2px solid black;
line-height:4em;
-moz-box-shadow: 1px 0 0 red;
-webkit-box-shadow: 1px 0 0 red;
box-shadow: 1px 0 0 red;
width: 200px; /* for demo purpose only*/
}
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illo, fugit!</p>
Fiddle : https://jsfiddle.net/nikhilvkd/pnajhz9g/
It is possible with box-shadow.
General Example
p {
border:2px dashed #000;
-webkit-box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.75);
box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.75);
width:100px;
}
<p>some content</p>
Example for right shadow
p {
border:2px dashed #000;
-webkit-box-shadow: 10px 0 rgba(0,0,0,0.75);
-moz-box-shadow: 10px 0 rgba(0,0,0,0.75);
box-shadow: 10px 0 rgba(0,0,0,0.75);
width:100px;
}
<p>some content</p>
A tool to generate a box-shadow you can find here: http://www.cssmatic.com/box-shadow
From the official specification
The ‘box-shadow’ property attaches one or more drop-shadows to the box. The property accepts either the ‘none’ value, which indicates no shadows, or a comma-separated list of shadows, ordered front to back.
https://drafts.csswg.org/css-backgrounds-3/#box-shadow
use this
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
.shadow{
box-shadow: 1px 2px 3px black;
}
</style>
</head>
<body>
<p class="shadow">Shadow for me</p>
</body>
</html>
this will add for the whole width.
Note
for more details, this is the css syntax
box-shadow: none|h-shadow v-shadow blur spread color |inset|initial|inherit;
none :Default value. No shadow is displayed
h-shadow :Required. The position of the horizontal shadow. Negative values are allowed.
v-shadow :Required. The position of the vertical shadow. Negative values are allowed.
blur :Optional. The blur distance.
spread: Optional. The size of shadow. Negative values are allowed.
p {
line-height:4em;
position: relative;
}
p::after {
content: ' ';
width: 2px;
height: 4em;
background-color: black;
display: block;
position: absolute;
top: 0;
right: 0;
box-shadow: 3px 3px 2px red;
}
<p>Stack Overflow</p>
I’m trying to adapt some css code I found, however my table seems ugly (according to me). I'll explain this on a picture.
css:
td, th {
border-left: 1px solid #494437;
border-top: 1px solid #494437;
padding: 10px;
text-align: left;
}
th {
background-color: #b8ae9c;
-webkit-box-shadow: inset 2px 2px 0px 0px rgba(255,255,255,1);
-moz-box-shadow: inset 2px 2px 0px 0px rgba(255,255,255,1);
box-shadow: inset 2px 2px 0px 0px rgba(255,255,255,1);
border-top: none;
text-shadow: 0 1px 0 rgba(255,255,255,.5);
}
td:first-child, th:first-child {
border-left: none;
}
I explained what I want by an image:
EDIT: For example I expect white area on right side, when I add padding-right: 0.2em; into "th". But it doesn't change anything.
Is this what you are expecting?
.table {
border: 1px solid #000;
float: left;
}
.header {
border: 2px solid #ccc;
border-width: 2px 0 0 2px;
background-color: #b8ae9c;
margin: 2px;
float: left;
}
<div class="table">
<div class="header">Header</div>
<div class="header">Header</div>
</div>
How can I add an inner shadow to a bootstrap "image-circle"?
jsfiddle
This doesn't work..
.box-shad {
box-shadow: 0 10px 20px #777 inset, 0 0 200px #000 inset, 0 0 150px #000 inset, 0 0 100px #000 inset;
}
<img class="img-circle box-shad" alt="" src="http://placehold.it/140x140"><img class="img-circle box-shad" alt="" src="http://placehold.it/140x140">
Thanks for any ideas.
SOLUTION:
Put the box shadow on a circular div with background image set to the image, rather than using an image.
You can try something like this:
.box-shad {
-webkit-box-shadow: 7px 7px 5px 0px rgba(50, 50, 50, 0.75);
-moz-box-shadow: 7px 7px 5px 0px rgba(50, 50, 50, 0.75);
box-shadow: 7px 7px 5px 0px rgba(50, 50, 50, 0.75);
}
Demo: http://jsfiddle.net/52VtD/1926/
UPDATE
I don't think it's possibile to set an inner shadow because it's an image; you can draw the circle too instead of use an image, so you'll can set the inner shadow.
Code:
.box-shad {
-webkit-box-shadow: inset 0 0 4px #000;
-moz-box-shadow: inset 0 0 4px #000;
box-shadow: inset 0 0 4px #000;
}
.circle {
width: 140px;
height: 140px;
display: inline-block;
border-radius: 50%;
background-color: #aaa;
}
Demo: http://jsfiddle.net/52VtD/1943/
This works to me. Please try it.
.inner-shadow {
box-shadow: inset 3px 3px 4px black;
border-radius: 50%;
}
img {
width: 100%;
border-radius: 50%;
position: relative;
z-index: -10;
}
<div class="inner-shadow">
<img src="http://placehold.it/300x300" alt="">
</div>
Closest I get is this:
http://jsfiddle.net/52VtD/1941/
<div class="border">
<a class="shadow img-circle"><img class="img-circle" src="http://placehold.it/140x140" /></a>
CSS:
.border
{
padding:10px;
width:160px;
}
.shadow
{
display:block;
position:relative;
}
.shadow img
{
display:block;
}
.shadow::before
{
display:block;
content:'';
position:absolute;
width:100%;
height:100%;
-moz-box-shadow:inset 0px 0px 5px 2px rgba(0,0,0,0.2);
-webkit-box-shadow:inset 0px 0px 5px 2px rgba(0,0,0,0.2);
box-shadow:inset 0px 0px 5px 2px rgba(0,0,0,0.2);
}
this article may help http://designbystevie.com/2011/03/applying-css3-inset-box-shadows-to-images/