Custom bottom border on div using mask - html

Hi i want effect like this on my div but only at the bottom:
What im doing right now is this:
.container {
width: 500px;
height: 150px;
background: #FDCA40;
}
.box {
width: 100%;
height: 100px;
background: #FE7448;
-webkit-mask: radial-gradient(circle 20px, transparent 97%, #fff 100%) top/50px 200%;
// not working:
// -webkit-mask: radial-gradient(circle 20px, #FE7448 97%, #FE7448 100%) top/50px 200%;
}
<div class="container">
<div class="box"></div>
</div>
Which property in mask allows me to give color to circle? Whole mask property is confusing to me.

You can do it like below:
.container {
width: 500px;
height: 150px;
background: #FDCA40;
}
.box {
height: 100px;
background: #FE7448;
-webkit-mask:
linear-gradient(#fff 0 0)
top/100% calc(100% - 20px) no-repeat,
radial-gradient(circle closest-side, #fff 97%,transparent 100%)
bottom/50px 40px space;
}
<div class="container">
<div class="box"></div>
</div>
Using CSS variables to easily manage it:
.container {
width: 500px;
height: 150px;
background: #FDCA40;
}
.box {
--r:20px; /* radius */
--d:10px; /* minimum distance between circles */
height: 100px;
background: #FE7448;
-webkit-mask:
linear-gradient(#fff 0 0)
top/100% calc(100% - var(--r)) no-repeat,
radial-gradient(circle closest-side, #fff 97%,transparent 100%)
bottom/calc(2*var(--r) + var(--d)) calc(2*var(--r)) space;
}
<div class="container">
<div class="box"></div>
</div>
<div class="container">
<div class="box" style="--r:30px;--d:0px;"></div>
</div>

Related

How to make a curved shape with gradient?

I have to create image like this using CSS:-
If not possible then how can I use this with minimum image size? Like in below code I have used two images but this is also not working...
<div style="background:url('https://i.stack.imgur.com/veeS8.png') no-repeat top center, url('https://i.stack.imgur.com/2i7ed.png') repeat-y top 50px center; widhth:100%; height:800px; background-size:100%;">
</div>
Also possible with masking without using image. This is more flexible. You can control easily the slope by changing the variable.
.container {
--slope: 100px;
width: 100%;
height: 500px;
--mask: radial-gradient(farthest-side, #000 99%, transparent 100%) 50% 0 / 150% calc(var(--slope) * 2) no-repeat,
linear-gradient(#000, #000) 0 100% / 100% calc(100% - var(--slope)) no-repeat;
-webkit-mask: var(--mask);
mask: var(--mask);
background: linear-gradient(90deg, rgba(133, 132, 242, 1) 0%, rgba(35, 136, 253, 1) 50%, rgba(127, 237, 226, 1) 100%);
}
<div class='container'></div>
something like this would work:
div.cont:before {
content: '';
background-image: url(https://i.stack.imgur.com/2i7ed.png);
background-size: 100% auto;
position: absolute;
top: 44px;
left: 0;
right: 0;
bottom: 0;
}
<div class="cont" style="width: 100%;height:800px;background-image: url(https://i.stack.imgur.com/veeS8.png);background-size: 100% auto;background-repeat: no-repeat;position: relative;">
</div>
a trivial task using clip-path
.container {
height: 400px;
background: linear-gradient(90deg, rgba(133,132,242,1), rgba(35,136,253,1), rgba(127,237,226,1));
clip-path:ellipse(90% 100% at bottom); /* simply adjust the 90% */
}
<div class='container'></div>
To have the same curvature on resize use pixel value
.container {
height: 400px;
max-width:800px;
background: linear-gradient(90deg, rgba(133,132,242,1), rgba(35,136,253,1), rgba(127,237,226,1));
clip-path:ellipse(600px 100% at bottom);
}
<div class='container'></div>
.element {
width: 200px;
height: 200px;
border-radius: 100% 100% 0 0 / 20% 20% 0 0;
background-image: linear-gradient(to right, #8684F2 0%, #1BEEE3 100%);
}
You can use CSS Gradient to get this kind of result. You can also use some tools online to generate some gradients like this one:
https://cssgradient.io/
.container {
width: 500px;
height: 500px;
background: rgb(133,132,242);
background: linear-gradient(90deg, rgba(133,132,242,1) 0%, rgba(35,136,253,1) 50%, rgba(127,237,226,1) 100%);
}
<div class='container'>
</div>

How to make shaped background using linear gradient?

How to make side beveled background using linear gradient?
html:
<div class="signpost">
<div class="column">
</div>
<div class="column bg-gray">
</div>
<div class="column">
</div>
</div>
css:
.signpost {display: table; width: 100%; height: 100vh; }
.signpost .column {display: table-cell; width: 33.33%; height: 100%; text-align: center;}
.bg-gray {background-image: linear-gradient(to left bottom, #ededed 0%, #ededed 100%, white 0%, white 0%);}
Example
Thank you for help!
Try this
.signpost {
width: 100wh;
height: 100vh;
background: linear-gradient(to bottom right, red 40%, transparent 44%) 0 0/50px 100% no-repeat,
linear-gradient(to top left, red 40%, transparent 44%) 100% 100%/70px 200% no-repeat,
#ededed;
}
<div class="signpost">
</div>
Can be made with multiple gradients:
linear-gradient(to bottom right, red 49%, transparent 51%) x-position y-position/x-size y-size
.box {
width: 300px;
height: 300px;
background: linear-gradient(to bottom right, red 49%, transparent 51%) 0 0/30px 100% no-repeat,
linear-gradient(to top left, red 49%, transparent 51%) 100% 100%/50px 200% no-repeat,
#ededed;
}
<div class="box">
</div>
An idea using one gradient:
.signpost {
display: table;
width: 100%;
height: 100vh;
}
.signpost .column {
display: table-cell;
width: 33.33%;
height: 100%;
}
.bg-gray {
background: linear-gradient(to bottom right,red 44%, #ededed 44.1% 55%, red 55.1%) center/100vw 1000vw;
}
body {
margin:0;
}
<div class="signpost">
<div class="column">
</div>
<div class="column bg-gray">
</div>
<div class="column">
</div>
</div>

Custom top border on div only at the top ot using mask

Hi i want effect like this on my div but only at the top:
I know there is css mask property but it's really complicated to me.
My solution is I created single circle svg and repeat it multiple times but i also need that left/right space.
.container {
margin: 20px 0;
height: 400px;
background: lightgray;
position: relative;
}
.svg {
background: url('../../assets/circle-gapped.svg');
height: 100%;
background-repeat: repeat-x;
position: absolute;
left: 0;
right: 0;
top: -30px;
}
<div class="container">
<div class="svg" />
</div>
I don't know how to upload assest to snippet, this is result of above code:
Like below:
.box {
width:300px;
height:200px;
background:red;
-webkit-mask: /* 20px = radius of circle 50px = 2*radius + 10px (distance between circles)*/
radial-gradient(circle 20px,transparent 97%, #fff 100%) bottom/50px 200%,
linear-gradient(#fff 0 0) left /20px 100% no-repeat, /* 20px of left border */
linear-gradient(#fff 0 0) right/20px 100% no-repeat; /* 20px of right border */
}
<div class="box"></div>
Or like below to have responsiveness:
.box {
height:200px;
background:red;
padding:0 50px;
-webkit-mask:
radial-gradient(circle 20px,#fff 97%, transparent 100%) bottom/50px 200% space content-box,
linear-gradient(#fff 0 0);
-webkit-mask-composite:destination-out;
mask-composite: exclude;
}
<div class="box"></div>
You can do this with a pseudo element on the gray div which has a repeating pattern of radial-gradient circles which are 50% radius gray and transparent for the outer 50%. Of course alter the dimensions and positions to give the exact look you want.
div.yellow {
background-color:yellow;
width: 100vw;
height: 80vh;
}
div.gray {
background-color: gray;
height: 20vh;
width: 100vw;
position: relative;
top: 0;
}
div.gray::after {
content:' ';
width: 100vw;
height: 10vh;
background-color: transparent;
position: absolute;
top: 15vh;
left: 0;
z-index: 2;
background-image: radial-gradient(gray,gray 50%,transparent 50%);
background-size: 10vh 10vh;
}
<div class="gray"></div>
<div class="yellow"></div>

How to make the image "normal" in a skewed div?

So I wanted to make a diamond with an image in it but the image will deform. I want to make it so that it's horizontal (normal) and filling the diamond.
The code I made.
.diamond {
width: 300px;
height: 300px;
border: 3px solid white;
outline: 2px solid black;
outline-offset: 20px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) rotate(67.5deg) skewX(45deg) scaleY(0.70711);
overflow: hidden;
}
.diamond-image {
background-image: url("https://images7.alphacoders.com/108/1082408.png");
background-size: cover;
position: absolute;
height: 100%;
width: 140%;
top: 0px;
left: 0px;
transform-origin: top bottom;
}
html{
height: 100%;
}
body{
background: rgb(224,215,215);
background: radial-gradient(circle, rgba(224,215,215,1) 0%, rgba(144,144,144,1) 100%);
}
<div class="diamond">
<div class="diamond-image"></div>
</div>
It would probably be complex to invert the transformation. I would build this differently without transformation.
You can simply control the shape by adjusting the width/height and the CSS variables
html{
min-height: 100%;
background: radial-gradient(circle, rgba(224,215,215,1) 0%, rgba(144,144,144,1) 100%);
}
.box {
--d:15px; /* gap between border and outline*/
--b1:3px; /* width of outline (black)*/
--b2:3px; /* width of border (white) */
--g1:transparent calc(48% - var(--d) - var(--b1) - var(--b2)) ,
#fff calc(49% - var(--d) - var(--b1) - var(--b2)) calc(49% - var(--b1)),
#000 calc(50% - var(--b1));
--g2:#fff calc(48.5% - var(--d) - var(--b1) - var(--b2)) calc(48.5% - var(--d) - var(--b1)),
transparent calc(49% - var(--d) - var(--b1)) calc(49% - var(--b1)),
#fff calc(49.5% - var(--b1)) 49.5%,
transparent 50%;
width:200px;
height:400px;
display:inline-block;
vertical-align:top;
background:
linear-gradient(to top right,var(--g1)) top right / 50% 50%,
linear-gradient(to top left ,var(--g1)) top left / 50% 50%,
linear-gradient(to bottom right,var(--g1)) bottom right / 50% 50%,
linear-gradient(to bottom left ,var(--g1)) bottom left / 50% 50%,
url(https://picsum.photos/id/1074/800/800) center/cover;
background-repeat:no-repeat;
-webkit-mask:
linear-gradient(to top right,var(--g2)) top right,
linear-gradient(to top left ,var(--g2)) top left,
linear-gradient(to bottom right,var(--g2)) bottom right,
linear-gradient(to bottom left ,var(--g2)) bottom left;
-webkit-mask-size:50% 50%;
-webkit-mask-repeat:no-repeat;
mask:
linear-gradient(to top right,var(--g2)) top right,
linear-gradient(to top left ,var(--g2)) top left,
linear-gradient(to bottom right,var(--g2)) bottom right,
linear-gradient(to bottom left ,var(--g2)) bottom left;
mask-size:50% 50%;
mask-repeat:no-repeat;
}
<div class="box"></div>
<div class="box" style="width:300px;--b1:5px;--d:20px"></div>
<div class="box" style="height:200px;--b2:5px;--d:5px"></div>

How to create a gradient css with an arrow down connected to a container

I'm trying to put an triangle/arrow under the v-container with some gradient colour but I don't know how to "merge" the gradient.
If I create the arrow with CSS the gradient won't match.
Any ideas about how to achieve this?
Here is the code:
HTML:
<div id="app">
<v-container fluid pa-0 class="gradient white--text">
<v-layout row wrap text-xs-center>
<v-flex xs12>
<h1 class="display-1 my-5">Lorem Ipsum</h1>
</v-flex>
</v-layout>
</v-container>
<div class="bottom-arrow"></div>
</div>
CSS:
.gradient{
height: 300px;
background: rgb(0,105,173);
background: linear-gradient(45deg, rgba(0,105,173,1) 0%, rgba(34,84,132,1) 100%);
}
.bottom-arrow:after {
content:'';
position: absolute;
left: 0;
right: 0;
margin: 0 auto;
width: 0;
height: 0;
border-top: 50px solid rgb(0,105,173);
border-left: 50px solid transparent;
border-right: 50px solid transparent;
}
You can use css clip-path, but the browser support is not that great.
.gradient{
height: 300px;
background: rgb(0,105,173);
background: linear-gradient(45deg, rgba(0,105,173,1) 0%, rgba(34,84,132,1) 100%);
display: flex;
justify-content: space-around;
align-items: center;
/* Clip-path */
/* clip-path: polygon(0% 0%, 100% 0%, 100% calc(100% - 30px), 60% calc(100% - 30px), 50% 100%, 40% calc(100% - 30px), 0% calc(100% - 30px));
padding-bottom: 30px; */
/* Fixed-width arrow */
clip-path: polygon(0% 0%, 100% 0%, 100% calc(100% - 30px), calc(50% + 40px) calc(100% - 30px), 50% 100%, calc(50% - 40px) calc(100% - 30px), 0% calc(100% - 30px));
}
<div id="app" class="gradient">
<h1 class="display-1 my-5">Lorem Ipsum</h1>
</div>
Here is another idea more supported than clip-path but without transparency.
.gradient{
height: 250px;
background:
/* 28.3px = cos(45deg) x 40px
225deg = 180deg + 45deg
*/
linear-gradient( 225deg, transparent 28.3px,#fff 29px) bottom left /50% 40px,
linear-gradient(-225deg, transparent 28.3px,#fff 29px) bottom right/50% 40px,
/*Your gradient*/
linear-gradient(to bottom right, red,yellow ,blue);
background-repeat:no-repeat;
}
<div id="app" class="gradient">
</div>