这是一个比较正常的

但如果我们把宽度和高度去掉呢?

好像看不太出来对吧,我们来给边框加上不同颜色。

看出啥了没,分明就是每个边都是一个三角形啊。

那假如我想要一个朝下的三角形是不是我只要把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属性制作各种图形。的更多相关文章

  1. css 利用border属性制作箭头 Using Borders to Make Pure CSS Arrows

    不再需要多余的图片 用border属性自然能创造箭头效果 学习地址:http://tech.patientslikeme.com/2010/11/09/using-borders-to-make-pu ...

  2. 纯css3样式属性制作各种图形图标

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. CSS深入了解border:利用border画三角形等图形

    三角形实际上是border的产物 我们正常使用的border都是四边一个颜色,当我们把四边换上不同颜色 那么你就会发现,三角来了~! <!DOCTYPE html> <html la ...

  4. 2017年总结的前端文章——border属性的多方位应用和实现自适应三角形

    border属性是在实际的应用中使用频率比较高的一个属性,除了作为边框使用,利用border属性的一些特征以及表现方式,可以在实现一些比较常见的效果(如等高布局,上下固定内容滚动布局和绘制CSS图标等 ...

  5. 利用border制作三角形原理

    网站前端页面中,有时候会使用一些三角形,除了使用图片的方式之外,利用css的border属性也可以做出相对应的三角形.那么,利用border是如何实现三角形的制作的呢? 先看下面一个例子: CSS代码 ...

  6. CSS border三角、圆角图形生成技术简介

    http://www.zhangxinxu.com/wordpress/?p=794 一.前言 利用CSS的border属性可以生成一些图形,例如三角或是圆角.纯粹的CSS2的内容,没有兼容性的问题, ...

  7. 重温CSS:Border属性

    边界是众所周知的,有什么新的东西吗?好吧,我敢打赌,在这篇文章中,有很多你不看永远不知道的东西! 不仅可以用CSS3来创建圆角,使用原有CSS一样可以显示自定义图形.这是正确的(有待考究):在过去,没 ...

  8. CSS:不可思议的border属性

    原文:Magic of CSS border property 译文:不可思议的CSS border属性 译者:dwqs 在CSS中,其border属性有很多的规则.对于一些事物,例如三角形或者其它的 ...

  9. 利用Bootstrap框架制作查询页面的界面

    UI设计实战篇——利用Bootstrap框架制作查询页面的界面   Bootstrap框架是一个前端UI设计的框架,它提供了统一的UI界面,简化了设计界面UI的过程(缺点是定制了界面,调整的余地不是太 ...

随机推荐

  1. 黑马程序员-scanf函数

    变量的内存:字节和地址:1.变量的存储单位是字节,每个字节都有存储地址.2.不同的数据大小占用的内存带下不同拥有的字节数也是不同的.变量的存储:1.存储是按照,先存储的放在地址教高的位置,优先存储的地 ...

  2. 前端学习之touch.js与swiper学习

    Touch.js是移动设备上的手势识别与事件库,改框架基于原生js,操作简单,主要分drag,swipe,rotate,scale,tab,hold,touch操作. swiper是一个移动端触摸滑动 ...

  3. 转:如何调试PHP的Core之获取基本信息

    其实一直想写这个系列, 但是一想到这个话题的宽泛性, 我就有点感觉无法组织. 今天我也不打算全部讲如何调试一个PHP的Core文件, 也不会介绍什么是Coredump, 选择一个相对比较简单的方向来介 ...

  4. c#后台进行窗体切换的方法

    Response.Redirect("http://localhost:60896/WebForm2.aspx");

  5. JDK和环境配置

    1. JASE : J2SE 这个就是我们现在在学的东西,他是一切Java的核心基础 JAME :J2ME : 他是Java的一个微型版,主要用来做移动开发 JAEE :J2EE Java企业版本,主 ...

  6. Eclipse不能自动编译 java文件

      在网上的解决方法 方法参考如下: (1) Window-->Preferences-->General-->Workspace  有个"Build automatica ...

  7. linux的一些小问题

    1.需要使用root权限时提示xxx is not sudoers.... 1).root用户下输入visudo 2).在打开的文件中找到 root ALL=(ALL) ALL,以xxx为用户名,添加 ...

  8. 单用户模式下修改root密码

    1.重启或者开机时,在倒数3秒的界面按下任意键. 2.该界面有如下提示(e 编辑 a 更改内核选项 c 命令行  b 启动),所以我们按下"e"编辑. 3.上下键选中第二行再按下& ...

  9. Centos6.6下安装MariaDB步骤,利用yum进行安装

    1.在/etc/yum.repos.d/下建立MariaDB.repo文件 可以在Win下编辑好此文件,然后通过SSH远程复制过去. 2.MariaDB.repo内容要根据MariaDB官方提供的re ...

  10. [渣译文] SignalR 2.0 系列:SignalR的服务器广播

    英文渣水平,大伙凑合着看吧…… 这是微软官方SignalR 2.0教程Getting Started with ASP.NET SignalR 2.0系列的翻译,这里是第八篇:SignalR的服务器广 ...