Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to cut box corner Using CSS with transparent background?

I want to cut left top corner of a box using CSS like this.

enter image description here

keep in mind that background is transparent.

like image 468
Amir Ur Rehman Avatar asked Jul 09 '17 07:07

Amir Ur Rehman


People also ask

How do I cut a box corner in CSS?

Here is another approach using CSS transform: skew(45deg) to produce the cut corner effect. The shape itself involves three elements (1 real and 2 pseudo-elements) as follows: The main container div element has overflow: hidden and produces the left border.

How do you make a box transparent in CSS?

First, we create a <div> element (class="background") with a background image, and a border. Then we create another <div> (class="transbox") inside the first <div>. The <div class="transbox"> have a background color, and a border - the div is transparent.

How do you make a border-radius transparent?

If you want your border to be transparent (or semitransparent), and you are setting a black background, you need to set the background limited to the inner part, so that the border can be seen. Show activity on this post. You can use a container to provide a border offset if you need it.


2 Answers

Nearly the same solution as OriDrori's answer but more flexible (if you need fixed-width cutted corner).

This gradient will look the same regardless of .card width and height.

body {
  background: purple;
}

.card {
  width: 200px;
  height: 200px;
  background: linear-gradient(135deg, transparent 20px, white 20px);
}
<div class="card"></div>
like image 164
Vadim Ovchinnikov Avatar answered Oct 02 '22 16:10

Vadim Ovchinnikov


You can use a simple linear gradient for that:

body {
  background: purple;
}

.card {
  width: 200px;
  height: 200px;
  background: linear-gradient(to bottom right, transparent 5%, white 5%);
}
<div class="card"></div>
like image 26
Ori Drori Avatar answered Oct 02 '22 16:10

Ori Drori