▪ ▪2015-11-01 18:17:49
css
▪ ▪, 2015-11-01 18:17:49

How to cut corners off a div?

Hello. I wanted to know if it is possible to cut out the corners in the div block using the css method, as shown in the figure? Or is only the old way with pictures suitable for this option?
1322ed653a154e628d4ab46fc662e717.jpg

Answer the question

In order to leave comments, you need to log in

4 answer(s)
T
tef, 2015-11-01
@kingdomofcrooked

Through a radial gradient.
jsfiddle.net/z3my1cfg

K
Kovalsky, 2015-11-01
@lazalu68

There is such a feature - border-corner-shape, although it seems to have been cut out of the spec. Here Lea Verou talks about her. But the demo is also from Lea Verou, in the code you will see how these corners are implemented through SVG.
Here , too, the dude asks how to make corners, through the border-corner-shape, they answer him that this is not yet in the specs and offer working options)

P
Pavel Radkov, 2015-11-01
@paulradzkov

Can be done via border-image: a background color image with transparent segments in the corners. And with the help border-image-outsetadjust the contact between the border and the background.
This is the “new” way, but still with pictures.

E
Evgeny Labuzov, 2016-03-18
@silksofthesoul

There is an option that will only work in chrome.
svgmask.svg file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<svg
  xmlns:svg="http://www.w3.org/2000/svg"
  xmlns="http://www.w3.org/2000/svg"
  viewBox="0 0 80 40"
  
  width="80"
  height="40"
  id="svg2">

  <path
  id="c2"
  d="
  M5,0
  L5,0
  l70,0
  v0
  c0,2.8,2.2,5,5,5
  h0
  v30
  h0
  c-2.8,0-5,2.2-5,5
  v0
  H5
  v0
  c0-2.8-2.2-5-5-5
  h0
  V5
  h0
  C2.8,5,5,2.8,5,0
  z"/>
</svg>

in HTML:
css:
.mask01{
    mask-box-image: url("svgmask.svg") 5 round;
    -webkit-mask-box-image: url("svgmask.svg") 5 round;
  }

The trick is that this method works with frames that have pictures and the size of the "rounded in the opposite direction" corners must be fixed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question