本文主要包含CSS,对话框等相关知识,Aaron 希望在学习及工作中可以帮助到您
如下图:左侧三角形
css代码如下:
- #talkbubble {
- margin-left:30px;
- width: 120px;
- height: 80px;
- background: red;
- position: relative;
- -moz-border-radius: 10px;
- -webkit-border-radius: 10px;
- border-radius: 10px;
- }
- #talkbubble:before {
- content:"";
- position: absolute;
- rightright: 100%;
- top: 26px;
- width: 0;
- height: 0;
- border-top: 13px solid transparent;
- border-right: 26px solid red;
- border-bottom: 13px solid transparent;
- }
其实,本案例的精华就是三角形的绘制,那么如何绘制三角形呢?我在这里总结一下!
上三角形,上三角形,顶部是尖的,所以用border-left,border-right,和border-bottom可以实现,给bottom一个颜色,其他设置为transparent
- #triangle-up {
- width: 0;
- height: 0;
- border-left: 50px solid transparent;
- border-right: 50px solid transparent;
- border-bottom: 100px solid red;
- }
同理,大家可以判断一下如下代码分别是什么样的三角形!
- #triangle-down {
- width: 0;
- height: 0;
- border-left: 50px solid transparent;
- border-right: 50px solid transparent;
- border-top: 100px solid red;
- }
- #triangle-left {
- width: 0;
- height: 0;
- border-top: 50px solid transparent; &n