CSS 制作三角形原理剖析
使用css制作三角形其实原理很简单,下面一步步解析。
1、html代码如下
<div class="triangle">
</div>
2、CSS代码
.triangle{ width: 200px;
height: 200px;
border: solid 40px red;
}
不错,这里显示是一个正方形,如下
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAWcAAAFfCAIAAAAd85oaAAAK70lEQVR4nO3UwY0cUAzD0Om/6UkBixz+weIGeQQLkAHJny8AvPCpAwD4x/A1ALzx+X5I8oe+Bsk3fQ2Sb/oaJN/0NUi+6WuQfNPXIPmmr0HyTV+D5Ju+Bsk3fQ2Sb/oaJN/0NUi+6WuQfNPXIPmmr0HyTV+D5Ju+Bsk3fQ2Sb/oaJN/0NUi+6WuQfNPXIPmmr0HyTV+D5Ju+Bsk3fQ2Sb/oaJN/0NUi+6WuQfNPXIPmmr0HyTV+D5Ju+Bsk3fQ2Sb/oaJN/0NUi+6WuQfNPXIPmmr0HyTV+D5Ju+Bsk3fQ2Sb/oaJN/0NUi+6WuQfNPXIPmmr0HyTV+D5Ju+Bsk3fQ2Sb/oaJN/0NUi+6WuQfNPXIPmmr0HyTV+D5Ju+Bsk3fQ2Sb/oaJN/0NUi+6WuQfNPXIPmmr0HyTV+D5Ju+Bsk3fQ2Sb/oaJN/0NUi+6WuQfPP/+hrAnrz2wx3VybbXAlfktR/uqE62vRa4Iq/9cEd1su21wBV57Yc7qpNtrwWuyGs/3FGdbHstcEVe++GO6mTba4Er8toPd1Qn214LXJHXfrijOtn2WuCKvPbDHdXJttcCV+S1H+6oTra9Frgir/1wR3Wy7bXAFXnthzuqk22vBa7Iaz/cUZ1sey1wRV774Y7qZNtrgSvy2g93VCfbXgtckdd+uKM62fZa4Iq89sMd1cm21wJX5LUf7qhOtr0WuCKv/XBHdbLttcAVee2HO6qTba8FrshrP9xRnWx7LXBFXvvhjupk22uBK/LaD3dUJ9teC1yR1364ozrZ9lrgirz2wx3VybbXAlfktR/uqE62vRa4Iq/9cEd1su21wBV57Yc7qpNtrwWuyGs/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BFXvvhjupk22uBK/LaD3dUJ9teC1yR1364ozrZ9lrgirz2wx3VybbXAlfktR/uqE62vRa4Iq/9cEd1su21wBV57Yc7qpNtrwWuyGs/3FGdbHstcEVe++GO6mTba4Er8toPd1Qn214LXJHXfrijOtn2WuCKvPbDHdXJttcCV+S1H+6oTra9Frgir/1wR3Wy7bXAFXnthzuqk22vBa7Iaz/cUZ1sey1wRV774Y7qZNtrgSvy2g93VCfbXgtckdd+uKM62fZa4Iq89sMd1cm21wJX5LUf7qhORvJ36muQfNPXIPmmr0HyTV+D5Ju+Bsk3fQ2Sb/oaJN/0NUi+6WuQfNPXIPmmr0HyTV+D5Ju+Bsk3fQ2Sb/oaJN/0NUi+6WuQfNPXIPmmr0HyTV+D5Ju+Bsk3fQ2Sb/oaJN/0NUi+6WuQfNPXIPmmr0HyTV+D5Ju+Bsk3fQ2Sb/oaJN/0NUi+6WuQfNPXIPmmr0HyTV+D5Ju+Bsk3fQ2Sb/oaJN/0NUi+6WuQfNPXIPmmr0HyTV+D5Ju+Bsk3fQ2Sb/oaJN/0NUi+6WuQfNPXIPmmr0HyTV+D5Ju+Bsk3fQ2Sb/oaJN/0NUi+6WuQfNPXIPmmr0HyTV+D5Ju+Bsk3fQ2Sb/oaJN/0NUi+6WuQfNPXIPmmr0Hyzb/zBwWecBxH5ORvAAAAAElFTkSuQmCC" alt="" />
3、下面改变个边框颜色
.triangle{ width: 200px;
height: 200px;
border-bottom: solid 40px #0000FF;
border-top: solid 40px #000000;
border-right: solid 40px #FF0000;
border-left: solid 40px #00FF00;
}
显示效果如下
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAWIAAAFlCAIAAABeO3WVAAAMfUlEQVR4nO2UW24tRxLEzk4nd3Znp5ofeyDZks4rulkVTYILqASiePsQEfmVG/0AEVkdMyEidzATInIHMyEidzATInIHMyEid7jd/txERD4zt9vXTFgKEfnE3G4f32TCUojI7Xb7fyO+z4SlELk886kHP2TCUohcmPkag58zYSlELsn8qwS/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pejMhI1Q2qpSFGbCRuga9pSiLRM2QleypBRVmbARup4NpejJhI3QVd2+FCWZsBG6tnuXoiETNkJ3cONSbJ8JG6H7uGsp9s6EjdDd3LIUG2fCRuie7leKXTNhI3RnNyvFlpmwEbq/O5Viv0zYCG1xm1JslgkboV3uUYqdMmEjtNENSrFNJmyE9rp6KfbIhI3QdpcuxQaZsBF6DdctxeqZsBF6JRctxdKZsBF6PVcsxbqZsBF6VZcrxaKZsBF6bdcqxYqZsBGqS5ViuUzYCNW/XaUUa2XCRqh+dYlSLJQJG6H6nXwpVsmEjVD9WbgUS2TCRqjekywFnwkbofqYWCngTNgI1WdkSkFmwkaoPi9QCiwTNkL1Vc8uBZMJG6H6nqeWAsiEjVBNeF4pzs6EjVDNeVIpTs2EjVBNe0YpzsuEjVA9xsNLcVImbITqkR5bijMyYSNUj/fAUhyeCRuhepZHleLYTNgI1XM9pBQHZsJGqBLmS3FUJmyEKme4FIdkwkao0iZLkc+EjVBdw1gpwpmwEaormSlFMhM2QnU9A6WIZcJGqK7qu6XIZMJGqK7tW6UIZMJGqO7g66V4NxM2QnUfXyzFW5mwEaq7+UopXs+EjVDd06dL8WImbITqzj5XilcyYSNU9/eJUjydCRuh2uKjpXguEzZCtcuHSvFEJmyEaqP3S/FoJmyEaq93SvFQJmyEaru/leJ+JmyE6jX8sRR3MmEjVK/k96X4LRM2QvV6flOKHzNhI1Sv6j9L8X0mbITqtf1Sim8yYSNU9XMp/pkJG6Gqf/tXKb5kwkao6lfn9udzJv4HQF0ETm9LKDMAAAAASUVORK5CYII=" alt="" />
这里可能会感觉很奇怪,为什么四个角上的变成了斜的,下面在做一下变换
4、稍作变化,去掉上边框
.triangle{ width: 200px;
height: 200px;
border-bottom: solid 40px #0000FF;
border-right: solid 40px #FF0000;
border-left: solid 40px #00FF00;
}
显示效果如下
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAWYAAAFkCAIAAACcjAZKAAAMHUlEQVR4nO2UQW4sVRTFslPYGew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5ZjZsko17kmZ5XjTsko17kyR5WjeOTUS/yfE+qxtnJqBd5F4+pxsHJqBd5L8+oxqnJqBd5Rw+oxpHJqBd5X69ejfOSUS/y7l66Goclo17khtetxknJqBe55EWrcUwy6kXuecVqnJGMepGrXq4aBySjXuS216rG1ZNRLzIvVY1LJ6NeZP7tVapx3WTUi8wfvUQ1LpqMepH5M/1qXDEZ9SLzfeVqXC4Z9SLzI81qXCsZ9SLzc2rVuFAy6kXmIzrVuEoy6kXm4wrVuEQy6kXmV311Nfxk1IvM7/nSasjJqBeZhK+rhpmMepHJ+aJqaMmoF5m0r6iGk4x6kfkcn14NIRn1IvOZPrcar05Gvch8vk+sxkuTUS8yX+WzqvG6ZNSLzNf6lGq8KBn1ItOQr8YrklEvMj3hajw9GfUi05asxnOTUS8yryFWjScmo15kXkmmGs9KRr3IvJ5ANZ6SjHqReVW/Ww0+GfUi89p+qxpwMupF5gl+vRpkMupF5jl+sRpYMupF5ml+pRpMMupF5pk+XA0gGfUi82Qfq8Z3k1EvMs/3gWp8Kxn1IvMufrYaX09Gvci8l5+qxheTUS8y7+jH1fhKMupF5n39oBoPJ6NeZN7d/6vGY8moF5kbvluNB5JRLzKX/Hk1PpuMepG550+q8alk1IvMVf9djY+TUS8yt/2hGh8ko15k5j+r8X/JqBeZ+bd/VePdZNSLzPzRX99+ezcZ732IiPgvJSMiHuBPa+w2Qe/ajXgAAAAASUVORK5CYII=" alt="" />
可以看出,浏览器渲染时,针对边框角处理,以left和top为例说明:如果top 和left同时存在,各显示一部分;如果只有left,left边框才会显示为矩形角。
5、现在缩小div宽度和高度
.triangle{ width: 150px;
height: 90px;
border-bottom: solid 40px #0000FF;
border-top: solid 40px #000000;
border-right: solid 40px #FF0000;
border-left: solid 40px #00FF00;
}
显示效果如下
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQsAAACyCAIAAADahX0MAAAFg0lEQVR4nO3VWZLbQAwEUd7UuNn4pvSX5RlZanFBd2HJjDqAGI0X2n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KiCpIwQeIZceSREh8Ai83EgqCIFH+CVGkl4IPJIsK5LcQuCRaimRJBYCj4TLhySrEHikXTIkKYXAI/kyIcknBB4llgZJMiHwKLQcSDIJgUe5JUCSRgg8ii46khxC4FF6oZEkEAKPBouLJLoQeLRZUCShhcCj2SIiiSsEHi0XDklQIfBovFhIIgqBR/sFQhJOCDzYtm9xkMQSAg/2bSGQBBICD/bf9EiiCIEHezMxkhBC4MGGUyLRC4EHOzAZErEQeLDD0yBRCoEHOzkBEpkQeLBLW41EIwQe7MaWIhEIgQe7vXVIVguBB3PaIiRLhcCDuW4FknVC4MEmbDqSRULgwaZtLpIVQuDBJm8ikulC4MGWbBaSuULgwRZuCpKJQuDBls8fySwh8GCiOSOZIgQeTDpPJP5C4MECzA2JsxB4sDDzQeIpBB4s2ByQuAmBBwu5u0h8hMCDBd4tJA5C4MHC7zqSu0LgwZLsIpJbQuDBUu0KkutC4MES7jSSi0LgwdLuHJIrQuDBku8EktNC4MFK7CiSc0LgwQrtEJITQuDByu0zkqNC4MGK7gOSQ0LgwUpvhOSzEHiwBnuL5IMQeLA2e41kJAQerNleIHkrBB6s5Z6RvBYCD9Z4P5C8EAIP1n7/kDwLgQdj2749kDwLUf8sxuLMtq9nITsRvQ8hRKMQQjQKIUSjEEI0CiFEoxBCNAohRKMQQjQKIUSj/gCRa2rVa7eTFQAAAABJRU5ErkJggg==" alt="" />
可以理解,当宽度和高度同时变为0时,就是如下效果
.triangle{ width:;
height:;
border-bottom: solid 40px #0000FF;
border-top: solid 40px #000000;
border-right: solid 40px #FF0000;
border-left: solid 40px #00FF00;
}
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJIAAACSCAIAAAAhGQTZAAAEF0lEQVR4nO3TS26sQBBE0dqpc2ftnfYb5LPstqGhqPxFEqE7QIxQHjGeHOBG9gdwV0Y2yJENcmSD3BiPwVWejI1fawzKFZ6M8dxlo1zJyRfOPhvlik1+yLxlo1yZySvLERvlCkz+mJxgo1zqZAvkH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DSzaFpuiY1mds3JXWejmXUTchfZaObTWbkrbDTz7JTcNBvN/DuWm2OjWVQHchNsNIvtndxZNppltCt3io1meW3LHbPRLLsNuQM2mtXot9w7NppV6kVul41m9fqW22ajWdX+y22w0ax2Mh4bbH9fcfX3D8QmPvwJA2dXAAAAAElFTkSuQmCC" alt="" />
6、这时候如果只留一个边框有颜色,其他边框变成透明的话,就成了三角形了
.triangle{ width:;
height:;
border-bottom: solid 40px transparent;
border-top: solid 40px #000000;/*只留上边框有颜色,其他边框透明*/
border-right: solid 40px transparent;
border-left: solid 40px transparent;
}
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJEAAACYCAIAAABrtZy8AAAC80lEQVR4nO3cSW7DQAwFUd/UR/NRf3ZB4HjQ0AOrVXUCAQ+QtCB5i9G6zX4A251mvDTjpRkvzXhpxkszXrfH43Gzwt3v92ezJLKV7T9Yft+NshXsJVj+fs9kK9U7sDz9g8hWpA9gz2ayVegz2Asz2eb2Fey1mWyz2gL21ky28W0E+2Qm28i2g30xk21Mu8C+m8nWu71gm8xk69cBsK1msvXoGNgOM9nadhhsn5lsrToDtttMtvOdBDtiJtuZzoMdNJPtWE3AjpvJtrdWYKfMItvmGoLl/NyVbF9rC5Yms3Kyfag5WFrNN8r2sh5gaTiTKttTncDSdo5Ytt/6gaX57Ldst85g6TGvf3G23mDptGNxWbYBYOm3F3NBtjFg6brLdCm2YWDpvX92EbaRYBmwM7g822CwjNnzXJhtPFiG7eYuyTYFLCP3qRdjmwWWwTvwy7BNBMv4uwULsM0Fy5RbE2i26WCZdR8EylYBLBNvuuDYioBl7h0eEFsdsEy/nYRgKwWW6WYpz1YNLBXMUpitIFiKmKUkW02w1DFLMbayYCllljJslcFSzSwF2IqDpaBZprLVB0tNs0xiQ4ClrFmGs1HAUtksA9lAYCluliFsLLDUN0tnNhxYEGbpxkYEC8UsHdigYAGZpSkbFywsszRiQ4MFZ5bTbHSwEM1ygm0BsEDNcohtDbBwzbKTbRmwoM2ymW0lsNDNsoFtMbAsYJaPbOuBZQ2zvGFbEizLmOUf26pgWcksf9gWBstiZkkej8faYFnP7AppxkszXprx0oyXZrw046UZL814acZLM16a8dKMl2a8NOOlGS/NeGnGSzNemvHSjJdmvDTjpRkvzXhpxkszXprx0oyXZrw046UZL814acZLM16a8dKMl2a8NOOlGS/NeGnGSzNemvHSjJdmvDTjpRkvzXhpxkszXprx0oyXZrw046UZL814acZLM16a8dKMl2a8NOOlGS/NeGnGSzNemvHSjJdmvDTjpRkvzXhpxusHJ/YeC119Um4AAAAASUVORK5CYII=" alt="" />
CSS 制作三角形原理剖析的更多相关文章
- CSS制作三角形和按钮
CSS制作三角形和按钮 用上一篇博文中关于边框样式的知识点,能制作出三角形和按钮. 我先说如何制作三角形吧,相信大家在平时逛网站的时候都会看到一些导航栏中的三角形吧,比如说: 网易首页的头部菜单栏中, ...
- 用css制作三角形
用css制作三角形,主要是利用css元素给“盒模型”设置边框得到的. 上图,上边框和做边框,以及上边框和右边框的交合处,浏览器会按照直角的二分之一处绘制交合线.这是“盒模型”有宽和高时候的效果.我们假 ...
- css制作三角形,下拉框三角形
网站制作中常常需要下拉框,而如果下拉框如果只是单纯的矩形则会显得太过单调,所以这次教大家利用css制作三角形放在矩形上面 首先利用css制作三角形 div { width:0px; height:0p ...
- css绘制三角形原理
1.新建一个元素,将它的宽高都设置为0:然后通过设置border属性来实现三角形效果,下面是css绘制三角形的原理: <!DOCTYPE html> <html> <he ...
- css画三角形原理解析
<div id="div1"></div><div id="div2"></div><div id=&qu ...
- 利用CSS制作三角形
在我们看到类似于这样的图片时: 我们一般都会想,哎,这还不简单,用一张图片就可以了. 的确,用图片可以很轻松地做到.不过我们接下来要讨论的是: 如何用css也作出这样的效果. 首先,我们来定义一个 ...
- 利用border制作三角形原理
网站前端页面中,有时候会使用一些三角形,除了使用图片的方式之外,利用css的border属性也可以做出相对应的三角形.那么,利用border是如何实现三角形的制作的呢? 先看下面一个例子: CSS代码 ...
- css制作三角形
#triangle-up { width: 0; height: 0; border-left: 50px solid transparent; border-right: 50px solid tr ...
- css 制作三角形图标 不支持IE6
.triangle { width: 10px; height: 10px; overflow: hidden; border-left: 4px solid rgba(, , , ); border ...
随机推荐
- 教你分分钟学会用python爬虫框架Scrapy爬取心目中的女神
本博文将带领你从入门到精通爬虫框架Scrapy,最终具备爬取任何网页的数据的能力.本文以校花网为例进行爬取,校花网:http://www.xiaohuar.com/,让你体验爬取校花的成就感. Scr ...
- jQuery CSS操作及jQuery的盒子模型
jQuery CSS-jQuery CSS方法 jQuery CSS-jQuery盒子模型
- JavaSE基础第一篇
1.JDK的安装: 包括JRE 和JVM 下载地址: www.oracle.com/www.sun.com 2.环境变量 set path = "bin所在路径" 设置pa ...
- android手机和ios手机的分辨率
Android手机目前常见的分辨率 1.1 手机常见分辨率: 4:3 VGA 640*480 (Video Graphics Array) QVGA 320*240 (Quarter VGA ...
- 易语言调用windows消息函数
1.SendMessageCallbackA的调用方法 .版本2 .DLL命令 发送消息返回_, 整数型, "user32.dll", "SendMessageCallb ...
- android sdk manager国内无法更新的解决办法
- Java中关于先有鸡还是先有蛋的问题----Class&Object
在Java中,我们常常会看到一个类型:Class.并且在类似Person.class,cache.getClass()等代码中见到它的身影. 众所周知,Class是用来描述一个类的类型,而Object ...
- nis,nfs,pam小结
最近一周总算把nis/nfs配置起来,中间各种被坑,这里简单记录一下: 主要参考两个大牛的文章,柏青哥,鸟哥 配置完之后的功能是可以连接任意一台主机,所有主机之间共享HOME目录,而且每人都有一定的限 ...
- Apache部署django项目
在此之前,我们一直使用django的manage.py 的runserver 命令来运行django应用,但这只是我们的开发环境,当项目真正部署上线的时候这做就不可行了,必须将我们的项目部署到特定的w ...
- BabelMap 9.0.0.3 汉化版(2016年12月27日更新)
软件简介 BabelMap 是一个免费的字体映射表工具,可辅助使用<汉字速查>程序. 该软件可使用系统上安装的所有字体浏览 Unicode 中的十万个字符,还带有拼音及部首检字法,适合文献 ...