直接上代码,不多说了!

画三角形

1)、

<style type="text/css">
.triangle{
width: 0;
height: 0;
/*border: 50px transparent solid;*//*当没有这句时,至少有2个方向的边框才能成形,比如下面的一组*/ border-top: 50px solid black;
border-right: 50px solid purple;
/*border-bottom: 50px solid blue;
border-left: 50px solid red;*/
}
</style>
<div class="triangle"></div>

  

2)、

<style type="text/css">
.triangle1{
width: 0;
height: 0;
border: 50px transparent solid;/*transparent表示边框颜色是透明的,solid表示边框是实线的*/
border-top-color: black;
border-bottom-color: black;
}
</style>
<div class="triangle1"></div>

  

3)、类似QQ或微信中的提示框,带有三角形的框

<style type="text/css">
.wechat-triangle{
position: relative;
width: 150px;
height: 36px;
border: 1px solid black;
border-radius: 5px;
background: rgba(245, 245, 245, 1);
} /*.wechat-triangle:before{
content: "";
display: block;
position: absolute;
top: 8px;
width: 0;
height: 0;
border: 6px transparent solid;
left: -12px;
border-right-color: rgba(245,245,245,1);
}*/ .wechat-triangle:before, .wechat-triangle:after{
content: "";
display: block;
position: absolute;
top: 8px;
width: 0;
height: 0;
border: 6px transparent solid;
} .wechat-triangle:before{
left: -11px;
border-right-color: rgba(245,245,245,1);
z-index: 1;
} .wechat-triangle:after{
left: -12px;
border-right-color: rgba(0,0,0,1);
z-index: 0;
} .wechat-triangle1{
width: 120px;
height: 30px;
position: relative;
border: 1px solid black;
border-radius: 5px;
background: rgba(245,245,245,1);
} .wechat-triangle1:before, .wechat-triangle1:after{
content: "";
width: 0;
height: 0;
display: block;
position: absolute;
top: 5px;
border: 4px transparent solid;
} .wechat-triangle1:before{
left: -8px;
border-right-color: rgba(245,245,245,1);
z-index: 1;
} .wechat-triangle1:after{
left: -9px;
border-right-color: rgba(0,0,0,1);
z-index: 0;
}
</style> <div class="wechat-triangle"></div>
<div class="wechat-triangle1"></div>

  其中rgba是由颜色与透明度组成,透明度是[0,1]。

4)、提示框,当鼠标放到上面时,就会有提示信息

<style>
.tip{
display: inline-block;
width: 100px;
height: 30px;
line-height: 30px;
text-align: center;
position: relative;
border: 1px solid #ccc;
cursor: pointer;
} .tip:before, .tip:after{
position: absolute;
opacity: 0;
} .tip:before{
content: '';
width: 0;
height: 0;
border-width: 6px;
border-style: solid;
border-color: #222 transparent transparent transparent;
top: -6px;
} .tip:after{
content: attr(data-tips);
white-space: nowrap;
font-size: 14px;
color: #fff;
background-color: #222;
top: -36px;
left: 5px;
border-radius: 6px;
padding: 0 10px;
text-shadow: 0 0 5px #000;
-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
-moz-box-sizing: boder-box;
-webkit-box-sizing: boder-box;
box-sizing: boder-box;
} .tip:hover:before, .tip:hover:after{
opacity: 1;
}
</style>
<div class="tip" data-tips="沉冤得雪魂归战场">琅琊榜</div>

css中的:before与:after的简单使用的更多相关文章

  1. css中的em 简单教程 -- 转

    先附上原作的地址: https://www.w3cplus.com/css/px-to-em 习惯性的复制一遍~~~~ -------------------------------我是分界线---- ...

  2. css中box-sizing简单说明(标准盒式模型和怪异盒式模型)

    今天写程序做布局的时候,遇到关于css中盒式模型的问题,百度了下这属性的解释,脑大啊,文字太绕看不懂.怎么办,于是自己动动手写了段程序测试,嗯,不错,一看效果就恍然大明白了.这里简单说明下,也可能说得 ...

  3. 简单聊聊CSS中的3D技术之“立方体”

    简单聊聊CSS中的3D技术之“立方体” 大家好,我是今天的男一号,我叫小博主. 今天来聊一下我在前端“逆战班”学习中遇到的颇为有趣的3D知识.前端学习3周,见识稀疏,在下面的分享中如有不对的地方请大家 ...

  4. css中的毛玻璃(不是透明度) 简单文档

    其实毛玻璃很简单 只需要在css中加入 backdrop-filter:blur(8px); 8px是模糊力度 注意:使用该方法前需要设置背景不能是透明(如果是显示这个元素下面的图像记得半透明,例子就 ...

  5. HTML和CSS设置动态导航以及CSS中伪元素的简单说明

    HTML页面代码: <!DOCTYPE html> <html> <head> <title>Test</title> <meta c ...

  6. 总结一下CSS中的定位 Position 属性

    在CSS中,Position 属性经常会用到,主要是绝对定位和相对定位,简单的使用都没有问题,尤其嵌套起来,就会有些混乱,今记录总结一下,防止久而忘之. CSS position 属性值: absol ...

  7. CSS中一些常见的兼容性问题

    CSS中一些兼容性问题就是浏览器兼容,而这些浏览器兼容问题主要是Ie和FF之间的争斗. CSS hack中的一些事: 我们为了让页面形成统一的效果,要针对不同的浏览器或不同版本写出对应可解析的CSS样 ...

  8. css中的负边距

    css中的负边距(negative margin)是布局中的一个常用技巧,只要运用得合理常常会有意想不到的效果.很多特殊的css布局方法都依赖于负边距,所以掌握它的用法对于前端的同学来说,那是必须的. ...

  9. css中单位px、pt、em和rem的区别

    国内的设计师大都喜欢用px,而国外的网站大都喜欢用em和rem,那么三者有什么区别,又各自有什么优劣呢? px :像素(Pixel).相对长度单位.像素px是相对于显示器屏幕分辨率而言的.(引自CSS ...

随机推荐

  1. win8.1环境下硬盘安装centos6.5双系统

    作为一名软件工程师或是相关行业的从业人员,经常会用到linux系统,这里为大家介绍的安装linux的方案是在原有win环境下安装linux双系统,两个系统选择分别为win8.1 和centos6.5. ...

  2. linux的7种运行级别

    Linux有7个运行级别(runlevel)运行级别0:系统停机状态,系统默认运行级别不能设为0,否则不能正常启动运行级别1:单用户工作状态,root权限,用于系统维护,禁止远程登陆运行级别2:多用户 ...

  3. 初步了解SequoiaDB数据库

    随着企业中日益复杂与多变的需求,以及迅速扩展带来的海量数据的业务,IT部门需要将越来越多的信息提供给用户,同时在现今的全球经济背景环境下,IT部 门还需要在提供高效服务的同时,降低其设备与程序维护成本 ...

  4. sql拆分查询

    有这样一个需求: 临时表sql: create table #AA ( ID int, Name nvarchar(20) ) insert #AA select 1,'苏州/上海/温州' union ...

  5. Mysql备份--mysqldump&outfile

    1.备份工具mysqldump 客户端和服务器端都能用select outfile 只能写到服务器端 2.按表单位备份 a.单个表备份 mysqldump -uusername -p database ...

  6. Error NO.2013 Lost connection to Mysql server during query

    系统:[root@hank-yoon ~]# cat /etc/redhat-release CentOS release 6.3 (Final) DB版本:mysql> select @@ve ...

  7. 安装gcc及开发环境

    安装gcc及开发环境================================> 安装gcc:     * apt-get install build-essential    * gcc ...

  8. 【Python】 最简单的web服务

    python -m SimpleHTTPServer  8321 1.python 没有指定目录的参数 想启动目录 就cd到该目录下 2.在目录下创建一个index.html 3.启动web服务,(端 ...

  9. POJ 3321 DFS序+线段树

    单点修改树中某个节点,查询子树的性质.DFS序 子树序列一定在父节点的DFS序列之内,所以可以用线段树维护. 1: /* 2: DFS序 +线段树 3: */ 4:   5: #include < ...

  10. mvc异步表单遇到的问题

    1,mvc异步表单遇到的问题    问题:使用jqury easy ui 时提交异步数据不能请求到服务器   解决办法:经过细心调试和检测,发现jqury的加载顺序放在了easy ui之后,所以首先加 ...