css - 我可以使用 CSS 扭曲边框,使它们看起来像素描吗?

标签 css css-transforms

我有带边框的框 (div),我想让它看起来像草图,即边框不是画成直线,而是稍微扭曲,就像用手画的一样。

插图:

"Sketched" boxes

这可以使用 CSS 转换或类似方法来完成吗?

最佳答案

这篇文章 hand-drawn borders给出了一个很好的例子,通过使用大椭圆圆 Angular (通过 CSS border-radius 属性)仅使用 CSS 在按钮上实现这种效果。它可能不适用于大型 div 元素。

文章改编的例子:

button {
      background:transparent;
      padding:0.5rem 0.5rem;
      margin:0 0.5rem;
      font-size:1rem;

      border-top-left-radius: 255px 15px;
      border-top-right-radius: 15px 225px;
      border-bottom-right-radius: 225px 15px;
      border-bottom-left-radius:15px 255px;
}

button:hover{
   box-shadow:2px 8px 4px -6px hsla(0,0%,0%,.3);
}
button.lined.thick{
   border:solid 3px #41403E;
}
button.dotted.thick{
   border:dotted 3px #41403E;
}
button.dashed.thick{
  border:dashed 3px #41403E;
}
button.lined.thin{
   border:solid 2px #41403E;
}
button.dotted.thin{
   border:dotted 2px #41403E;
}
button.dashed.thin{
  border:dashed 2px #41403E;
}
<button class='lined thick'>Lined Thick</button>
<button class='dotted thick'>Dotted Thick</button>
<button class='dashed thick'>Dashed Thick</button>
<div>&nbsp;</div>
<button class='lined thin'>Lined Thin</button>
<button class='dotted thin'>Dotted Thin</button>
<button class='dashed thin'>Dashed Thin</button>

关于css - 我可以使用 CSS 扭曲边框,使它们看起来像素描吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43694588/

相关文章:

html - Polymer 1.0 Cordova,我该怎么做才能改变主页的方向?

css - 利用 css 转换和转换为 wordpress 构建多级菜单。问题 : does not work in IE

css - 在鼠标移动到 Webkit 中的元素上或从元素上移开之前,元素不会重新绘制

css - 无法在给定样式中设置背景颜色

css - 使用 3d 过渡时的怪异

CSS3 变换顺序很重要 : rightmost operation first

在 Wordpress 站点中使用关键帧进行 CSS 动画/转换

javascript - 按 ENTER 切换 HTML 标签

html - 高度为 100% 图像的 Chrome 随机不保持纵横比并拉伸(stretch)图像。

html - 样式生成的表格行