【发布时间】:2013-07-16 02:06:05
【问题描述】:
尊敬的stackoverflowers,
如何创建带有背景图案的三角形元素?
例如,我需要这样的 div:
但我的状态是这样的:
所有带有三角形元素的示例都使用边框,其中不能有 img ....
这是我需要coolarrow的小节类:
<div class="subsection"><span>Ryan Gosling, Mr Landlord</span></div>
.subsection {
.box-shadow (0, -1px, 1px, 0, rgba(0, 0, 0, 0.3));
background: url('/assets/pattern-lorem.png'); // The inner part of the slider have the pattern
display: block;
clear: both;
float: left;
width: 100%;
padding-top: 15px;
padding-bottom: 15px;
display: none;
}
.subsection {
position:relative;
}
.subsection:before {
content:'';
position:absolute;
top:0;
left:0;
height:20px;
width:0;
border-left:20px solid white;
border-bottom:16px solid transparent;
}
.subsection:after {
content:'';
position:absolute;
top:36px;
left:0;
bottom:0;
width:0;
border-left:20px solid white;
border-top:16px solid transparent;
}
我得到了:
这很好......我怎样才能以所需的形式将箭头放在顶部? ...并覆盖案例 div ? ... 谢谢。
【问题讨论】:
-
我认为这个问题回答了类似的问题stackoverflow.com/questions/11379085/…
-
不,它不是重复的......需要有一个形状但有图像背景的图像......而不是从边框输入的颜色......
-
你会考虑使用 SVG 而不是 CSS 吗?可能会更容易。
标签: html css transform css-shapes