Linear-gradient not working in Edge and IE11 - html

My CSS isn't showing the background image in Microsoft Edge and IE11.
It seems to have something to do with linear-gradients in those browsers. The background color shows up, but not the image in Edge and IE11. Any suggestions?
#DIV_1 {
background-blend-mode: overlay, overlay;
background-position: 50% 50%, 50% 50%;
bottom: 0px;
box-sizing: border-box;
color: rgb(255, 255, 255);
height: 400px;
left: 356.25px;
position: absolute;
right: -356.25px;
text-decoration: none solid rgb(255, 255, 255);
text-size-adjust: 100%;
top: 0px;
width: 356.25px;
column-rule-color: rgb(255, 255, 255);
perspective-origin: 178.125px 200px;
transform-origin: 178.125px 200px;
caret-color: rgb(255, 255, 255);
background: linear-gradient(rgb(0, 174, 217) 0%, rgb(23, 36, 169) 100%) no-repeat scroll 50% 50% / cover padding-box border-box, rgba(0, 0, 0, 0) url("http://www.purpleelephantpolitics.com/wp-content/uploads/2017/03/New-Pics-Of-Ducks-26-For-Line-Drawings-with-Pics-Of-Ducks.jpg") no-repeat scroll 50% 50% / cover padding- box border-box;
border: 0px none rgb(255, 255, 255);
font: normal normal normal normal 16px / 22.8571px "Proxima Nova";
outline: rgb(255, 255, 255) none 0px;
}/*#DIV_1*/
https://jsfiddle.net/t6j11zm4/

background-blend-mode is not supported on Edge and IE.
You can create something similar with pseudo-element overlays
Hover the image to see the effect:
body {
background: #131418;
text-align: center;
margin: 1em auto;
}
.my-image-parent {
display: inline-block;
width: 300px;
height: 300px;
text-align: center;
}
.my-image {
width: auto;
height: 100%;
background: url(https://unsplash.it/400/400);
background-size: contain;
background-position: center;
background-repeat: no-repeat;
}
.my-image {
position: relative;
}
.my-image:after {
content: '';
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background: radial-gradient(circle at 30% 107%, rgba(253, 244, 151, 0.5) 0%, rgba(253, 244, 151, 0.5) 5%, rgba(253, 89, 73, 0.6) 45%, rgba(214, 36, 159, 0.6) 60%, rgba(40, 90, 235, 0.6) 90%);
opacity: 0;
transition: all ease 1s;
}
.my-image:hover:after {
opacity: .5;
}
<div class="my-image-parent">
<div class="my-image"></div>
</div>

Related

Clipped Button in css not as Expected

Expected
.clipped-button {
height: 42px;
min-width:120px;
width: auto;
display: block;
border:none;
border-radius:2px;
align-items:center;
clip-path: polygon(0px 0%, 0px 60%, 18px 100%, 100% 100%, 100% 40%, calc(100% - 18px) 0px);
padding: 2.625px;
background-color: #993029;
}
.btn {
width: 100%;
height: 100%;
background-color: rgb(205, 65, 58);
display:flex;
justify-content:center;
align-items:center;
clip-path: polygon(0px 0%, 0px 60%, 16px 100%, 100% 100%, 100% 40%, calc(100% - 16px) 0px);
color: rgb(255, 255, 255);
}
<button class="clipped-button"><div class="btn">Click Me</div>
</button>
Not getting the clipped corners rounded
Please help to round the clipped corners at top right and bottom left if possible
Rather than a clip-path perhaps something similar to the following is an option.
.button {
display: inline-block;
width: 200px;
height: 50px;
padding: 10px 20px;
font-size: 1.2em;
cursor: pointer;
text-align: center;
text-decoration: none;
justify-content: center;
align-items: center;
outline: none;
color: #fff;
border-radius: 25px;
border: 5px solid rgb(190, 40, 40);
background-color: rgba(200, 60, 60, 0.6);
background-image: linear-gradient(to bottom right, rgba(255,0,0,0), rgba(200, 60, 60, 0.8));
}
.button:hover {
box-shadow: 0 10px 10px 0 rgba(0,0,0,0.2);
/*--background-color: rgba(200, 60, 60, 1.0); --alt color--*/
background-image: linear-gradient(to bottom right, rgba(255,0,0,0), rgba(250, 100, 100, 1.0));
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '\1F846 \1F846';
position: absolute;
opacity: 0;
top: -2px;
right: -40px;
transition: 0.5s;
}
.button:hover span {
padding-right: 40px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
<button class="button"><span> Click Me </span></button>

CSS - gradient border not working in safari

I am trying to create a custom button with a gradient border. At this point I got the button to work in both Chrome and Firefox.
I have followed an online guide on how to create custom borders with a gradient which are also rounded. The link to the guide can be found here: documentation.
But for some reason the same styling does not work in Safari. I do not know why this is the case.
Here is the CSS code I use in order to create the button. I have also included a snippet with the same style at the bottom. Note that the snippet has a few extra classes and CSS properties just to get it to show properly.
.rainbow-gradient-border {
position: relative;
border-radius: 0.25rem;
box-shadow: 0 2px 10px 0 rgba(142, 57, 255, 0.29);
}
.rainbow-gradient-border::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-radius: 0.25rem;
padding: 0.1rem;
background: linear-gradient(
90deg,
#4d3d8f 0%,
#df67ed 23%,
#e24c26 65%,
#f18823 84%,
#3aa6c2 100%
);
-webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
-webkit-mask-composite: destination-out;
mask-composite: exclude;
}
body, .container{
width: 100%;
height: 100%;
background-color: black;
}
.container{
background-color: black;
}
.rainbow-gradient-border {
position: relative;
color: white;
width: 10rem;
display: flex;
justify-content: center;
align-items: center;
border-radius: 0.25rem;
box-shadow: 0 2px 10px 0 rgba(142, 57, 255, 0.29);
}
.rainbow-gradient-border::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-radius: 0.25rem;
padding: 0.1rem;
background: linear-gradient(
90deg,
#4d3d8f 0%,
#df67ed 23%,
#e24c26 65%,
#f18823 84%,
#3aa6c2 100%
);
-webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
-webkit-mask-composite: destination-out;
mask-composite: exclude;
}
<div class="container">
<div class="rainbow-gradient-border">
<p>Log In</p>
</div>
</div>
try using -webkit-mask-composite: source-out;
instead of destination-out.
This worked for me and they have the same description on https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-mask-composite
You can achieve this in a more simple way, without using masks. I used this tool to add the prefixes.
body, .container{
width: 100%;
height: 100%;
background-color: black;
color: white;
}
.rainbow-gradient-border {
position: relative;
}
.outie{
display: inline-block;
background: -webkit-gradient(
linear,
left top, right top,
from(#4d3d8f),
color-stop(23%, #df67ed),
color-stop(65%, #e24c26),
color-stop(84%, #f18823),
to(#3aa6c2)
);
background: -o-linear-gradient(
left,
#4d3d8f 0%,
#df67ed 23%,
#e24c26 65%,
#f18823 84%,
#3aa6c2 100%
);
background: linear-gradient(
90deg,
#4d3d8f 0%,
#df67ed 23%,
#e24c26 65%,
#f18823 84%,
#3aa6c2 100%
);
border-radius: 4px;
padding: 2px;
width: 10rem;
border-radius: 0.25rem;
-webkit-box-shadow: 0 2px 10px 0 rgba(142, 57, 255, 0.29);
box-shadow: 0 2px 10px 0 rgba(142, 57, 255, 0.29);
}
.innie{
display:inline-block;
width: 100%;
background: black;
padding: 15px 0px;
text-align: center;
}
<div class="container">
<div class="rainbow-gradient-border">
<span class="outie">
<span class="innie">
Log In
</span>
</span>
</div>
</div>

Use CSS to overlay image on gradient with padding

I'm attempting to create a button that contains a gradient covering the whole button, then with an image on just a portion of the button.
(note: for ease of the question I've changed my code to a div, but the outcome remains the same)
Initially this was successful doing such:
<div class="myBtn_1">test button one</div>
.myBtn_1
{
border: solid 1px #ff00ff;
background-image: url('https://picsum.photos/21?image=1080'),
linear-gradient(to right, rgba(141, 245, 146, 1), rgba(255, 255, 255, 1));
background-repeat: no-repeat;
background-size: auto 100%;
width: 200px;
height: 50px;
padding-left: 65px;
}
the jfiddle representing this can be found: here
HOWEVER I want some border around my image within the button/div, so I added background-position 5px 5px to the css, as well as explicitly setting the background-size (auto 40px). This does add padding to the image, but it also adds padding to the gradient.
again, see the 2nd class in the same jfiddle
Question: how can I create a button/div in css that has a gradient covering the full background, then add an image that has padding around it?
You can comma delineate the individual background properties too.
.myBtn_3
{
border: solid 1px #ff00ff;
background-image: url('https://picsum.photos/21?image=1080'), linear-gradient(to right, rgba(141, 245, 146, 1), rgba(255, 255, 255, 1));
background-repeat: no-repeat;
background-size: auto 40px, auto auto;
width: 200px;
height: 50px;
padding-left: 65px;
background-position: 5px 5px, 0 0;
}
<div class="myBtn_3">
test button two
</div>
Why don't you use
position: absolute;
on the image and just put it inside the div
.myBtn_1
{
border: solid 1px #ff00ff;
background-image: url('https://picsum.photos/21?image=1080'),
linear-gradient(to right, rgba(141, 245, 146, 1), rgba(255, 255, 255, 1));
background-repeat: no-repeat;
background-size: auto 100%;
width: 200px;
height: 50px;
padding-left: 65px;
}
.myBtn_2
{
border: solid 1px #ff00ff;
background-image: url('https://picsum.photos/21?image=1080'), linear-gradient(to right, rgba(141, 245, 146, 1), rgba(255, 255, 255, 1));
background-repeat: no-repeat;
background-size: auto 40px;
width: 200px;
height: 50px;
padding-left: 65px;
background-position: 5px 5px;
}
.myBtn_3
{
border: solid 1px #ff00ff;
background-image: linear-gradient(to right, rgba(141, 245, 146, 1), rgba(255, 255, 255, 1));
background-repeat: no-repeat;
background-size: auto 100%;
width: 200px;
height: 50px;
padding-left: 65px;
position: relative;
}
.myBtn_3 img {
position: absolute;
left: 5px;
top: 5px;
height: calc(100% - 10px)
}
<div class="myBtn_1">test button one</div>
<br />
<div class="myBtn_2">
test button two
</div>
<br />
<div class="myBtn_3">
test button three
<img src="https://picsum.photos/21?image=1080">
</div>

is there a way to bring text over a "before" pseudo element?

I'm relatively new to html and css in general, but am trying to get the header and paragraph text above the gradient background, so it's more legible. I'm sure there is something simple i'm missing, and any help is appreciated :)
Codepen: https://codepen.io/minacosentino/pen/YxLLQw
.jumbotron {
display: flex;
align-items: center;
background: url('https://static1.squarespace.com/static/56fc981de707eb954cdcfca3/t/572a8a8d37013b0bab651c88/1462405784417/business+working+unsplash.com.jpg?format=1500w');
height: 40rem;
background-size: cover;
background-repeat: no-repeat;
background-position: center bottom;
position: relative;
}
.jumbotron::before {
background: rgba(0, 0, 0, 0) -webkit-linear-gradient(to top right, rgba(203,67,152,.7) 0%, rgba(100,190,235,.7) 100%) repeat scroll 0 0;
background: rgba(0, 0, 0, 0) -moz-linear-gradient(to top right, rgba(203,67,152,.7) 0%, rgba(100,190,235,.7) 100%) repeat scroll 0 0;
background: rgba(0, 0, 0, 0) -o-linear-gradient(to top right, rgba(203,67,152,.7) 0%, rgba(100,190,235,.7) 100%) repeat scroll 0 0;
background: rgba(0, 0, 0, 0) linear-gradient(to top right, rgba(203,67,152,.7) 0%, rgba(100,190,235,.7) 100%) repeat scroll 0 0;
content: "";
display: block;
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
}
.jumbotron h2 {
font-family: 'Montserrat', sans-serif;
color: #ffffff;
font-size: 8rem;
font-weight: 500;
text-align: center;
}
.jumbotron p {
font-family: 'Montserrat', sans-serif;
color: #ffffff;
font-size: 8rem;
font-weight: 200;
text-align: center;
}
You just need to give your .container element a non-static positioning, and it will naturally come to the front.
Right now, your .jumbotron::before is set to position: absolute, and because the .container (its sibling) has no non-static positioning defined, it's showing up behind it.
I've added this to the end of your CSS:
.container {
position: relative;
}
Working demo:
.jumbotron {
display: flex;
align-items: center;
background: url('https://static1.squarespace.com/static/56fc981de707eb954cdcfca3/t/572a8a8d37013b0bab651c88/1462405784417/business+working+unsplash.com.jpg?format=1500w');
height: 40rem;
background-size: cover;
background-repeat: no-repeat;
background-position: center bottom;
position: relative;
}
.container {}
.jumbotron::before {
background: rgba(0, 0, 0, 0) -webkit-linear-gradient(to top right, rgba(203, 67, 152, .7) 0%, rgba(100, 190, 235, .7) 100%) repeat scroll 0 0;
background: rgba(0, 0, 0, 0) -moz-linear-gradient(to top right, rgba(203, 67, 152, .7) 0%, rgba(100, 190, 235, .7) 100%) repeat scroll 0 0;
background: rgba(0, 0, 0, 0) -o-linear-gradient(to top right, rgba(203, 67, 152, .7) 0%, rgba(100, 190, 235, .7) 100%) repeat scroll 0 0;
background: rgba(0, 0, 0, 0) linear-gradient(to top right, rgba(203, 67, 152, .7) 0%, rgba(100, 190, 235, .7) 100%) repeat scroll 0 0;
content: "";
display: block;
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
}
.jumbotron h2 {
font-family: 'Montserrat', sans-serif;
color: #ffffff;
font-size: 8rem;
font-weight: 500;
text-align: center;
}
.jumbotron p {
font-family: 'Montserrat', sans-serif;
color: #ffffff;
font-size: 8rem;
font-weight: 200;
text-align: center;
}
.container {
position: relative;
}
<link href="https://fonts.googleapis.com/css?family=Montserrat:200,500" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<section class="jumbotron">
<div class="container">
<h2>hello!</h2>
<p>welcome to inside sales</p>
</div>
</section>
you can give z-index value to before pesudo element
.jumbotron::before {
background: rgba(0, 0, 0, 0) -webkit-linear-gradient(to top right,
rgba(203,67,152,.7) 0%, rgba(100,190,235,.7) 100%) repeat scroll 0 0;
background: rgba(0, 0, 0, 0) -moz-linear-gradient(to top right,
rgba(203,67,152,.7) 0%, rgba(100,190,235,.7) 100%) repeat scroll 0 0;
background: rgba(0, 0, 0, 0) -o-linear-gradient(to top right,
rgba(203,67,152,.7) 0%, rgba(100,190,235,.7) 100%) repeat scroll 0 0;
background: rgba(0, 0, 0, 0) linear-gradient(to top right,
rgba(203,67,152,.7) 0%, rgba(100,190,235,.7) 100%) repeat scroll 0 0;
content: "";
display: block;
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
z-index:-1;
}
I used transform: translate3d(0px, 0px, 0px);
I have an structure like this:
.blog-header {
position: relative;
...
&::before {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
background: url("../static/shape.svg");
background-size: cover;
opacity: 0.6;
}
&__breadcrumb {
transform: translate3d(0px, 0px, 0px);
...
}
}
Or
.blog-header {
position: relative;
...
}
.blog-header::before {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
background: url("../static/shape.svg");
background-size: cover;
opacity: 0.6;
}
.blog-header__breadcrumb {
...
transform: translate3d(0px, 0px, 0px);
}
Use can use z-index property in css to change the layer an element is displayed on.
z-index
.jumbotron container {
z-index: 2000;
}

CSS border image is wider than the div

I am adding an image border in bottom of my div like this :
HTML:
<div class="view">
<div class="shadow_overlay"></div>
</div>
CSS:
.view {
text-align: center;
overflow: hidden;
position: relative;
text-align: center;
cursor: default;
width: 160px;
height: 190px;
border-image: linear-gradient(to right, rgb(139, 191, 64) 25%, rgb(230, 27, 33) 25%, rgb(230, 27, 33) 50%, rgb(124, 196, 236) 50%, rgb(124, 196, 236) 75%, rgb(254, 181, 17) 75%);
border-image-slice: 1;
border-image-width: 4px 0px 0px 0px;
}
.shadow_overlay {
background: url('http://i.imgur.com/MrVzqyp.png') 0 0 no-repeat;
background-size: cover;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin-left:auto;
margin-right:auto;
width:160px;
height:190px;
}
This worked but in action border-image is wider than my div.
Problem pic:
How do I fix this problem?
DEMO here
It seems like browsers assign a default width to borders when border-image is used (but the borders on the other sides are invisible because the border-image-width is 0px). To avoid the borders from looking like they are overflowing the div, manually set the border widths on all other sides to 0px.
border-width: 4px 0px 0px 0px;
The behavior is seen in Chrome (upto v48.0.2535.0 dev-m), IE (Edge), Opera and Safari. The border image doesn't extend beyond the div in latest Firefox (v41.0.1) IE (v11),
.view {
text-align: center;
overflow: hidden;
position: relative;
text-align: center;
cursor: default;
width: 160px;
height: 190px;
border-image: linear-gradient(to right, rgb(139, 191, 64) 25%, rgb(230, 27, 33) 25%, rgb(230, 27, 33) 50%, rgb(124, 196, 236) 50%, rgb(124, 196, 236) 75%, rgb(254, 181, 17) 75%);
border-image-slice: 1;
border-image-width: 4px 0px 0px 0px;
border-width: 4px 0px 0px 0px;
}
.shadow_overlay {
background: url('http://i.imgur.com/MrVzqyp.png') 0 0 no-repeat;
background-size: cover;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin-left: auto;
margin-right: auto;
width: 160px;
height: 190px;
}
<div class="view">
<div class="shadow_overlay"></div>
</div>
In the below snippet you can see how it looks as though all other sides have a 3px border. There is no clear explanation either in the Web or in the specs about whose behavior is correct (Chrome, Edge or FF, IE11).
.view {
text-align: center;
overflow: hidden;
position: relative;
text-align: center;
cursor: default;
width: 160px;
height: 190px;
border-image: linear-gradient(to right, rgb(139, 191, 64) 25%, rgb(230, 27, 33) 25%, rgb(230, 27, 33) 50%, rgb(124, 196, 236) 50%, rgb(124, 196, 236) 75%, rgb(254, 181, 17) 75%);
border-image-slice: 1;
border-image-width: 4px 0px 0px 0px;
}
.view#two{
border-width: 4px 3px 3px 3px;
}
.shadow_overlay {
background: url('http://i.imgur.com/MrVzqyp.png') 0 0 no-repeat;
background-size: cover;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin-left: auto;
margin-right: auto;
width: 160px;
height: 190px;
}
<div class="view">
<div class="shadow_overlay"></div>
</div>
<div class="view" id="two">
<div class="shadow_overlay"></div>
</div>
The W3C Specs also say the following about border-image properties but in FF and IE11 the border-image is not shown when only border-width is provided and border-image-width is avoided.
The border-image properties do not affect layout: layout of the box, its content, and surrounding content is based on the ‘border-width’ and ‘border-style’ properties only.
So, it seems like the behavior of border-image is still not standardized. I am leaning towards what is observed in Chrome, Edge because Microsoft, for some reason, seems to have changed the behavior from IE11 and so there must be a good reason for it.