利用CSS的border属性可以生成一些图形,例如三角或是圆角。纯粹的CSS2的内容,没有兼容性的问题。css border 三角,纯css2实现,兼容各浏览器(包括IE6),且效果非常好。
效果演示
简明现代魔法
NowaMagic
Welcome
特点:
外边框部分:会发现是"圆角"。
三角部分:不是图片。再点击,三角形向下。
纯css2实现,效果明显,技术简单。
CSS
.br-test{ width:300px; }
.items *{ margin:0; padding:0; }
.items{ border-color:#ccc; border-style:solid; border-width:0 2px; padding:5px; }
.items-item{ position:relative; border:#CCC 1px solid; height:20px; margin:5px 0 0 0; padding:2px; overflow:hidden; }
.items-item h3{position:absolute; left:24px; font-size:14px; }
.items-item-triangle{ position:absolute; left:5px; width:0; height:0; overflow:hidden; font-size:0; line-height:0; border-color:#fff #fff#fff #CCC; border-style:dashed dashed dashed solid; border-width:10px; cursor:pointer; }
.click{ left:0; top:5px; border-color:#CCC transparent transparent transparent; border-style:solid dashed dashed dashed; }
.top-border{ border-bottom:2px solid #ccc; border-left:2px dotted transparent; border-right:2px dotted transparent; }
.bottom-border{ border-top:2px solid #ccc; border-left:2px dotted transparent; border-right:2px dotted transparent; }
HTML
简明现代魔法
NowaMagic
Welcome
JavaScript
$(".items-item-triangle",$("#br-items")).each(function(){
var that = $(this);
that.click(function(){
$(this).toggleClass("click");
});
});