CSS Drop Shadow effect not displaying correctly - html

I am creating a button with a drop shadow effect (neumorphism) but when I apply my CSS to the button is just appears as a 2 toned solid button...Which part of the CSS am I using incorrectly? Are my drop shadow values wrong relative to the size of the button? Changing the width and height doesn't help.
.css-test {
background: #EAF0F8;
mix-blend-mode: normal;
border: 0.5px solid #FFFFFF;
box-shadow: 0px -30px 60px rgba(167, 179, 190, 0.35), 0px 30px 60px rgba(167, 179, 190, 0.35);
border-radius: 35px;
}
.buysellbutton {
width: 44px;
height: 44px;
background: #F0F0F3;
box-shadow: -10px -10px 30px 40% #FFFFFF, 10px 10px 30px rgba(174, 174, 192, 0.4);
border-radius: 16px;
}
<div class="css-test">
<h3> Cash Flow: <span>CSS TEST</span></h3>
<button class="buysellbutton">buy</button>
</div>

to remove black border from button just add broder-style:none to button. Added one more button with hover and active styling.
for creating Neumorphism effect you can check https://neumorphism.io/
.css-test {
background: #EAF0F8;
mix-blend-mode: normal;
border: 0.5px solid #FFFFFF;
box-shadow: 0px -30px 60px rgba(167, 179, 190, 0.35), 0px 30px 60px rgba(167, 179, 190, 0.35);
border-radius: 15px;
padding: 10px;
}
.buysellbutton {
width: 80px;
height: 44px;
border-style:none;
border-radius: 16px;
background: #F0F0F3;
box-shadow: 18px 18px 36px #c5c5c7,
-18px -18px 36px #ffffff;
outline:none;
}
.button {
width: 150px;
height: 50px;
background: #f3f0f1;
position: relative;
background: #f3f0f1;
margin-bottom: 25px;
border-radius: 32px;
text-align: center;
cursor: pointer;
transition: all 0.1s ease-in-out;
outline: none;
border-style: none;
box-shadow: -6px -6px 10px rgba(255, 255, 255, 0.8),
6px 6px 10px rgba(0, 0, 0, 0.2);
color: #6f6cde;
}
span {
font-size: 25px;
font-weight: semibold;
}
.button:hover {
opacity: 0.7;
box-shadow: -6px -6px 10px rgba(255, 255, 255, 0.8),
6px 6px 10px rgba(0, 0, 0, 0.2);
}
.button:active {
opacity: 1;
box-shadow: inset -4px -4px 8px rgba(255, 255, 255, 0.5),
inset 8px 8px 16px rgba(0, 0, 0, 0.1);
color: #79e3b6;
}
<div class="css-test">
<h3> Cash Flow: <span>CSS TEST</span></h3>
<button class="buysellbutton">buy</button>
<button class="button"><span>Buy</span></button>
</div>

First, use the below code at the top of all CSS
button{
all: unset;
}
and instead of
box-shadow: -10px -10px 30px 40% #FFFFFF, 10px 10px 30px rgba(174, 174, 192, 0.4);
use
box-shadow: -10px -10px 30px 40px #FFFFFF, 10px 10px 30px rgba(174, 174, 192, 0.4);

Related

How to style a button like the image?

I am trying to create a button like this image with PURE CSS. Please could you help me with the CSS ?
This Image
I am trying using below but not giving exact same result -
.styled {
border: 0 !important;
line-height: 2.5;
font-weight: bold;
text-align: center !important;
color: rgba(11,44,20,255) !important;
border-radius: 8px !important;
padding: 5px 16px 5px 16px;
transition: 0.2s all;
background-image: linear-gradient(to top left,
rgba(0, 0, 0, .2),
rgba(0, 0, 0, .2) 100%,
rgba(0, 0, 0, 0)) !important;
box-shadow: inset 7px 7px 3px rgba(255, 255, 255, .6),
inset -7px -7px 3px rgba(0, 0, 0, .7) !important;
}
This is closest as I can get without the button background. You can try experimenting with CSS gradients until you hit the actual angle.
#button{
width: 69px;
height: 34px;
position: relative;
background: #3F4E4C;
background: -webkit-radial-gradient(bottom right, #3F4E4C, #7CD9BA);
background: -moz-radial-gradient(bottom right, #3F4E4C, #7CD9BA);
background: radial-gradient(to top left, #3F4E4C, #7CD9BA);
border: none;
outline: none;
border-radius: 8px;
}
#external{
position: absolute;
top: 6px;
left: 6px;
background: #3ade66;
width: calc(100% - 12px);
height: calc(100% - 12px);
border-radius: 6px;
text-align:center;
color: black;
line-height: 2.2;
font-size: 10px;
font-weight: bold;
}
<button id="button">
<div id="external">Start</div>
</button>
Add an onclick event to the image.
function myFunction() {
alert("Button clicked");
};
img {
/*Disables dragging of the image*/
-webkit-user-drag: none;
-khtml-user-drag: none;
-moz-user-drag: none;
-o-user-drag: none;
user-drag: none;
/*Sets the mouse to pointer when hovered*/
cursor: pointer;
}
<img src="https://i.stack.imgur.com/Rggof.png" onclick="myFunction();">
Got the similar view using -
.styled {
border: 0 !important;
line-height: 2.5;
font-weight: bold;
text-align: center !important;
color: rgba(11,44,20,255) !important;
border-radius: 10px !important;
transition: 0.2s all;
background-image: linear-gradient(to top left,
rgba(0, 0, 0, .2),
rgba(0, 0, 0, .2) 100%,
rgba(0, 0, 0, 0)) !important;
box-shadow: inset 6px 6px 1px rgba(255, 255, 255, .3),
inset -6px -6px 1px rgba(0, 0, 0, .3) !important;
}

Apply box shadow to border in css

I made this button design in Figma and would like to apply it in CSS.
If you look closely you can see that I applied a highlight with a white shadow on the border
But when I do it with the following CSS lines it just has a shadow inside and not on the border like this image shows.
div {
border-style: solid;
border-width: 0.7em;
border-color: var(--highlight);
box-shadow: inset 0.2em 0.2em 0.4em rgba(255, 255, 255, 0.25), inset -2px -2px 4px rgba(0, 0, 0, 0.25);
filter: drop-shadow(5px 5px 10px rgba(0, 0, 0, 0.25));
}
<div> Sign Up </div>
how can I apply the highlight/shadow on the border?
I have trying to create the div looks like your Figma design,
I use the combination of normal (outset) box-shadow and inset box-shadow.
The outset was used to give bright shadow and make the div looks stronger, and I saw the figma show the darker inner shadow to make the border looks a little bit 3D.
NOTE: I use border-style: ridge to make the border looks 3D as shown in Your Figma, you can make it flat by using border-style: solid
[Capture attached below
body{
background-color: rgb(50, 53, 90);
}
div {
width: 100px;
margin: auto;
color: white;
padding-top: 4px;
padding-bottom: 4px;
border-radius: .6rem;
text-align: center;
border-style: ridge;
border-width: 0.2em;
border-color: rgb(251, 55, 102);
box-shadow: 0em 0em 1.5px rgba(255, 255, 255, 0.25), inset 0px 0px 5px rgba(0, 0, 0, 0.25);
filter: drop-shadow(5px 5px 10px rgba(0, 0, 0, 0.25));
}
Using border-style: ridge
body{
background-color: rgb(50, 53, 90);
}
div {
width: 100px;
margin: auto;
color: white;
padding-top: 4px;
padding-bottom: 4px;
border-radius: .6rem;
text-align: center;
border-style: solid;
border-width: 0.2em;
border-color: rgb(251, 55, 102);
box-shadow: 0em 0em 1.5px rgba(255, 255, 255, 0.25), inset 0px 0px 5px rgba(0, 0, 0, 0.25);
filter: drop-shadow(5px 5px 10px rgba(0, 0, 0, 0.25));
}
Using border-style: solid
Sorry if this is not what you want, I hope you like my answer
<style>
#example3 {
border: 10px solid red;
border-radius: 5px
}
#bg{
background-color: #000;
color: #fff;
padding: 20px;
text-align: center
}
</style>
<div id="bg">
<div id="example3">
<p>A pink shadow.</p>
</div>
</div>
Image showing box shadow effect>
box-shadow: 0 0 25px color-of-choice;
This will create a faint shadow all around the image or block.
Make sure the color matches with your background color.

CSS3 : Box shadow just like in the image

I have an image. I want to have the box shadow just like in the image.
I have tried below code.
.main_div{
height:260px;
width:300px;
-moz-box-shadow: 0px 3px 8px rgb(67, 176, 238);
-webkit-box-shadow: 0px 3px 8px rgb(67, 176, 238);
box-shadow: 0px 3px 8px rgb(67, 176, 238);
}
<div class="main_div"></div>
I don't want box-shadow to top.
Any help would be great.
Thank You.
You could add multiple box-shadow, as you don't want that at top so you could style each side as below,
Syntax for box-shadow,
box-shadow:offset-x | offset-y | blur-radius | spread-radius | color
.main_div {
height: 260px;
width: 300px;
margin: 50px;
box-shadow: 0px 12px 10px -5px rgba(67, 176, 238, 1), 10px 12px 10px -5px rgba(67, 176, 238, 1), -10px 12px 10px -5px rgba(67, 176, 238, 1);
}
<div class="main_div"></div>
try this; hope it works for you;
.main_div {
height: 260px;
width: 300px;
-moz-box-shadow: 0px 3px 8px rgb(67, 176, 238);
-webkit-box-shadow: 0px 3px 8px rgb(67, 176, 238);
box-shadow: 0px 6px 30px rgb(67, 176, 238);
}
you can try
.main_div{
height:260px;
width:300px;
-moz-box-shadow: 0px 3px 8px rgb(67, 176, 238);
-webkit-box-shadow: 0px 3px 8px rgb(67, 176, 238);
box-shadow: 0px 3px 6px rgba(32, 79, 182);
}
I hope this is what you are looking for. You can change opacity to your liking
.main-main{
height: 500px;
width: 500px;
background-color: #bcc0c6;
}
.main_div{
background-color: white;
height:260px;
width:300px;
-webkit-box-shadow: 0px 10px 15px 0px rgba(224, 13, 34,1);
-moz-box-shadow: 0px 10px 15px 0px rgba(224, 13, 34,1);
box-shadow: 0px 10px 15px 0px rgba(224, 13, 34,1);
}
<br />
<div class="main-main">
<div class="main_div"></div>
</div>
I have used your image (displayed at the top) and I also wrapped your div in order to set a background color similar to yours. I think the result (displayed at the bottom) is quite close to the provided image:
.main_div_wrap {
background-color:#eff2f4;
width: 350px;
padding: 25px;
}
.main_div {
background-color:#ffffff;
height: 260px;
width: 350px;
-moz-box-shadow: 0px 9px 12px 0px rgb(197, 224, 246);
-webkit-box-shadow: 0px 9px 12px 0px rgb(197, 224, 246);
box-shadow: 0px 9px 12px 0px rgb(197, 224, 246);
}
What about this?
<img src="https://i.stack.imgur.com/hbltS.png" />
<div class="main_div_wrap">
<div class="main_div"></div>
</div>

CSS-Image border glow when hover with individual color

I would like to ask how should I apply different colour glow to an image border when a user hover over? like say that in this JSFiddle file, I have a green thumb and a red thumb. I want each image border to glow according to the colour of the image, or any colour that I specify. How should I achieve that?
PS** For example purposes the image are converted to base64 in the JSFiddle.
This is how I do in my CSS
img{
width: 16px;
cursor: pointer;
padding: 10px;
}
img:hover{
border-color: #66afe9;
outline: 0;
-webkit-box-shadow: inset 5px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
box-shadow: inset 5px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
}
Thank You
If I understand your question then here is an example DEMO
img{
width: 48px;
cursor: pointer;
/*padding: 10px;*/
/* border:1px solid #fff;*/
margin-right: 20px;
}
img:hover{
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: 0px 0px 30px 0px rgba(0, 255, 0, 0.67);
-moz-box-shadow: 0px 0px 30px 0px rgba(0, 255, 0, 0.67);
box-shadow: 0px 0px 30px 0px rgba(0, 255, 0, 0.67);
}
img:last-of-type:hover{
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: 0px 0px 30px 0px rgba(232, 0, 0, 0.67);
-moz-box-shadow: 0px 0px 30px 0px rgba(232, 0, 0, 0.67);
box-shadow: 0px 0px 30px 0px rgba(232, 0, 0, 0.67);
}
As written in the comment, there is no way for HTML/CSS to determine the main color of the image displayed. If you know the predominant color of each image, give them class names accordingly and write the related CSS.
See demo for a simple version.
img.green:hover{
border-color: #66afe9;
box-shadow: 0 0 8px rgba(0,255,0, 0.6);
}
img.red:hover{
border-color: #66afe9;
box-shadow: 0 0 8px rgba(255,0,0, 0.6);
}
Change:
box-shadow: inset 5px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
to:
box-shadow: inset 0 0 5px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
DEMO
box-shadow Syntax:
Formal syntax: none | [inset? && [ <offset-x> <offset-y> <blur-radius>? <spread-radius>? <color>? ] ]#
Box shadow also worked for,
img:hover{ box-shadow: 0 0 8px rgba(0, 0, 0, 0.6); }
If you want to more style in css
http://ianlunn.github.io/Hover/
or use your custom image like this
img:hover{background:url('http://www.addglitter.com/link-sparkle.gif');

How to create drop shadow?

I want to add drop shadow to input fields, I tried this code
.inp_text{
background: url(../images/inp_back.png) no-repeat;
border: none;
color: #393939;
height: 34px;
padding: 6px 6px 6px 6px;
width: 156px;
}
.inp_text:focus{
background: #fff;
box-shadow: 0 0 5px rgba(0, 0, 255, 1);
-webkit-box-shadow: 0 0 5px rgba(0, 0, 255, 1);
-moz-box-shadow: 0 0 5px rgba(0, 0, 255, 1);
border: 1px solid rgba(0, 0, 255, 0.8);
}
This is working fine in firefox but, I am not getting the blue glow in other browsers(IE & chrome). Please help.
use outline:none; in .inp_text you will find the desire result.
.inp_text{
background: url(../images/inp_back.png) no-repeat;
border: none;
color: #393939;
height: 34px;
padding: 6px 6px 6px 6px;
width: 156px;
outline:none;
}