本文主要包含CSS,三角形,箭头等相关知识,佚名 希望在学习及工作中可以帮助到您
最近我想修改一下这个网站,我想在上面放置一个提示框。这是很容易,但我想让提示框上有一个三角形的箭头。可是,一想到这需要使用图片,并且各种颜色,各种方向的箭头要准备无数种,这几乎是一种灾难。幸运的是,MooTools的核心开发着Darren Waddell告诉了我一个非常棒的技术:用CSS绘制三角形箭头。使用纯CSS,你只需要很少的代码就可以创作出各种浏览器都兼容的三角形箭头!
CSS代码
- /* create an arrow that points up */
- div.arrow-up {
- width: 0;
- height: 0;
- border-left: 5px solid transparent; /* left arrow slant */
- border-right: 5px solid transparent; /* right arrow slant */
- border-bottom: 5px solid #2f2f2f; /* bottom, add background color here */
- font-size: 0;
- line-height: 0;
- }
- /* create an arrow that points down */
- div.arrow-down {
- width: 0;
- height: 0;
- border-left: 5px solid transparent;
- border-right: 5px solid transparent;
- border-top: 5px solid #2f2f2f;
- font-size: 0;
- line-height: 0;
- }
- /* create an arrow that points left */
- div.arrow-left {
- width: 0;
- height: 0;
- border-bottom: 5px solid transparent; /* left arrow slant */
- border-top: 5px solid transparent; /* right arrow slant */
- border-right: 5px solid #2f2f2f; /* bottom, add background color here */
- font-size: 0;
- line-height: 0;
- }
- /* create an arrow that points right */
- div.arrow-rightright {
- width: 0;
- height: 0;
- border-bottom: 5px solid transparent; /* left arrow slant */
- border-top: 5px solid transparent; /* right arrow slant */
- border-left: 5px solid #2f2f2f; /* bottom, add background color here */
- font-size: 0;
- line-height: 0;
- }
绘制这些三角形的关键在于,你要