<p class="sycode"> <br> </p> <br> <title>纯CSS实现 “三角箭头”代码</title> <br> <meta http-equiv="Content-Language" content="zh-CN"> <br> <style type="text/css"><!-- <br /> span {_overflow:hidden;} <br /> .wp {position: relative; background: red; padding: 20px; color: #fff; margin-bottom: 30px;} <br /> .arrow {position: absolute; left: 30px; top: -32px; width: 0; height: 0; font-size: 0; border-width: 16px; border-style: dashed dashed solid dashed; border-color: transparent transparent <br /> <br /> <br /> red transparent;} <br /> --></style> <br> <style _mce_bogus="1"> <br /> <!-- <br /> span {_overflow:hidden;} <br /> .wp {position: relative; background: red; padding: 20px; color: #fff; margin-bottom: 30px;} <br /> .arrow {position: absolute; left: 30px; top: -32px; width: 0; height: 0; font-size: 0; border-width: 16px; border-style: dashed dashed solid dashed; border-color: transparent transparent <br /> <br /> <br /> red transparent;} <br /> --></style> <br> <br> <br> <div style="padding: 40px; background:#fff;" _mce_style="padding: 40px; background: #fff;"> <br> <div class="wp"> <br> <span class="arrow"></span>“三角形箭头”例1</div> <br> <div style="position: relative; background: red; padding: 20px; color: #fff; margin-bottom: 30px;" _mce_style="position: relative; background: red; padding: 20px; color: #fff; margin- <br /> <br /> <br /> bottom: 30px;"> <br> <span style="position: absolute; left: 30px; top: -32px; width: 0; height: 0; font-size: 0; border-width: 16px; border-style: dashed dashed solid dashed; border-color: transparent <br /> <br /> <br /> transparent red transparent;" _mce_style="position: absolute; left: 30px; top: -32px; width: 0; height: 0; font-size: 0; border: 16px dashed dashed solid dashed transparent transparent <br /> <br /> <br /> red transparent;"></span>“三角形箭头”例1</div> <br> <div style="position: relative; border: 4px solid red; padding: 20px; margin-bottom: 30px;" _mce_style="position: relative; border: 4px solid red; padding: 20px; margin-bottom: <br /> <br /> <br /> 30px;"> <br> <span style="position: absolute; left: 30px; top: -32px; width: 0; height: 0; font-size: 0; border-width: 16px; border-style: dashed dashed solid dashed; border-color: transparent <br /> <br /> <br /> transparent red transparent;" _mce_style="position: absolute; left: 30px; top: -32px; width: 0; height: 0; font-size: 0; border: 16px dashed dashed solid dashed transparent transparent <br /> <br /> <br /> red transparent;"></span><span style="position: absolute; left: 30px; top: -27px; width: 0; height: 0; font-size: 0; border-width: 16px; border-style: dashed dashed solid dashed; <br /> <br /> <br /> border-color: transparent transparent #FFF transparent;" _mce_style="position: absolute; left: 30px; top: -27px; width: 0; height: 0; font-size: 0; border: 16px dashed dashed solid <br /> <br /> <br /> dashed transparent transparent #FFF transparent;"></span>“三角形箭头”例2</div> <br> <div style="position: relative; background: red; padding: 20px; color: #fff; margin-bottom: 30px;" _mce_style="position: relative; background: red; padding: 20px; color: #fff; margin- <br /> <br /> <br /> bottom: 30px;"> <br> <span style="position: absolute; left: 30px; top: -16px; width: 0; height: 0; font-size: 0; border-width: 16px; border-style: dashed dashed dashed solid; border-color: transparent <br /> <br /> <br /> transparent transparent red;" _mce_style="position: absolute; left: 30px; top: -16px; width: 0; height: 0; font-size: 0; border: 16px dashed dashed dashed solid transparent transparent <br /> <br /> <br /> transparent red;"></span>“三角形箭头”例3</div> <br> <div style="position: relative; background: red; padding: 20px; color: #fff; margin-bottom: 30px;" _mce_style="position: relative; background: red; padding: 20px; color: #fff; margin- <br /> <br /> <br /> bottom: 30px;"> <br> <span style="position: absolute; left: 30px; top: -16px; width: 0; height: 0; font-size: 0; border-width: 16px 24px; border-style: dashed dashed dashed solid; border-color: transparent <br /> <br /> <br /> transparent transparent red;" _mce_style="position: absolute; left: 30px; top: -16px; width: 0; height: 0; font-size: 0; border: 16px 24px dashed dashed dashed solid transparent <br /> <br /> <br /> transparent transparent red;"></span><span style="position: absolute; left: 14px; top: -32px; width: 0; height: 0; font-size: 0; border-width: 16px; border-style: dashed dashed solid <br /> <br /> <br /> dashed; border-color: transparent transparent #fff transparent;" _mce_style="position: absolute; left: 14px; top: -32px; width: 0; height: 0; font-size: 0; border: 16px dashed dashed solid <br /> <br /> <br /> dashed transparent transparent #fff transparent;"></span>“三角形箭头”例4</div> <br> <div style="position: relative; background: red; width: 160px; padding: 20px; color: #fff; margin-bottom: 30px;" _mce_style="position: relative; background: red; width: 160px; <br /> <br /> <br /> padding: 20px; color: #fff; margin-bottom: 30px;"> <br> <span style="position: absolute; left: 0px; top: -12px; width: 188px; height: 0; font-size: 0; border-width: 6px; border-style: dashed dashed solid dashed; border-color: transparent <br /> <br /> <br /> transparent red transparent;" _mce_style="position: absolute; left: 0px; top: -12px; width: 188px; height: 0; font-size: 0; border: 6px dashed dashed solid dashed transparent transparent <br /> <br /> <br /> red transparent;"></span> <br> 模拟梯形边<span style="position: absolute; left: 0px; bottom: -12px; width: 188px; height: 0; font-size: 0; border-width: 6px; border-style: solid dashed dashed dashed; border-color: <br /> <br /> <br /> red transparent transparent transparent;" _mce_style="position: absolute; left: 0px; bottom: -12px; width: 188px; height: 0; font-size: 0; border: 6px solid dashed dashed dashed red <br /> <br /> <br /> transparent transparent transparent;"></span> <br> </div> <br> <h2>看看这个例子就会明白所谓“三角边”了</h2> <br> <div style="border-width:40px;border-style:solid;border-color:red green black blue;line-height:0;font-size:0;overflow:hidden;width:100px;height:0" _mce_style="line-height: 0; font-size: <br /> <br /> <br /> 0; overflow: hidden; width: 100px; height: 0; border: 40px solid red green black blue;"></div> <br> <h2>把某些边透明掉就可以模拟三角形了,注意ie6下透明的边要是dotted或dashed</h2> <br> <div style="border-width:40px;border-style:dashed dashed solid dashed;border-color:transparent transparent red transparent;line-height:0;font-size:0;width:0;height:0" _mce_style="line <br /> <br /> <br /> -height: 0; font-size: 0; width: 0; height: 0; border: 40px dashed dashed solid dashed transparent transparent red transparent;"></div> <br> <div style="border-width:40px;border-style:dashed solid solid dashed;border-color:transparent blue red transparent;line-height:0;font-size:0;width:0;height:0" _mce_style="line-height: <br /> <br /> <br /> 0; font-size: 0; width: 0; height: 0; border: 40px dashed solid solid dashed transparent blue red transparent;"></div> <br> </div> <br> <div><a href="http://www.999jiujiu.com/"> http://www.999jiujiu.com/</a></div> <br> <br>