gpt4 book ai didi

css - 在 css 中创建一个具有渐变背景的三 Angular 形

转载 作者:技术小花猫 更新时间:2023-10-29 11:14:45 25 4
gpt4 key购买 nike

我正在尝试在 css 中创建一个具有渐变背景的三 Angular 形。我还没有取得任何成功。有没有办法做到这一点来实现下图中看到的这种效果。(附加到错误密码错误框的三 Angular 形。)

在 Photoshop 中设计 enter image description here

这是我目前在 HTML 和 CSS 中的设计。

enter image description here

这是我目前为三 Angular 形准备的 CSS。

.error-triangle {
wwidth: 0;
height: 0;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-right: 10px solid blue;
margin-top: 64px;
margin-left: 350px;
position: fixed;
-webkit-box-shadow: 0 0 3px rgba(102,65,65,.25), 2px 3px 5px rgba(70,34,34,.25), inset 1px 2px rgba(255,255,255,.25);
-moz-box-shadow: 0 0 3px rgba(102,65,65,.25), 2px 3px 5px rgba(70,34,34,.25), inset 1px 2px rgba(255,255,255,.25);
box-shadow: 0 0 3px rgba(102,65,65,.25), 2px 3px 5px rgba(70,34,34,.25), inset 1px 2px rgba(255,255,255,.25);
background-image: -webkit-linear-gradient(bottom, #eb6767, #d94040 35%, #eb6767);
background-image: -moz-linear-gradient(bottom, #eb6767, #d94040 35%, #eb6767);
background-image: -o-linear-gradient(bottom, #eb6767, #d94040 35%, #eb6767);
background-image: -ms-linear-gradient(bottom, #eb6767, #d94040 35%, #eb6767);
background-image: linear-gradient(to top, #eb6767, #d94040 35%, #eb6767);
}

我正在使用这个 tutorial on CSS tricks.

最佳答案

创建具有渐变(或任何其他类型的图像背景)的三 Angular 形(或其他形状 - pentagons, hexagons、八边形、decagonsdodecagonstetradecagonsoctadecagons 等)非常容易使用 CSS 转换。

但在这种情况下,您甚至不需要三 Angular 形。您只需将方形伪元素旋转 45 度,然后在其上从一个 Angular 到另一个 Angular 应用渐变。

demo

<div class='warn'></div>

CSS:

.warn {
position: relative;
margin: 0 auto;
border: solid 1px darkred;
width: 12em; height: 3em;
border-radius: .2em;
background: linear-gradient(lightcoral, firebrick);
}
.warn:before {
position: absolute;
top: 50%; left: 0;
margin: -.35em -.45em;
border-left: inherit; border-bottom: inherit;
/* pick width & height such that
the diagonal of the square is 1em = 1/3 the height of the warn bubble */
width: .7em; height: .7em;
border-radius: 0 0 0 .2em;
transform: rotate(45deg);
background: linear-gradient(-45deg, firebrick -100%, lightcoral 200%);
content: '';
}

关于css - 在 css 中创建一个具有渐变背景的三 Angular 形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15437233/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com