Creating complex gradients in css or sass - css

I am new to programming.
Is it possible to create a gradient like the background of this design using sass or css? I want to place some colors in random places.
Thank you in advance.

Yes you can by adding multiple gradient to you background property
W3scool doc
.container {
height: 100vh;
background:
radial-gradient(circle at 10% 20%, #FF000070 2%, transparent 40%),
radial-gradient(circle at 70% 40%, #BADA5570 4%, transparent 10%),
radial-gradient(ellipse at 50% 80%, #BADA5570 7%, transparent 30%);
}
<div class="container"></div>

Yes, a similar effect might be achieved.
You can stack gradients by separating them with commas. The "white" color must be transparent so you can see through the uppermost gradients.
Take a look at this gradient:
div {
background:
radial-gradient(circle at 10px 30px, rgb(2, 0, 36) 0%, rgb(7, 6, 97) 31%, rgba(9, 9, 121, 0) 46%, rgba(0, 212, 255, 0) 100%),
radial-gradient(circle at 600px 400px, rgb(200, 0, 36) 0%, rgb(200, 6, 97) 31%, rgba(9, 9, 121, 0) 46%, rgba(0, 212, 255, 0) 100%);
width: 400px;
height: 400px;
}
<div></div>

Glassmorphism is the name of the effect.
Check this site Glassmorphism
.container{
background: rgba( 255, 255, 255, 0.25 );
box-shadow: 0 8px 32px 0 rgba( 31, 38, 135, 0.37 );
backdrop-filter: blur( 10px );
-webkit-backdrop-filter: blur( 4.0px );
border-radius: 10px;
border: 1px solid rgba( 255, 255, 255, 0.18 );
width:100%;
height:100vh;
z-index:999;
}
.circle1{
position:absolute;
top:10px;
left:20px;
height:100px;
width:100px;
background:red;
opacity: 0.5;
border-radius:50%;
z-index:-1;
}
.circle2{
position:absolute;
bottom:10px;
right:20px;
height:250px;
width:250px;
opacity: 0.5;
background:blue;
border-radius:50%;
z-index:-1;
}
<div class="container"></div>
<div class="circle1"></div>
<div class="circle2"></div>

Related

Give multiple colors to a button using css

I Want to color a button just like this. Is there any way i can do this by using css?
Button should look like this
You can use a linear gradient.
JSFiddle
button {
height: 50px;
width: 100px;
background: linear-gradient(-60deg, red 50%, yellow 50%);
}
<button></button>
Using something like this
.x{
height: 50px;
background: #ff3232;
background: -moz-linear-gradient(-45deg, #ff3232 0%, #ff3030 50%, #282fff 51%, #005dff 100%);
background: -webkit-linear-gradient(-45deg, #ff3232 0%,#ff3030 50%,#282fff 51%,#005dff 100%);
background: linear-gradient(135deg, #ff3232 0%,#ff3030 50%,#282fff 51%,#005dff 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ff3232', endColorstr='#005dff',GradientType=1 );
}
<div class="x">
</div>
HTML:
<button id="main"></button>
CSS:
#main {
width: 200px;
height: 50px;
border: none;
background: linear-gradient(120deg, rgb(255, 0, 144), rgb(255, 0, 144) 55%, rgb(0, 222, 255), rgb(0, 222, 255) 45%);
}
Codepen

Gradient on the bottom of an image with css

Hello i want to have this kind of effect with an image (which is not a background image) :
Do u have any idea how i can create this effect with css ?
Look at this:
img {
width: 400px;
}
.content {
background: rgba(255, 255, 255, 0) linear-gradient(to bottom, rgba(0, 0, 0, 0) 10%, rgba(255, 255, 255, .1) 40%, rgba(255, 255, 255, .5) 75%, rgba(255, 255, 255, 1) 100%) repeat scroll 0 0;
position: relative;
margin-top: -200px;
height: 200px;
}
<img src="http://www.dl.21tech.ir/img-upload/2016/12/95092801.jpg" />
<div class="content"></div>
You can use a container with gradient, outside the img and set negative z-index of image to push it behind container.
<div class="gradient-bg">
<img src="http://img.phombo.com/img1/photocombo/1634288/hd-wallpapers-scenic-desktop-wallpaper-beautiful-fresh-nature-scenery-sunrise-1920x1080-wallpaper.jpg">
<span>Hello There</span>
</div>
.gradient-bg{
display: inline-block;
background: -moz-linear-gradient(bottom, rgba(0,0,0,0) 0%, rgba(249, 249, 249, 0.89) 100%);
background: -webkit-gradient(linear, left bottom, left bottom, color-stop(0%,rgba(0,0,0,0.65)), color-stop(100%,rgba(0,0,0,0)));
background: -webkit-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(249, 249, 249, 0.89) 100%);
background: -o-linear-gradient(bottom, rgba(0,0,0,0) 0%,rgba(249, 249, 249, 0.89) 100%);
background: -ms-linear-gradient(bottom, rgba(0,0,0,0) 0%,rgba(249, 249, 249, 0.89) 100%);
background: linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(249, 249, 249, 0.89) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a6000000', endColorstr='#00000000',GradientType=0 );
}
span{
position: absolute;
top: 183px;
}
img{
position:relative;
z-index:-1;
display:block;
height:200px; width:auto;
}
Use image height width and gradient accordingly.
This is sample code for the solution

How to add transparent notch to a DIV with CSS only? [duplicate]

I'm trying to add some css3 styles on an element, basing on an image model.
Inside transparent arrow on the left with blue border:
Link to image
It is possible only with css3 ?
with a single element you could do this i have to go to work hope this help
<div>Lorem Ipsum</div>
the style:
div{
width:200px;
height:60px;
margin:100px;
background-color:transparent;
color:black;
position:relative;
text-indent:30px;
line-height:60px;
box-shadow:inset 20px 0 0 200px white;
overflow:hidden;
-webkit-box-shadow: inset -164px 0 0 20px white;
-moz-box-shadow: inset -164px 0 0 20px white;
box-shadow: inset -164px 0 0 20px white;
}
div:before{
content: '';
position: absolute;
left: 0px;
top: 4px;
width: 14px;
border-bottom: 3px solid blue;
border-left: 3px solid blue;
height: 18px;
background-color:white;
-webkit-transform: skew(0deg,34deg);
-moz-transform: skew(0deg,34deg);
transform: skew(0deg,34deg);
}
div:after{
content: '';
position: absolute;
background-color:white;
left: 0px;
bottom: 4px;
width: 14px;
border-top: 3px solid blue;
border-left: 3px solid blue;
height: 18px;
-webkit-transform: skew(0deg,-34deg);
-moz-transform: skew(0deg,-34deg);
transform: skew(0deg,-34deg);
}
body{
background-color: #EEEEEE;
khtml-background-size: 10px 10px;
-webkit-background-size: 10px 10px;
-moz-background-size: 10px 10px;
-ms-background-size: 10px 10px;
-o-background-size: 10px 10px;
background-size: 10px 10px;
background-image: -khtml-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
background-image: -webkit-gradient(linear, left top, right bottom, color-stop(.25, rgba(255, 255, 255, .15)), color-stop(.25, transparent), color-stop(.5, transparent), color-stop(.5, rgba(255, 255, 255, .15)), color-stop(.75, rgba(255, 255, 255, .15)), color-stop(.75, transparent), to(transparent));
background-image: -webkit-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
background-image: -moz-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
background-image: -ms-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
background-image: -o-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
background-image: linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
width:100%;
height:100%;
}
The background is not solid which makes it very hard.
Especially since your arrow is not 90 degrees, which won't render that smooth I guess.
But have a look at this question:
CSS triangle custom border color
Using the technique of creating triangles with transparent borders of divs.
Two attempts that might help you a bit,
HTML
<div class="button">
<div class="wrapper">
<div class=" top-side "></div>
<div class="arrow-right "></div>
<div class="arrow-right2 "></div>
<div class="bottom-side "></div>
</div>
</div>
CSS
.button {
width: 400px;
background-color:orange;
}
.wrapper{
background-color:blue;
width:2px;
}
.arrow-right {
width: 0;
height: 0;
border-top: 5px solid transparent;
border-bottom: 5px solid transparent;
border-left: 15px solid white;
position:absolute;
z-index:2;
}
.arrow-right2 {
position:relative;
top:-1px;
z-index:1;
width: 0;
height: 0;
border-top: 6px solid transparent;
border-bottom: 6px solid transparent;
border-left: 18px solid blue;
}
.top-side {
height:7px;
width:2px;
background-color:blue;
}
.bottom-side {
height:7px;
width:2px;
background-color:blue;
}
http://jsfiddle.net/FkPYb/2/
also check
http://jsfiddle.net/FkPYb/1/
You might get better result by tweaking them.
Here is simplified variation of #kougiland's.
div {
width:200px;
height:60px;
position:relative;
text-indent:30px;
line-height:60px;
}
div:before{
content: '';
position: absolute;
top: 14px;
left: 0px;
width: 17px;
border-bottom: 1px solid blue;
border-left: 1px solid blue;
-webkit-transform: skew(0deg,60deg);
-moz-transform: skew(0deg,60deg);
transform: skew(0deg,60deg);
}
div:after{
content: '';
position: absolute;
left: 0px;
bottom: 14px;
width: 17px;
border-top: 1px solid blue;
border-left: 1px solid blue;
-webkit-transform: skew(0deg,-60deg);
-moz-transform: skew(0deg,-60deg);
transform: skew(0deg,-60deg);
}
http://jsfiddle.net/fxLeg262/

lighten background color on hover for different background colors

I have multiple elements, their background colors are different from each other. like:
<div class="element"> Content of the DIV</div>
<div class="element2"> Content of the DIV</div>
.element{
width:100px;
height:50px;
background-color:#888888;
}
.element2{
width:100px;
height:50px;
background-color:#222222;
}
I want to make hover like:
.element:hover, .element2:hover{}
When I bring mouse over the element, only background should be little bit lighter. I don't want to use opacity: 0.4 (lightens whole div) or background-color:rgba(50,50,50,0.5); (only for one color)
JSFIDDLE
The easiest way to achieve this is to simply apply a background-image to your elements on :hover. Either using a CSS gradient (which I generated using ColorZilla's "Ultimate CSS Gradient Generator"):
.element:hover,
.element2:hover,
.element3:hover {
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#ffffff+0,ffffff+100&0.5+0,0.5+100 */
background-image: -moz-linear-gradient(top, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.5) 100%);
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(255, 255, 255, 0.5)), color-stop(100%, rgba(255, 255, 255, 0.5)));
background-image: -webkit-linear-gradient(top, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.5) 100%);
background-image: -o-linear-gradient(top, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.5) 100%);
background-image: -ms-linear-gradient(top, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.5) 100%);
background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.5) 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#80ffffff', endColorstr='#80ffffff', GradientType=0);
}
.element {
width: 100px;
height: 50px;
background-color: #888888;
}
.element2 {
width: 100px;
height: 50px;
background-color: #222222;
}
.element3 {
width: 100px;
height: 50px;
background-color: #ff9900;
}
.element:hover,
.element2:hover,
.element3:hover {
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#ffffff+0,ffffff+100&0.5+0,0.5+100 */
background-image: -moz-linear-gradient(top, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.5) 100%);
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(255, 255, 255, 0.5)), color-stop(100%, rgba(255, 255, 255, 0.5)));
background-image: -webkit-linear-gradient(top, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.5) 100%);
background-image: -o-linear-gradient(top, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.5) 100%);
background-image: -ms-linear-gradient(top, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.5) 100%);
background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.5) 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#80ffffff', endColorstr='#80ffffff', GradientType=0);
}
<div class="element">Content of the DIV</div>
<div class="element2">Content of the DIV</div>
<div class="element3">Content of the DIV</div>
Or using a partially-transparent image:
.element:hover,
.element2:hover,
.element3:hover {
background-image: url(http://i.stack.imgur.com/5udh0.png);
}
.element {
width: 100px;
height: 50px;
background-color: #888888;
}
.element2 {
width: 100px;
height: 50px;
background-color: #222222;
}
.element3 {
width: 100px;
height: 50px;
background-color: #ff9900;
}
.element:hover,
.element2:hover,
.element3:hover {
background-image: url(http://i.stack.imgur.com/5udh0.png);
}
<div class="element">Content of the DIV</div>
<div class="element2">Content of the DIV</div>
<div class="element3">Content of the DIV</div>
This works because of the 'stacking' order of the background properties; the background-color sits at the back and the background-image sits 'above' that layer.
References:
"Using CSS Gradients," at MDN.
Here is a Fiddle and you should wrap your content into divs so you can apply rgba(255,255,255,0.5) to them:
.element{
width:100px;
height:50px;
background-color:#888888;
position:relative;
}
.element2{
width:100px;
height:50px;
background-color:#222222;
position:relative;
}
.element:hover > div, .element2:hover > div{
/* what can we put here? */
position:absolute;
top:0%;
left:0%;
width:100%;
height:100%;
background-color:rgba(255,255,255,0.5);
}
<div class="element"><div>Content of the DIV</div></div>
<div class="element2"><div>Content of the DIV</div></div>
this is a trick that uses the way stacking contents are rendered, backgrounds always below contents (even if it belongs to a higher stack):
fiddle
div {
width:100px;
height:50px;
z-index:2;
position:relative;
}
.element {
background-color:#888888;
}
.element2 {
background-color:red;
}
.element3 {
background-color:cyan;
}
div:hover:after {
content:'';
display:block;
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
background:white;
opacity:0.5;
z-index:-2;
}
<div class="element">test</div>
<div class="element2">test</div>
<div class="element3">test</div>
if you're interested in the explanation check this answer
OR YOU CAN TRY THIS CODE ALSO
OR YOU CAN TRY THIS ONE ALSO::
<!DOCTYPE html>
<html>
<head>
<style>
.element{
width:100px;
height:50px;
background-color:#888888;
}
.element:hover {
background-color: yellow;
}
.element2{
width:100px;
height:50px;
background-color:#222222;
}
.element2:hover {
background-color: red;
}
</style>
</head>
<body>
<div class="element">
Content of the DIV
</div>
<div class="element2">
Content of the Div2
</div>
</body>
</html>

Opacity - changing from-to for background with CSS

I have the following element with background:
and I want to set to it opacity changing from 0 to 1 for example. Is it possible to make this only with CSS?
This is how I am making the background:
padding: 5px 10px 5px 10px;
background-image: linear-gradient(-45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent);
background-size: 20px 20px;
background-color: #E5D52B;
Is this what you are trying to do? fiddle
<button class="button">
<span></span>
</button>
.button {
padding: 5px 10px 5px 10px;
background-image: linear-gradient(-45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent);
background-size: 20px 20px;
background-color: #E5D52B;
width:400px;
height:100px;
}
span {
background: linear-gradient(to left, rgba(255, 255, 255, 0) 20%, rgba(255, 255, 255, 1) 80%);
left:0;
top:8px;
width:400px;
height:100px;
position:absolute;
margin:0;
padding: 0;
}
You can use CSS3 transitions.
.button {
padding: 5px 10px 5px 10px;
background-image: linear-gradient(-45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent);
background-size: 20px 20px;
background-color: #E5D52B;
opacity:1;
transition:opacity 1s;
-webkit-transition:opacity 1s;
}
.button:hover {
opacity:0;
transition:opacity 1s;
-webkit-transition:opacity 1s;
}
You can replace .button:hover with another definition for the same effect. See this fiddle.
here is how you do it:::
img
{
opacity:0.4;
filter:alpha(opacity=40); /* For IE8 and earlier */
}
img:hover
{
opacity:1.0;
filter:alpha(opacity=100); /* For IE8 and earlier */
}

Resources