gpt4 book ai didi

html - 创建 Angular 彩色横幅

转载 作者:太空狗 更新时间:2023-10-29 13:19:47 25 4
gpt4 key购买 nike

您好,我正在尝试在 HTML 和 CSS 中创建以下带 Angular strip 外观:

enter image description here

只是蓝色和紫色区域,后面是白色。

我显然可以看到如何使用图像来实现它,但是仅使用 HTML/CSS 呢?

这可能吗?

它在网站上使用 - www.africa.dating

我知道我应该有更多示例代码,但实际上我不确定从哪里开始,所以我只有以下 HTML:

fiddle :http://jsfiddle.net/e2dr5udr/3/

<div id="container">
<div id="blue"></div>
<div id="purple"></div>
</div>

#container {
width: 100%;
height: 100px;
background-color: white;
position: absolute;
}

#blue {
width: 100%;
height: 100px;
background-color: blue;
position: absolute;
}

#purple {
width: 100%;
height: 100px;
background-color: purple;
position: absolute;
}

谢谢

最佳答案

您可以使用伪元素和一些边框操作

这将允许您只用一个元素创建它,创建这个:

.title {
height: 1px;
background-color: transparent;
border-bottom: 170px solid blue;
border-right: 170px solid transparent;
width: 190px;
position:relative;
}

.title:after{
content:"";
position:absolute;
height: 1px;
top:0px;
background-color: transparent;
border-bottom: 170px solid purple;
border-right: 170px solid transparent;
width: 210px;
z-index:-1;
}
<div class="title"></div>

如果您不想使用这种方法,可以查看另一种方法(使用背景渐变)here


使用 SkewX:

div{
position:relative;
height:15vh;
width:60vw;
overflow:hidden;
}
div:before{
z-index:-1;
content:"";
position:absolute;
top:0;
height:100%;
right:50%;
width:150%;
border-right:10px solid green;
background:cornflowerblue;
-webkit-transform:skewX(45deg);
transform:skewX(45deg);
}
<div>123</div>

关于html - 创建 Angular 彩色横幅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27739851/

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