Clip-Path and border
1
1
1
The clip-path() property
Clip-path() is a CSS property to cut a geometrical region from a region:
We use circle( radius, center ):
//we can use % and px for the center, 50% takes the entire space
.circolo{
background-color: red;
clip-path: circle(40% at 20% 75% );
}
We can have border-radius on inset clips:
We can clip entire polygon(), you can use this as a guide:
We draw (X,Y) points for each point of the polygon:
//remember to NOT put a (,) for the last point
.stalle{
background-color: white;
clip-path: polygon(
50% 0%,
61% 35%,
98% 35%,
68% 57%,
79% 91%,
50% 70%,
21% 91%,
32% 57%,
2% 35%,
39% 35%
);
}
CSS borders and border-box
Using the border property we can specify width, color and style of a border
We can use border-style: double or the outline property for a double border:
For an internal border, we can use :before:after, box-shadow, or background-clip:
We space each side:
//relative>absolute needed
.tasti{
position: relative;
border: 8px solid red;
}
.tasti::after{
content: " ";
position: absolute;
top: 5px;
left: 5px;
right: 5px;
bottom: 5px;
border: 3px solid green;
}
The border width sets the difference between content-box and border-box:
//box-sizing: content-box is set by default, it adds border and padding to the width
//border-box sums border and padding to the set width
.come{
background-color: pink;
box-sizing: content-box;
padding: 20px;
border: 10px blue solid;
}
.cane{
background-color: pink;
border: 10px blue solid;
box-sizing: content-box;
}
We use border-images to use gradients or url images for our borders:
We can't use border-radius not border-left/right/top/bottom for border-image but:
1
Last updated
Was this helpful?