css - 我怎样才能用背景渐变制作这个形状?

标签 css css-shapes linear-gradients radial-gradients

我想创建这个只有背景的形状。或者可能是剪辑路径和伪元素。

enter image description here

到目前为止,我尝试使用 ::before

div {
  height: 300px;
  width: 400px;
  background: tomato;
  border-radius: 0 0 5px 0;
  position: relative;
}
div::before {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: inherit;
  height: 400px;
  background: red;
  bottom: -395px;
  border-radius: 0 0 400px 0;
}

.abs {
  width: 400px;
  position: absolute;
  top: 0;
  left: 0;
}

body {
  margin: 0;
}
<div></div>

<img src="https://i.hizliresim.com/LvZGL1.png" alt="" class="abs"> <!-- intended shape -->

最佳答案

您可以考虑将倾斜变换与一些溢出和半径相结合:

.box {
  width: 200px;
  height: 280px;
  position: relative;
  overflow:hidden;
}

.box:before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-bottom-right-radius: 100px 50px;
  background: linear-gradient(26deg,red,blue);
  transform: skewY(-26deg);
  transform-origin: left;
}
<div class="box">

</div>

关于css - 我怎样才能用背景渐变制作这个形状?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57196016/

相关文章:

css - 如何让这个 CSS slider 只作为自动播放?

css - 自定义 Css 在 magento 2 中不起作用

css - 使用 CSS 创建钟形

CSS Clip-path定位问题

css - 折叠的导航栏高度不同

css - 在没有 CSS 的情况下设置 html 文本的样式

css - Firefox 渐变作为 mask

winforms - 如何在 Visual C++ 中为窗体设置渐变背景色?

CSS六 Angular 里,怎么样?

css - 线性梯度或 calc() 在 IE11 中不起作用