纯css制作三角、圆形按钮,兼容ie6
2013-10-14 14:13
597 查看
原文网址:http://dtop.powereasy.net/Item/3418.aspx
以前一直用图片做小三角、圆形按钮等,但有时候实在不太方便,例如换个颜色又要打开ps弄,挺麻烦的。而且对于追求细节和极致的前端工程师来说,能不用图片就不用图片,于是参考了天猫、微博等网站的做法,用纯html和css实现,效果还是不错的。
以下是成果,兼容主流浏览器,包括ie6。
代码是:
运行代码编辑代码查看源代码
资源添加向导
css三角原理可以看看这里:
http://www.bobd.cn/design/web/htmlcss/201009/43881.html
以前一直用图片做小三角、圆形按钮等,但有时候实在不太方便,例如换个颜色又要打开ps弄,挺麻烦的。而且对于追求细节和极致的前端工程师来说,能不用图片就不用图片,于是参考了天猫、微博等网站的做法,用纯html和css实现,效果还是不错的。
以下是成果,兼容主流浏览器,包括ie6。
代码是:
运行代码编辑代码查看源代码
资源添加向导
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
>
<
meta
http-equiv
=
"Content-Type"
content
=
"text/html; charset=utf-8"
/>
<
meta
http-equiv
=
"Content-Language"
content
=
"zh-CN"
/>
<
meta
name
=
"Keywords"
content
=
""
/>
<
meta
name
=
"Description"
content
=
""
/>
<
title
></
title
>
</
head
>
<
style
type
=
"text/css"
>
*{margin:0; padding:0; list-style:none; font:normal 12px/150% 宋体; }
body{ padding:20px; }
.arrow{ margin-bottom:20px; }
/* css三角形 */
.arrow,.arrow s { position:relative; display:block; font-size: 0; line-height: 0; width: 0; height: 0; border-color:transparent; border-style:dashed; border-width:5px; }
.arrowR,.arrowR s{ border-left-color:#aaa; border-left-style:solid; }
.arrowR s{ border-left-color:#fff; position:absolute; left:-7px; top:-5px; }
.arrowR:hover{ border-left-color:#f60; }
.arrowL,.arrowL s{ border-right-color:#aaa; border-right-style:solid; }
.arrowL s{ border-right-color:#fff; position:absolute; right:-7px; top:-5px; }
.arrowL:hover{ border-right-color:#f60; }
.arrowT,.arrowT s{ border-bottom-color:#aaa; border-bottom-style:solid; }
.arrowT s{ border-bottom-color:#fff; position:absolute; left:-5px; top:-3px; }
.arrowT:hover{ border-bottom-color:#f60; }
.arrowB,.arrowB s{ border-top-color:#aaa; border-top-style:solid; }
.arrowB s{ border-top-color:#fff; position:absolute; left:-5px; bottom:-3px; }
.arrowB:hover{ border-top-color:#f60; }
/* css圆形 */
.circle{ line-height:100%; overflow:hidden; font-family:Tahoma,Helvetica; font-size:18px; color:#aaa; }
.circle:hover{ color:#f60; }
/* 提示盒子 */
.tipBox{ width:200px; margin-top:10px; }
.tipBox .hd{ height:5px; position:relative; }
.tipBox .hd .arrow{ position:absolute; top:-5px; left:10px; }
.tipBox .hd .arrow s{ top:-4px; }
.tipBox .bd{ border:1px solid #aaa; padding:10px; -webkit-border-radius:5px; -moz-border-radius:5px; border-radius:5px; }
.tipBoxA .arrow s{ border-bottom-color:#f6f6f6; }
.tipBoxA .bd{ background:#f6f6f6; }
</
style
>
<
body
>
<
a
class
=
"arrow arrowR"
></
a
>
<
a
class
=
"arrow arrowL"
></
a
>
<
a
class
=
"arrow arrowT"
></
a
>
<
a
class
=
"arrow arrowB"
></
a
>
<
a
class
=
"arrow arrowR"
><
s
></
s
></
a
>
<
a
class
=
"arrow arrowL"
><
s
></
s
></
a
>
<
a
class
=
"arrow arrowT"
><
s
></
s
></
a
>
<
a
class
=
"arrow arrowB"
><
s
></
s
></
a
>
<
a
class
=
"circle"
>•</
a
>
<
div
class
=
"tipBox"
>
<
div
class
=
"hd"
>
<
s
class
=
"arrow arrowT"
><
s
></
s
></
s
>
</
div
>
<
div
class
=
"bd"
>
用css做的提示盒子,上三角是纯css,盒子圆角用到css3
</
div
>
</
div
>
<
div
class
=
"tipBox tipBoxA"
>
<
div
class
=
"hd"
>
<
s
class
=
"arrow arrowT"
><
s
></
s
></
s
>
</
div
>
<
div
class
=
"bd"
>
用css做的提示盒子,上三角是纯css,盒子圆角用到css3
</
div
>
</
div
>
</
body
>
</
html
>
css三角原理可以看看这里:
http://www.bobd.cn/design/web/htmlcss/201009/43881.html
相关文章推荐
- 追求极致--纯css制作三角、圆形按钮,兼容ie6
- 使用css制作三角,兼容IE6,用到的标签&lt;div&gt;&lt;s&gt;&lt;span&gt;
- 使用css制作三角,兼容IE6,用到的标签<div><s><span>
- 使用css制作三角,兼容IE6,用到的标签<div><s><span>
- CSS制作三角箭头(兼容IE6)
- 纯css制作带三角border篇(兼容所有浏览器)
- CSS使用菱形◆制作气泡对话框(兼容IE6 IE9)
- CSS border制作小三角形状及应用(兼容IE6)
- 利用css中的border生成三角,兼容包括IE6的主流浏览器
- 纯css制作带三角(兼容所有浏览器)
- css border制作小三角形状及应用(兼容IE6)
- 利用css中的border生成三角,兼容包括IE6的主流浏览器
- css实现三角箭头(兼容IE6)
- 利用css中的border生成三角,兼容包括IE6的主流浏览器
- 纯css制作带三角border篇(兼容所有浏览器)
- CSS实现三角兼容ie6
- 纯CSS制作圆角按钮,不需图片,兼容各浏览器
- css写三角兼容ie6
- 纯css制作带三角border篇(兼容所有浏览器)
- 利用float制作兼容ie6纯css下来菜单,无table、无js