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.
Related
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;
}
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);
In this button a shadow appearing and it looks like another button border there. I tried to use box-shadow property but I failed.
I used this CSS
a {
padding: 10px 40px;
border-radius: 30px;
font-size: 18px;
color: #fff;
border: 1px solid #fff;
box-shadow: 5px 5px 0px #2CBFBB;
}
Can anyone please help me?
You can achieve this effect with filter: drop-shadow and a transparent background:
body {
background: #76D7C4;
}
button {
text-transform: uppercase;
padding: 10px 20px;
color: white;
cursor: pointer;
background: transparent; /* no background! */
border: 1px solid white;
border-radius: 100px;
filter: drop-shadow(5px 5px 1px rgba(0, 0, 0, 0.25));
}
<button>Learn More</button>
Based on chazsolo's answer. It's possible to get shadow on button without shadow on text using absolutely positioned pseudoelement and CSS property inheritance:
body {
background: #76d7c4;
}
button {
text-transform: uppercase;
padding: 10px 20px;
color: white;
cursor: pointer;
background: transparent; /* no background! */
border: 1px solid white;
border-radius: 100px;
position: relative; /* new */
}
button:after {
content: "";
position: absolute;
/* Making pseudoelement the same size as container */
left: 0;
right: 0;
top: 0;
bottom: 0;
/* Inheriting border properties */
border-radius: inherit;
border: inherit;
/* Applying filter with shadow */
filter: drop-shadow(5px 5px 1px rgba(0, 0, 0, 0.25));
}
<button>Learn More</button>
You can also do it by combining box-shadow: ... and box-shadow: inset .... Just adjust the box-shadow so it fits your needs.
Example
body {
background: #32DBD7;
}
button {
background: transparent;
color: #fff;
border: 3px solid #fff;
border-radius: 35px;
padding: 10px 40px;
font-size: 34px;
box-shadow: 3px 3px 4px rgba(0, 0, 0, .25), inset 3px 3px 4px rgba(0, 0, 0, .25);
-moz-box-shadow: 3px 3px 4px rgba(0, 0, 0, .25), inset 3px 3px 4px rgba(0, 0, 0, .25);
-webkit-box-shadow: 3px 3px 4px rgba(0, 0, 0, .25), inset 3px 3px 4px rgba(0, 0, 0, .25);
}
<button>Learn More</button>
.test { margin-top: 2em; }
a {
padding: 10px 40px;
border-radius: 30px;
font-size: 18px;
color: #fff;
border: 1px solid #fff;
box-shadow: 5px 5px 0 darkgray;
text-decoration: none;
}
body {
background-color: #2CBFBB;
}
<div class="test">
Learn More
</div>
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;
}
inner radius of input box
<input type="text" class="input-text">
css
.input-text{
border-width: 4px;
border-color: #F85534;
padding: 6px 14px;
width: 540px;
font-size: 16px;
margin: 0px !important;
height: 35px;
-webkit-appearance: none;
z-index: 5;
position: relative;
border-radius:0px;
box-shadow: inset -1px 1px 2px
rgba(43, 40, 40, 0.2),-1px 1px 0px
rgba(43, 40, 40, 0.2),-2px 2px 0px
rgba(43, 40, 40, 0.2);
-webkit-box-shadow: inset -1px 1px 2px rgba(43, 40, 40, 0.2),-1px 1px 0px rgba(43, 40,40,0.2),-2px 2px 0px rgba(43, 40, 40, 0.2);
}
I need inner radius for text box, outer radius should be zero.
EDIT
Image
I'm not sure if you can do it without wrapping the input in a div, this is how i would do it:
HTML:
<div class="input-wrapper"><input type="text" placeholder="text"></div>
CSS:
.input-wrapper {
background: blue;
padding: 3px;
display: inline-block;
}
.input-wrapper input {
border-radius: 5px;
border: none;
font-size: 14px;
padding: 3px;
}
Check a JS-fiddle here: http://jsfiddle.net/qCyKW/