CSS特殊形状,一个角被修剪。

huangapple go评论70阅读模式
英文:

CSS special shape with one shaved corner

问题

我尝试制作一个有一个角被削掉的按钮,我在网上搜索但找不到创建它的方法。

我尝试的是以下CSS代码:

#button {
  border-bottom: 100px solid red;
  border-left: 25px solid transparent;
  height: 0;
  width: 100px;
}

但正如你可以看到的那样,它并不会:

CSS特殊形状,一个角被修剪。

任何帮助都将非常感谢。

英文:

I try to make a button with one corner shaved, I was searching around the web but could't find a method to create it like that.

CSS特殊形状,一个角被修剪。

The thing I tried is the following css code:

   #button {
  border-bottom: 100px solid red;
  border-left: 25px solid transparent;
  height: 0;
  width: 100px;
}

But as you can see, it does..:

CSS特殊形状,一个角被修剪。

Any help would be great

答案1

得分: 5

你考虑过使用clip-path吗?
你可以尝试这个

.path {
  clip-path: polygon(28% 0, 100% 0, 100% 100%, 0 100%, 0 29%);
  width: 100px;
  height: 60px;
  background-color: tomato;
}
<div class="path"></div>
英文:

Have you consider using clip-path?
You can try this

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

.path {
  clip-path: polygon(28% 0, 100% 0, 100% 100%, 0 100%, 0 29%);
  width: 100px;
  height: 60px;
  background-color: tomato;
}

<!-- language: lang-html -->

&lt;div class=&quot;path&quot;&gt;&lt;/div&gt;

<!-- end snippet -->

huangapple
  • 本文由 发表于 2020年1月6日 16:31:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/59608876.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定