Kin*_*Kin 5 html css css-shapes
我试图用箭头创建div的错误标签,但有居中问题.
我明白了: 
我需要这样的东西:
HTML:
<div class="error-label-arrow"></div>
<div class="error-label">This field is required.</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
div.error-label{
padding: 7px 10px 0 4px;
color: #fff;
background-color: #DA362A;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
div.error-label-arrow{
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-right:10px solid #DA362A;
float: left;
}
Run Code Online (Sandbox Code Playgroud)
可能吗?
这是小提琴
Cur*_*urt 18
您可以使用CSS Pseudo类来执行此操作,因此您不需要"箭头"元素:
div.error-label {
padding: 10px;
color: #fff;
background-color: #DA362A;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
width: 190px;
margin: 30px;
}
div.error-label:before {
content: ' ';
height: 0;
position: absolute;
width: 0;
left: 18px;
border: 10px solid transparent;
border-right-color: #DA362A;
}Run Code Online (Sandbox Code Playgroud)
现场演示:http://jsfiddle.net/p9ZPg/
| 归档时间: |
|
| 查看次数: |
17374 次 |
| 最近记录: |