gpt4 book ai didi

html - 如何在 CSS 中创建丝带形状

转载 作者:太空宇宙 更新时间:2023-11-04 13:46:50 25 4
gpt4 key购买 nike

http://jsfiddle.net/6HyjZ/

.bookmarkRibbon{
width:0;
height:100px;
border-right:50px solid blue;
border-left:50px solid blue;
border-bottom:30px solid transparent;
}

<div class="bookmarkRibbon"></div>

我正在努力制作这种形状的版本,其中丝带指向右侧而不是向下,我怎样才能做到这一点?

最佳答案

使用 CSS 的丝带形状 Clip Path :

.bookmarkRibbon {
width: 100px;
height: 60px;
background: blue;
clip-path: polygon(0% 0%, 100% 0%, calc(100% - 20px) 50%, 100% 100%, 0% 100%);
}
<div class="bookmarkRibbon"></div>

指向下方:

.bookmarkRibbon {
width: 60px;
height: 100px;
background: blue;
clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 50% calc(100% - 20px), 0% 100%, 0% 0%);
}
<div class="bookmarkRibbon"></div>

使用 CSS 的丝带形状 border

为了帮助您逐步可视化逻辑,以便您可以轻松地将其应用于任何方面:

CSS Ribbon Shape - How To Create

.bookmarkRibbon {
border: 30px solid blue; /* All borders set */
border-left: 0; /* Remove left border */
border-right: 20px solid transparent; /* Right transparent */
width: 100px; /* Increase element Width */
}
<div class="bookmarkRibbon"></div>

关于html - 如何在 CSS 中创建丝带形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24207341/

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