帶三角形的對話框有2中方,一下分別用示例做介紹
方法1;向左和向右
向右
~~~
.box-you{
position:relative;
width:200px;
height:100px;
border:1px solid red;
border-radius:3px;
text-align:center;
line-height:100px;
}
.box-you:after {
content:'';
position:absolute;
right:-19px;
top:16px;
border:10px solid transparent;
border-left-color:white;
}
.box-you:before {
content:'';
position:absolute;
right:-20px;
top:16px;
border:10px solid transparent;
border-left-color:red;
}
<div class="box-you">
箭頭右
</div>
~~~
向左
~~~
.box-zou{
margin-top: 20px;
margin-left: 20px;
position: relative;
width:200px;
height:100px;
border:1px solid red;
border-radius:3px;
text-align:center;
line-height:100px;
}
.box-zou:before{
content:"";
position: absolute;
left:-20px;
top:50%;
margin-top: -10px;
border: 10px solid transparent;
border-right-color:red;
}
.box-zou:after{
content:"";
position: absolute;
left:-19px;
top: 50%;
margin-top: -10px;
border: 10px solid transparent;
border-right-color: white
}
<div class="box-zou">
箭頭左方法一
</div>
~~~
效果:
方法2:向下和向上,用的是旋轉
向下;
~~~
.box2-xia{
margin-top: 20px;
margin-left: 20px;
position: relative;
width:150px;
height:180px;
background: #cac;
text-align: center;
}
.box2-xia:before{
content:"";
width:10px;
height:10px;
background:#cac;/*此處用的事填充色*/
position: absolute;
bottom:-5px;
left:50%;
margin-left: -5px;
transform:rotate(45deg);
}
div class="box2-xia">
箭頭下 方法二 填充色
</div>
~~~
向上
~~~
.box2-shang{
margin-top: 40px;
margin-left: 20px;
padding-top: 10px;
position: relative;
width:150px;
height:180px;
border:1px solid #f00;
text-align: center;
}
.box2-shang:before{
content:"";
width:10px;
height:10px;
background:#fff;
border:1px solid transparent;
border-top-color: red;
border-left-color: red;/*此處用的邊框*/
position: absolute;
top:-6px;
left:50%;
margin-left: -5px;
transform:rotate(45deg);
}
<div class="box2-shang">
箭頭下,方法2 無填充色
</div>
~~~
效果
- 布局
- display:table布局
- display:flex彈性布局
- html
- 1.1關于文字小技巧
- 1.2加載
- 1.3蘋果和安卓樣式兼容問題
- 1.4結構技巧
- 1.5兼容ie7,ie8技巧
- css
- 1.1內容不夠,頁面固定在底部
- 1.2 css屬性書寫順序
- 1.3font和line-height之CSS代碼書寫順序不同,導致顯示效果不一樣
- 1.4 flex設置成1和auto有什么區別
- 1.5帶三角形的對話框
- 1.6css選擇器
- 1.6.1通用兄弟選擇器E ~ F
- 1.6.2相鄰兄弟選擇器E + F
- 1.6.3 CSS3結構選擇器
- 1.6.4 屬性選擇器
- 1.6.7 class^=,class*= ,class$= 的含義
- 1.7偽類
- 1.7.1:not(s)
- 1.9inherit和 initial
- 2.0 css技巧
- css3
- 1.2 背景background
- 1.3 transform
- 1.3.1移動translate
- 1.3.2縮放scale
- 1.3.3旋轉rotate
- 1.3.4扭曲skew
- 1.4 Transition
- 1.5 animate
- 1.6 calc()
- 1.7 Gradients漸變
- 1.8 backface-visibility
- 1.9 text-size-adjust
- sass知識點
- 1.1sass寫法轉化
- 1.1.1 sass的轉換寫法
- 1.2 & 嵌套寫法
- 1.2變量
- 1.2.1 默認值
- 1.2.2 全局變量和局部變量
- 1.2.3 嵌套
- 1.2.4 偽類選擇器
- 1.2.5變量用井號花括號包裹
- 1.2.6 多個變量一起聲明
- 1.3混合宏
- 1.3.1不帶參數的混合宏
- 1.3.2傳一個不帶值的參數
- 1.3.3傳多個不帶值的參數
- 1.3.4傳一個參數的值
- 1.3.5傳多個參數的值
- 1.3.6參數變量名后面加...(省略號)
- 1.4文件導入
- 1.5繼承@extend
- 1.6占位符%
- 1.7混合宏VS繼承VS占位符
- 1.8 @media在sass中寫法
- 1.9 @content的作用
- sass基本運算
- 1.1[Sass運算]加法
- 1.2[Sass運算]減法
- 1.3[Sass運算]乘法
- 1.4[Sass運算]除法
- sass函數
- 1.1 @if函數
- 1.2for函數
- 1.3 while函數
- 1.4 each循環
- 函數
- 1.1一些函數的意思
- 1.2if else函數
- 1.3 i++和++i的區別
- 1.4for函數
- UI設計規則
- 1.1字體
- 1.2尺寸
- 1.3 注意點
- 1.4 界面設計注意點