利用border属性制作各种图形。
这是一个比较正常的
但如果我们把宽度和高度去掉呢?
好像看不太出来对吧,我们来给边框加上不同颜色。
看出啥了没,分明就是每个边都是一个三角形啊。
那假如我想要一个朝下的三角形是不是我只要把border-top给显示出来,其他的隐藏就好了啊。OK,说干就干
transparent表示透明,所以可以当做隐藏来使用。你可能会说那直接只设置border-top不就好了吗,但你可以发现是不行的,你试试就知道了。
单个:
代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
#item1{
width:0px;
height:0px;
border:30px solid transparent;
border-top:30px solid red;
}
#item2{
width:0px;
height:0px;
border:30px solid transparent;
border-left:30px solid green;
}
#item3{
width:0px;
height:0px;
border:30px solid transparent;
border-bottom:30px solid pink;
}
#item4{
width:0px;
height:0px;
border:30px solid transparent;
border-right:30px solid lightblue;
}
</style>
</head>
<body>
<div id="item1"></div>
<div id="item2"></div>
<div id="item3"></div>
<div id="item4"></div>
</body>
</html>
两个组合:
代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
#item1{
width:0px;
height:0px;
border:30px solid transparent;
border-top:30px solid red;
border-right:30px solid red;
}
#item2{
width:0px;
height:0px;
border:30px solid transparent;
border-top:30px solid green;
border-left:30px solid green;
}
#item3{
width:0px;
height:0px;
border:30px solid transparent;
border-top:30px solid pink;
border-bottom:30px solid pink;
}
#item4{
width:0px;
height:0px;
border:30px solid transparent;
border-right:30px solid lightblue;
border-bottom:30px solid lightblue;
}
#item5{
width:0px;
height:0px;
border:30px solid transparent;
border-right:30px solid lightsalmon;
border-left:30px solid lightsalmon;
}
#item6{
width:0px;
height:0px;
border:30px solid transparent;
border-bottom:30px solid red;
border-left:30px solid red;
}
</style>
</head>
<body>
<div id="item1"></div>
<div id="item2"></div>
<div id="item3"></div>
<div id="item4"></div>
<div id="item5"></div>
<div id="item6"></div>
</body>
</html>
三个组合:
代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
#item1{
width:0px;
height:0px;
border-left:30px solid transparent; border-top:30px solid red;
border-right:30px solid red;
border-bottom:30px solid red;
}
#item2{
width:0px;
height:0px;
border-bottom:30px solid transparent; border-top:30px solid green;
border-right:30px solid green;
border-left:30px solid green;
}
#item3{
width:0px;
height:0px;
border-right:30px solid transparent; border-top:30px solid pink;
border-left:30px solid pink;
border-bottom:30px solid pink;
}
#item4{
width:0px;
height:0px;
border-top:30px solid transparent; border-right:30px solid lightblue;
border-left:30px solid lightblue;
border-bottom:30px solid lightblue;
}
</style>
</head>
<body>
<div id="item1"></div>
<div id="item2"></div>
<div id="item3"></div>
<div id="item4"></div>
</body>
</html>
配合宽度使用。
注意宽度别超过边框长度。
平行四边形
完。
利用border属性制作各种图形。的更多相关文章
- css 利用border属性制作箭头 Using Borders to Make Pure CSS Arrows
不再需要多余的图片 用border属性自然能创造箭头效果 学习地址:http://tech.patientslikeme.com/2010/11/09/using-borders-to-make-pu ...
- 纯css3样式属性制作各种图形图标
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- CSS深入了解border:利用border画三角形等图形
三角形实际上是border的产物 我们正常使用的border都是四边一个颜色,当我们把四边换上不同颜色 那么你就会发现,三角来了~! <!DOCTYPE html> <html la ...
- 2017年总结的前端文章——border属性的多方位应用和实现自适应三角形
border属性是在实际的应用中使用频率比较高的一个属性,除了作为边框使用,利用border属性的一些特征以及表现方式,可以在实现一些比较常见的效果(如等高布局,上下固定内容滚动布局和绘制CSS图标等 ...
- 利用border制作三角形原理
网站前端页面中,有时候会使用一些三角形,除了使用图片的方式之外,利用css的border属性也可以做出相对应的三角形.那么,利用border是如何实现三角形的制作的呢? 先看下面一个例子: CSS代码 ...
- CSS border三角、圆角图形生成技术简介
http://www.zhangxinxu.com/wordpress/?p=794 一.前言 利用CSS的border属性可以生成一些图形,例如三角或是圆角.纯粹的CSS2的内容,没有兼容性的问题, ...
- 重温CSS:Border属性
边界是众所周知的,有什么新的东西吗?好吧,我敢打赌,在这篇文章中,有很多你不看永远不知道的东西! 不仅可以用CSS3来创建圆角,使用原有CSS一样可以显示自定义图形.这是正确的(有待考究):在过去,没 ...
- CSS:不可思议的border属性
原文:Magic of CSS border property 译文:不可思议的CSS border属性 译者:dwqs 在CSS中,其border属性有很多的规则.对于一些事物,例如三角形或者其它的 ...
- 利用Bootstrap框架制作查询页面的界面
UI设计实战篇——利用Bootstrap框架制作查询页面的界面 Bootstrap框架是一个前端UI设计的框架,它提供了统一的UI界面,简化了设计界面UI的过程(缺点是定制了界面,调整的余地不是太 ...
随机推荐
- (转)非常完善的Log4net详细说明
转自:http://www.cnblogs.com/zhangchenliang/p/4546352.htmlhttp://www.cnblogs.com/zhangchenliang/p/45463 ...
- linux修改主机名的方法
linux修改主机名的方法 用hostname命令可以临时修改机器名,但机器重新启动之后就会恢复原来的值. #hostname //查看机器名#hostname -i //查看本机器名对应的ip ...
- UVA 12299 RMQ with Shifts(线段树:单点更新)
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...
- 初学python第二天
今天我将用python来编写一款小游戏,用这个来总结一下自己学过的一些基础语法.没错,它就是井字游戏.想想自己第一接触这种游戏,还是小学生呢
- windows 7下qtcreator里QWT文件的pro配置
http://blog.chinaunix.net/uid-20717410-id-272331.html 把编译好的qwt的include文件夹下面 所有的.h文件 复制到qt目录下 然后在pro里 ...
- Python开源框架
info:更多Django信息url:https://www.oschina.net/p/djangodetail: Django 是 Python 编程语言驱动的一个开源模型-视图-控制器(MVC) ...
- testng参数化及用例排序
http://blog.sina.com.cn/s/blog_6966650401012ra0.html 一.一个简单的测试谷歌搜索 import org.testng.annotations.Tes ...
- 解决ie8(及其以下)不支持getElementsByClassName的问题
这篇技术笔记与大家分享的是:解决IE8(及以下)不支持getElementsByClassName的方法.如果有说错的地方,麻烦留言告诉我,我及时更正,一来是更新一下我的认知,二来也是不要误导的他人, ...
- css各项水平居中
当被设置元素为块状元素时用text-align:center就不起作用了,这也分两种情况,定宽块状元素和不定宽块状元素. 一.定宽块状元素:快状元素的宽度width为固定值,之后我们可以将左右marg ...
- java war包加载提示jar not loaded
今天在开发的时候,项目需要加载Guvnor的war包.War包部署后,启动tomcat提示jar not load 后来查阅资料后发现是Jar包冲突导致的,冲突的Jar包在tomcat中已经存在,然后 ...