作者热门文章
- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
如何仅使用 CSS 绘制像此图像左侧那样的丝带末端?
我知道我可以利用 CSS 中的 Angular 是斜接的这一事实,所以我可以有一个 div
,其边框大小为 0,其他边框更大来给我三 Angular 形。有没有办法只用 1 个 div
来做到这一点?或者我需要堆叠一些三 Angular 形吗?我真的更喜欢有 1 个 div
,这样用户就不必考虑这个,我可以只使用 CSS :before
伪元素来插入它。实现这一点的最佳方式是什么?
IE9+和其他浏览器的现代版本只需要支持。
最佳答案
HTML
<div class="ribbon">
<strong class="ribbon-content">Everybody loves ribbons</strong>
</div>
CSS
.ribbon {
font-size: 16px !important;
width: 50%;
position: relative;
background: #ba89b6;
color: #fff;
text-align: center;
padding: 1em 2em; /* Adjust to suit */
margin: 2em auto 3em;
}
.ribbon:before {
content: "";
position: absolute;
display: block;
bottom: -1em;
border: 1.5em solid #986794;
z-index: -1;
}
.ribbon:before {
left: -2em;
border-right-width: 1.5em;
border-left-color: transparent;
}
.ribbon .ribbon-content:before {
content: "";
position: absolute;
display: block;
border-style: solid;
border-color: #804f7c transparent transparent transparent;
bottom: -1em;
}
.ribbon .ribbon-content:before {
left: 0;
border-width: 1em 0 0 1em;
}
关于色带末端的 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13341399/
我正在尝试将 View 的背景设置为具有从 Palette api 生成颜色的渐变 渐变将从纯色逐渐淡出,但我希望纯色部分占据大部分背景。现在它开始稳定,然后在 View 宽度上逐渐淡出,我希望它从
我是一名优秀的程序员,十分优秀!