css实现小三角(原理)





这个div的样式如下所示:
- div{
- width: 0px;
- height: 0px;
- border-width: 20px;
- border-style: solid;
- border-color: lightgreen pink yellow lightblue;
- }


- #triangle{
- width: 0px;
- height: 0px;
- border-width: 20px;
- border-style: solid;
- border-color: transparent transparent yellow transparent;
- }
- #triangle{
- width: 0px;
- height: 0px;
- *width: 40px;
- *height: 40px;
- font-size:;
- line-height:;
- overflow: hidden;
- border-width: 20px;
- border-style: dashed dashed solid dashed;
- border-color: transparent transparent yellow transparent;
- }

t.png)


- border-style: solid dashed dashed dashed;
- border-color: lightgreen transparent transparent transparent;


- border-style: dashed solid dashed dashed;
- border-color: transparent pink transparent transparent;
右三角:

q.png)
- border-style: dashed dashed dashed solid;
- border-color: transparent transparent transparent lightblue;
- /* css */
- *{
- margin: 0px;
- padding: 0px;
- text-align: center;
- }
- #container{
- position: relative; //这句很重要,因为小三角是相对父元素#container来绝对定位的
- width: 50px;
- height: 40px;
- border:1px solid lightblue;
- margin: 200px auto;
- padding: 20px;
- }
- #chat{
- width: 50px;
- height: 40px;
- background-color: lightblue;
- }
- #triangle{
- position: absolute; //设置小三角绝对定位
- width: 0px;
- height: 0px;
- *width: 14px;
- *height: 14px;
- font-size:;
- line-height:;
- overflow: hidden;
- border-width: 7px;
- border-style: dashed dashed dashed solid;
- border-color: transparent transparent transparent lightblue;
- top: 33px; //33px:父元素#container的内边距20px + #chat宽度的一半20px - 自身元素#triangle的边宽7px =33px
- left: 70px; //70px: #chat的宽度50px + 父元素#container的内边距20px =70px
- }
- /* html代码 */
- <div id="container">
- <div id="chat"></div>
- <div id="triangle"></div>
- </div>
css实现小三角(原理)的更多相关文章
- CSS的小三角
上三角▲ width: 0; height: 0; line-height: 0; font-size: 0; border-width: 10px; border-style: solid; bor ...
- css制作小三角
视觉稿中经常有些小三角,如下图.每次用图片做太不方便了,我们看看用css实现的效果(支持ie6,7哦) <style> /*border实现三角*/ /*箭头向上*/ .arrow-top ...
- 用CSS制作小三角提示符号
今天在项目中遇到了如下图的切图要求. 对,重点就是那个小三角提示符号. html 结构如下 <div class="wrap"> <div class=" ...
- CSS实现小三角小技巧
<style> .box{ width: 20px; height: 20px; background-color: #424; border: 10px solid #9C27B0; b ...
- CSS生成小三角
前言:小三角的应用场景:鼠标移动到某个按钮上面,查看信息详情时,信息详情弹出框有时候会需要一个小三角. 代码如下: <div id='triangle'></div> #tri ...
- 纯css制作小三角
在网站制作的过程中常涉及一些小图标,以前大部分会采用小图片.但有了css3后很多变得方便了,比如要在li列表的每行文字的前面加个小三角,可以这么写: <!DOCTYPE html> < ...
- css的小三角实现的方式
先上一个简单的例子哈: 此时的方向向下. 如果想方向向上的话用:border-top:0;border-bottom:4px solid; 1. width:0 height:0 border宽度,颜 ...
- css 兼容小三角
<!DOCTYPE><html ><head><meta http-equiv="Content-Type" content=" ...
- css实现小三角效果
<!DOCTYPE html><html><head><meta charset="UTF-8"> <title>新闻标 ...
随机推荐
- Google分布式构建软件之一:获取源代码
本文原文在google开发者工具组的博客上[需要FQ],以下是我的翻译,欢迎转载,但尊重作者版权,注名原文地址. 在Google,所有的产品都是在主干上开发的.这样的好处:每个人都可以查看和修改代码, ...
- Hibernate的三种状态及对象生命周期
理解Hibernate的三种状态,更利于理解Hibernate的运行机制,这些可以让你在开发中对疑点问题的定位产生关键性的帮助. 三种状态 临时状态(Transient):在通过new关键字, ...
- 我的LESS编译方案
背景 近期项目前端决定使用less,简单介绍一下,详细信息有兴趣查看官方文档(http://www.lesscss.net/article/home.html) LESSCSS是一种动态样式语言,属于 ...
- Chrome 控制台新玩法-console显示图片以及为文字加样式
有兴趣的同学可以文章最后的代码复制贴到控制台玩玩. Go for Code 在正常模式下,一般只能向console 控制台输出简单的文字信息.但为了把信息输出得更优雅更便于阅读,除了cosole.lo ...
- TroubleShooting笔记--快照进程sp_replupdateschema和索引重建发生冲突
今天早上服务器出现大面积的阻塞,上去排查blocking,最后大概确定的问题是: rebuild index job(243) --->blocked--->sp_replupdatesc ...
- 測試大型資料表的 Horizontal Partitioning 水平切割
FileGroup 檔案群組 :一個「資料庫(database)」可對應一或多個 FileGroup,一個 FileGroup 可由一或多個 file (.ndf) 構成. FileGroup 可讓 ...
- [Hadoop大数据]——Hive连接JOIN用例详解
SQL里面通常都会用Join来连接两个表,做复杂的关联查询.比如用户表和订单表,能通过join得到某个用户购买的产品:或者某个产品被购买的人群.... Hive也支持这样的操作,而且由于Hive底层运 ...
- MongoDB 搭建副本集
副本集(Replica Set)是一组MongoDB实例组成的集群,由一个主(Primary)服务器和多个备份(Secondary)服务器构成.通过Replication,将数据的更新由Primary ...
- 使用Ado.net执行SP很慢,而用SSMS执行很快
今天遇到一个问题,有用户反应,在site上打开报表,一直loading,出不来结果. 遇到这种问题,我立刻simulate用户使用Filter Condition,问题repro,看来不是偶然事件,通 ...
- Data Profiling Task
Data Profiling Task 是用于收集数据的Metadata的Task,在使用ETL处理数据之前,应该首先检查数据质量,对数据进行分析,这将对Table Schema的设计结构和生成ETL ...