Firefox border-radius white edges - html

There is annoying thing in Firefox that it can't handle clipping (antialiasing?) of rounded corner elements, especially if there are multiple backgrounds. In some scenarios (non-absolute elements I guess) it can be solved by setting background-clip: content-box inside a class but in other cases it can't be solver that way even with any other properties. Although, Chrome does not creating this problems (or have better working with clipping under the hood). Here some examples based on my scenarios that I managed to recreate with snippets and screenshot of results in different browsers.
Please don't offer me to get rid of multiple backgrounds and blend modes because I need it due to css doesn't support gradient transitions.
body {
margin: 0;
}
.wrapper {
position: relative;
padding: 20px;
background-color: #2B3351;
}
.child {
display: inline-block;
position: relative;
padding: 24px 48px;
text-align: center;
font-family: "Raleway", sans-serif;
font-weight: 900;
font-size: 18px;
text-transform: uppercase;
align-items: center;
color: rgba(255, 255, 255, 0.6);
border-radius: 34px;
background-color: #181B34;
background-image: linear-gradient(160deg, #e6e7f9 11.77%, #ebebfb 74.75%);
background-blend-mode: multiply;
box-shadow: -10px -10px 15px rgba(165, 206, 255, 0.1), 10px 10px 20px rgba(0, 0, 0, 0.35), inset 0 0 0 rgba(165, 206, 255,0), inset 0 0 0 rgba(0,0,0,0);
margin: 24px 0;
background-clip: content-box;
}
.absolute {
position: absolute;
background-color: #030b33bf;
background-image: linear-gradient(160deg, #e7ecfd, #FfffFF);
background-blend-mode: multiply;
width: 24px;
height: 24px;
border-radius: 50%;
transform: translate(150px, -60px);
box-shadow: -3px -3px 5px rgba(0, 6, 39, 0), 4px 4px 8px rgba(0, 6, 39, .35);
background-clip: border-box;
}
<div class="wrapper">
<div class ="child"></div>
<div class="absolute"></div>
</div>

Related

Unable to convert button design in Figma to CSS code

I designed this button in Figma but when I copy the CSS properties from the inspect section from Figma I won't get the same output, what I'm doing wrong here?
Figma file: https://www.figma.com/file/r3z3qwUsYGsn9SVDefWVoM/problem?node-id=2%3A6
div {
display: flex;
justify-content: center;
align-items: left;
height: 100%;
text-align: center;
}
button {
width: 300px;
height: 64px;
border: none;
line-height: 23px;
text-align: center;
letter-spacing: 0.666667px;
color: #000000;
font-weight: 400;
font-size: 16px;
background: linear-gradient(135.37deg, rgba(0, 0, 0, 0.35) 4.29%, rgba(255, 255, 255, 0.35) 95.6%);
background-blend-mode: soft-light;
box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.15), -5px -5px 10px #FAFBFF, 5px 5px 10px rgba(190, 106, 255, 0.3);
border-radius: 20px;
}
<div>
<button>Wednesday</button>
</div>
I want the button to be like that
and this is what i'm getting right now
Unfortunately, button shadows won't show through the button's body, even if the body is transparent. You will have to find another way to render a very rich button like that.
See my proof of concept below.
You can also find a detailed explanation at https://stackoverflow.com/a/9573440/46915
body {
background: #777;
}
div {
display: flex;
justify-content: center;
align-items: left;
height: 100%;
text-align: center;
}
button {
position: absolute;
width: 300px;
height: 64px;
background-color: transparent;
background-repeat: no-repeat;
border: none !important;
/*background: linear-gradient(135.37deg, rgba(0, 0, 0, 0.35) 4.29%, rgba(255, 255, 255, 0.35) 95.6%);*/
background-blend-mode: soft-light;
box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.15), -5px -5px 10px #FAFBFF, 5px 5px 10px rgba(190, 106, 255, 0.3);
border-radius: 20px;
}
<div>
<button>Wednesday</button>
</div>

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;
}

Vertical Linear Gradient

I am trying to get a vertical effect for a sidebar on a page. I have tried the deg option but it still shows a horizontal line
.sidebar {
position: relative;
display: inline-block;
padding: 15px 25px;
background-image: linear-gradient(90deg, #1559EC, #1559EC);
color: #fff;
font-size: 36px;
font-family: Arial;
border-radius: 3px;
box-shadow: 0px 1px 4px -2px #333;
text-shadow: 0px -1px #333;
}
.sidebar:after {
content: '';
position: absolute;
top: 2px;
left: 2px;
width: calc(100% - 4px);
height: 50%;
background: linear-gradient(rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.2));
}
<div class="sidebar">
The quick brown fox
</div>
The issue is not the gradient but the pseudo element. The gradient is using the same color so the angle is useless. What you need is to invert height/width values on the pseudo element and adjust the direction of its gradient. You can also replace the gradient of the main element by simple color:
.sidebar {
position: relative;
display: inline-block;
padding: 15px 25px;
background:#1559EC;
color: #fff;
font-size: 36px;
font-family: Arial;
border-radius: 3px;
box-shadow: 0px 1px 4px -2px #333;
text-shadow: 0px -1px #333;
}
.sidebar:after {
content: '';
position: absolute;
top: 2px;
left: 2px;
width: 50%;
height: calc(100% - 4px);
background: linear-gradient(to right,rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.2));
}
<div class="sidebar">
The quick brown fox
</div>
And you can simplify it like below using multiple background on the main element:
.sidebar {
position: relative;
display: inline-block;
padding: 15px 25px;
background:
linear-gradient(to right,rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.2)) 2px 2px/50% calc(100% - 4px)no-repeat,
#1559EC;
color: #fff;
font-size: 36px;
font-family: Arial;
border-radius: 3px;
box-shadow: 0px 1px 4px -2px #333;
text-shadow: 0px -1px #333;
}
<div class="sidebar">
The quick brown fox
</div>
The gradient you're trying to change has both colors the same so you won't see the difference. The easiest way to make what you want IS using a generator since the code for each render engine is a bit different.
The easiest keyword solution is to use "to direction" instead of a degree. See below. The first box is top to bottom and the second is left to right.
Your example has a pseudo-class (:after) adding a second gradient to create the hard line. You could achieve a similar effect by adding more stops to the gradient.
.box{
width: 100px;
height: 100px;
margin-bottom: 20px
}
.gradient1 {
background: linear-gradient(to bottom, #8fc400, #29b8e5);
}
.gradient2 {
background: linear-gradient(to right, #8fc400, #29b8e5);
}
.gradient3 {
background: linear-gradient(to bottom, rgba(191,210,85,1) 0%,rgba(142,185,42,1) 50%,rgba(114,170,0,1) 51%,rgba(158,203,45,1) 100%);
}
<div class="box gradient1">
</div>
<div class="box gradient2">
</div>
<div class="box gradient3">
</div>

CSS: create material design shadow issue

I need to create this button with CSS only and have an issue with box shadow. There are two different shadows on this button: one yellow, one black. The maximum what I get is this
.button {
height: 81px;
width: 250px;
text-align: center;
font-family: 'Celias_Medium', 'Open Sans:500', sans-serif;
font-size: 11px;
line-height: 3.3;
letter-spacing: 0.4px;
cursor: pointer;
outline: none;
display: block;
vertical-align: top;
padding: 23px 0 26px 0;
text-transform: uppercase;
color: #000000;
background-color: #fbfb5c;
box-shadow: 0 20px 90px -30px rgba(251, 251, 92, 0.9), 0 40px 90px -50px rgba(0, 0, 0, 0.5)
}
<div class="button">ADD 7 Activities</div>
Here is result. Is there any other solution to get this result?
try on this if u cant see it on chrome moz or safari
.button {
height: 81px;
width: 250px;
text-align: center;
font-family: 'Celias_Medium', 'Open Sans:500', sans-serif;
font-size: 11px;
line-height: 3.3;
letter-spacing: 0.4px;
cursor: pointer;
outline: none;
display: block;
vertical-align: top;
padding: 23px 0 26px 0;
text-transform: uppercase;
color: #000000;
background-color: #fbfb5c;
box-shadow: 0 20px 90px -30px rgba(251, 251, 92, 0.9), 0 40px 90px -50px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 0 20px 90px -30px rgba(251, 251, 92, 0.9), 0 40px 90px -50px rgba(0, 0, 0, 0.5);
-webkit-box-shadow: 0 20px 90px -30px rgba(251, 251, 92, 0.9), 0 40px 90px -50px rgba(0, 0, 0, 0.5);
}
hope this one works :)
Is that what you want?
.button {
height: 81px;
width: 250px;
text-align: center;
font-family: 'Celias_Medium', 'Open Sans:500', sans-serif;
font-size: 11px;
line-height: 3.3;
letter-spacing: 0.4px;
cursor: pointer;
outline: none;
display: block;
vertical-align: top;
padding: 23px 0 26px 0;
box-sizing: border-box;
text-transform: uppercase;
color: #000000;
background-color: #fbfb5c;
box-shadow: 1px 1px 70px -24px;
}
<div class="button">
ADD y activities
</div>
Generally speaking material buttons would look something like this, but I don't really know what you're asking.
.button {
height: 81px;
width: 250px;
text-align: center;
font-family: Celias_Medium, 'Open Sans:500', sans-serif;
font-size: 11px;
line-height: 3.3;
letter-spacing: .4px;
cursor: pointer;
vertical-align: top;
padding: 23px 0 26px;
box-sizing: border-box;
text-transform: uppercase;
background-color: #fbfb5c;
border-radius: 4px;
margin: 16px 0;
box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 1px 2px rgba(0, 0, 0, .24);
transition: all .3s cubic-bezier(.25, .8, .25, 1)
}
.button:hover {
box-shadow: 0 14px 28px rgba(0, 0, 0, .25), 0 10px 10px rgba(0, 0, 0, .22)
}
<div class="button">
Button no. 1
</div>
<div class="button">
Button no. 2
</div>
<div class="button">
Button no. 3
</div>
<div class="button">
Button no. 4
</div>
<div class="button">
Button no. 5
</div>

how to set image into div

I am trying to fit a image into div but something going wrong, actualy i just want when i set a image into div it should not affect the div property.
i am trying like this:
#image_try {
background-color: white;
-webkit-box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.4);
-moz-box-shadow: 0px 1px 6px rgba(23, 69, 88, .5);
-webkit-border-radius: 12px;
-moz-border-radius: 7px;
border-radius: 7px;
background: -webkit-gradient(linear, left top, left bottom,
color-stop(0%, white), color-stop(15%, white), color-stop(100%, #D7E9F5));
background: -moz-linear-gradient(top, white 0%, white 55%, #D5E4F3 130%);
float: right;
border: 2px;
color: #FF0000;
overflow: hidden;
width: 164px;
display: table;
margin: 0 auto;
padding: 78px 31px 7px 233px;
background: #FFFFFF;
height: 79px;
margin-top: -174px;
margin-right: 25px;
background-image:url(images/weather.jpg) no-repeat;
}
updates:
Actualy when i did not set image in background then div looks like good but when i am setting image its height and width being affected
any idea... answer will be fully appreciate...thank you
I can see few dupe in your css like for background, you using color twice also you are setting it to gradient for Chrome and Firefox. You are repeating margin too. As far as i can under stand your problem was with padding. I removed that only. Kindly check the css and provide screenshot if possible.
#image_try {
-webkit-box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.4);
-moz-box-shadow: 0px 1px 6px rgba(23, 69, 88, .5);
-webkit-border-radius: 12px;
-moz-border-radius: 7px;
border-radius: 7px;
border: 2px;
color: #FF0000;
width: 164px;
height: 79px;
background-image:url(images/weather.jpg) no-repeat;
}
Try above edited answer