http://ourjs.com/detail/532bc9f36922aa7e1d000001
2015-07-29 21:20
399 查看
<div id="demo11"></div> <style> #demo11 { border: 10px solid #000; border-left-color: #f00; width: 10px; height: 10px; } </style>
一个三角形
当元素宽、高为零,且其他边为透明颜色时,可以形一个三角形。<div id="demo12"></div> <style> #demo12 { border: 10px solid #000; border-left-color: #f00; width: 0; height: 0; } </style>
任意角度的三角形
改变各个边的宽度,即通过调整“边框”厚度可以配置出任意角度<div id="demo14"></div> <style> #demo14 { border: 10px solid transparent; border-left: 20px solid #f00; width: 0; height: 0px; } </style>
通过伪元素实现
三角形可以通过伪元素绘制出,而无需改变原来的DOM结构文字内容
<span id="demo15">文字内容</span> <style> #demo15{ position: relative; } #demo15:after { border: 10px solid transparent; border-left: 10px solid #f00; width: 0; height: 0; position: absolute; content: ' ' } </style>
伪元素实现三角线箭头
通过伪元素绘制出的两个,一个与背景色相同覆盖部分红色箭头,形成三角线文字内容
<span id="demo15">文字内容</span> <style> #demo16{ position: relative; } #demo16:after, #demo16:before { border: 10px solid transparent; border-left: 10px solid #fff; width: 0; height: 0; position: absolute; top: 0; right: -20px; content: ' ' } #demo16:before { border-left-color: #f00; right: -21px; } </style>
三角线分割的Tab页
文字内容 Tab1文字内容 Tab2
文字内容 Tab3
<ul id="demo17"> <li>文字内容 Tab1</li> <li>文字内容 Tab2</li> <li>文字内容 Tab3</li> </ul> <style> #demo17{ font-size: 10px; height: 24px; } #demo17 li { float: left; position: relative; list-style: none; margin: 0 20px 12px -19px; border-top: solid 1px #ddd; border-bottom: solid 1px #ddd; padding-left: 12px; } #demo17 li:after, #demo17 li:before { border: 10px solid transparent; border-left: 10px solid #fff; width: 0; height: 0; position: absolute; top: 0; right: -18px; content: ' ' } #demo17 li:before { border-left-color: #ddd; right: -19px; } </style>
三角形跟矩形组合成提示框
这里还有另一种效果,使用三角形跟矩形组合成提示框,代码来自这篇文章:Css arrows and shapes without markup
<div id="demo"></div> <style> #demo { width: 100px; height: 100px; background-color: #ccc; position: relative; border: 4px solid #333; } #demo:after, #demo:before { border: solid transparent; content: ' '; height: 0; left: 100%; position: absolute; width: 0; } #demo:after { border-width: 9px; border-left-color: #ccc; top: 15px; } #demo:before { border-width: 14px; border-left-color: #333; top: 10px; } </style>
相关文章推荐
- Aircrack-ng指导教程
- LINK1123:failure during conversion to COFF:file invalid or corrupt
- HDU 5046 Airport
- The Brain vs Deep Learning Part I: Computational Complexity — Or Why the Singularity Is Nowhere Near
- The Brain as a Universal Learning Machine
- 2015 Multi-University Training Contest 3 1008
- 2015 Multi-University Training Contest 3 1002 RGCDQ
- ZOJ 3450 Doraemon's Railgun
- debug : StartService failed, getlasterror = 0x7f(127) 转
- Failure [INSTALL_FAILED_OLDER_SDK] [每件问题100块]
- 多校赛3- Painter
- 多校赛3- Painter 分类: 比赛 2015-07-29 19:58 3人阅读 评论(0) 收藏
- dlopen failed: "*.so" has unexpected e_machine
- EAGAIN、EWOULDBLOCK、EINTR与非阻塞 长连接
- hdu-5316 Magician (2015 Multi-University Training Contest 3)
- HUAS Summer Trainning #3~A
- UVa 10651 Pebble Solitaire(状态压缩DP)
- HTTP1.1中CHUNKED编码解析 http://blog.csdn.net/zhangboyj/article/details/6236780
- 2015多校第一场1006 hdu 5293 Tree chain problem
- Core Animaiton - 7