SVG gradient using CSS

Just use in the CSS whatever you would use in a fill attribute. Of course, this requires that you have defined the linear gradient somewhere in your SVG. Here is a complete example: rect { cursor: pointer; shape-rendering: crispEdges; fill: url(#MyGradient); } <svg width=”100″ height=”50″ version=”1.1″ xmlns=”http://www.w3.org/2000/svg”> <style type=”text/css”> rect{fill:url(#MyGradient)} </style> <defs> <linearGradient id=”MyGradient”> <stop … Read more

Why does the linear-gradient disappear when I make an element position:absolute?

Add some height to the body to see the background: * { margin: 0px; padding: 0px; } body { background: linear-gradient(20deg, #B7B0F6, #B1D5F9); min-height: 100vh; } header { position: absolute; top: 50%; left: 50%; margin-right: -50%; transform: translate(-50%, -50%); } <header> <h1>Hello!</h1> </header> Your body contain no in-flow element so its height is equal to … Read more

Animating Linear Gradient using CSS

Please try this code: #gradient { height:300px; width:300px; border:1px solid black; font-size:30px; background: linear-gradient(130deg, #ff7e00, #ffffff, #5cff00); background-size: 200% 200%; -webkit-animation: Animation 5s ease infinite; -moz-animation: Animation 5s ease infinite; animation: Animation 5s ease infinite; } @-webkit-keyframes Animation { 0%{background-position:10% 0%} 50%{background-position:91% 100%} 100%{background-position:10% 0%} } @-moz-keyframes Animation { 0%{background-position:10% 0%} 50%{background-position:91% 100%} 100%{background-position:10% 0%} … Read more

background image, linear gradient jagged edged result needs to be smooth edged

Unfortunately, this always happens when we use angled linear-gradient images and currently the only way to overcome this behavior seems to be to avoid hard-stopping of the colors (that is, don’t make the stop point of one color as the start point of the next). Making the second color start a little farther away from … Read more

Weird effect when applying transparent border over an element with a gradient background

That’s because the starting and ending points of the gradient are at the edges of the padding-box and border is rendered outside the padding-box. So, the borders look funny because the background is repeated on each side outside the padding-box to cover the border-box. The box-shadow:inset is rendered inside the padding-box (just like background) and … Read more

How to create a curve between two gradient using CSS?

Here is a solution using linearGradient with SVG. .container { width: 500px; height: 200px; background:linear-gradient(to bottom right, #de350b, #0065ff); } svg { width:100%; } <div class=”container”> <svg mlns=”http://www.w3.org/2000/svg” viewBox=”0 0 64 64″> <defs> <linearGradient id=”grad” x1=”0%” y1=”0%” x2=”100%” y2=”100%”> <stop offset=”0%” stop-color=”#ad3″ /> <stop offset=”100%” stop-color=”#add” /> </linearGradient> </defs> <path d=’M0 10 C30 28 38 … Read more

Gradient text color

I don’t exactly know how the stop stuff works. But I’ve got a gradient text example. Maybe this will help you out! _you can also add more colors to the gradient if you want or just select other colors from the color generator .rainbow2 { background-image: linear-gradient(to right, #E0F8F7, #585858, #fff); color: transparent; -webkit-background-clip: text; … Read more

CSS3 cross browser linear gradient

background-image: -ms-linear-gradient(right, #0c93C0, #FFF); background-image: -o-linear-gradient(right, #0c93C0, #FFF); All experimental CSS properties are getting a prefix: -webkit- for Webkit browsers (chrome, Safari) -moz- for FireFox -o- for Opera -ms- for Internet Explorer no prefix for an implementation which is in full accordance with the specification. Use top right instead of right, if you want a … Read more

Border Gradient with Border Radius

2021: I recommend using the CSS mask method since the support is pretty good now You cannot use border-radius with gradient. Here is another idea where you can rely on multiple background and adjust the background-clip: .white-grad { background: linear-gradient(#ccc 0 0) padding-box, /*this is your grey background*/ linear-gradient(to right, #9c20aa, #fb3570) border-box; color: #313149; … Read more