html - 如何在 CSS3 的边框中使用渐变?

标签 html css gradient

enter image description here

我想要上面的结果,不能使用图片,因为div的高度不固定。

我们将不胜感激。

最佳答案

您可以使用伪类 & gredient background 来创建它。检查下面更新的代码段 ...

.msgBox {
  padding: 3px;
  background: #f9db31;
  background: -webkit-linear-gradient(#f9db31 0%, #ff0000 100%);
  background: -moz-linear-gradient(#f9db31 0%, #ff0000 100%);
  background: -o-linear-gradient(#f9db31 0%, #ff0000 100%);
  background: linear-gradient(#f9db31 0%, #ff0000 100%);
  float: left;
  margin: 50px;
  position: relative;
  border-radius: 5px;
}
.msgBox::before {
  border-bottom: 30px solid transparent;
  border-right: 30px solid #f9db31;
  border-top: 0 solid transparent;
  content: "";
  height: 0;
  left: -27px;
  position: absolute;
  top: 25px;
  width: 0;
  z-index: 999;
}
.msgBox::after {
  border-bottom: 28px solid transparent;
  border-right: 28px solid #fff;
  border-top: 0 solid transparent;
  content: "";
  height: 0;
  left: -21px;
  position: absolute;
  top: 27px;
  width: 0;
  z-index: 999;
}
.innerBox {
  width: 400px;
  min-height: 200px;
  background: #fff;
  border-radius: 5px;
}
<div class="msgBox">
<div class="innerBox">

</div>
</div>

关于html - 如何在 CSS3 的边框中使用渐变?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47029397/

相关文章:

Python BeautifulSoup 提取字体标签的内容

css - print.css 正在打印非常小的文本

javascript - 如何制作旋转渐变(在圆上)?

python - 在 Django 中,如何只打印错误而不打印 key ?

html - Chrome 中相同的样式,不同的字体颜色

html - 我想在 css 中应用鼠标移出延迟

ios - 无法在启用 Storyboard自动布局的 iOS6 中执行自定义 UIButton

css - 线性渐变的 URL 不起作用

php - 横向打印页面

javascript - 猫头鹰轮播图像幻灯片无法很好地调整大小