我想将 html div 设置为像火箭一样,我的意思是它应该表示为带有三角形边缘的长方形。就像这个截图: -
问问题
857 次
6 回答
8
纯 CSS 解决方案可以使用 :after 伪选择器并滥用边框来制作三角形。该站点甚至会为您生成代码:
将位置设置为右侧,大小设置为 div 的高度。
于 2012-09-09T23:47:24.670 回答
4
你实际上可以用纯 CSS 做三角形: http: //css-tricks.com/snippets/css/css-triangle/
于 2012-09-09T23:45:24.697 回答
2
这是您可以使用 css 做的事情,有点像箭头。
.arrow_box {
position: relative;
background: #2ad517;
border: 4px solid #12f50a;
top: 100px;
width: 240px;
height: 180px
}
.arrow_box:after, .arrow_box:before {
left: 100%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.arrow_box:after {
border-color: rgba(42, 213, 23, 0);
border-left-color: #2ad517;
border-width: 90px;
top: 50%;
margin-top: -90px;
}
.arrow_box:before {
border-color: rgba(18, 245, 10, 0);
border-left-color: #12f50a;
border-width: 96px;
top: 50%;
margin-top: -96px;
}
于 2012-09-09T23:53:38.500 回答
1
让你开始的东西
于 2012-09-09T23:55:09.040 回答
0
希望这会有所帮助:http: //jsfiddle.net/A2KzR/
HTML:
<div id="global">
<div id="normal" >Content</div>
<div id="triangle-right" />
</div>
CSS:
#triangle-right {
width: 0;
height: 0;
border-top: 50px solid transparent;
border-left: 100px solid red;
border-bottom: 50px solid transparent;
left: 50px;
position: relative;
}
#normal {
width: 50px;
height: 100px;
background-color: red;
float:left;
}
#global {
width: 800px;
}
于 2012-09-09T23:54:58.450 回答