我想通过添加左边框来设置警告消息的样式。我做了这个,但左边框有问题,因为它没有放在红色边框内...它以某种方式移位到左边
HTML:
<div class="msg-warning">Random warning message</div>
CSS:
.msg-warning {
border: 1px solid red;
padding: 0px 5px;
border-left-width: 12px;
}
.msg-warning {
border-left-color: blue;
}
答案 0 :(得分:1)
.msg-warning {
border: 1px solid red;
padding: 0px 5px;
border-left: none;
box-shadow:-12px 0 blue;
margin-left:12px;
}
&#13;
<div class="msg-warning">Random warning message</div>
&#13;
答案 1 :(得分:0)
div
div 中嵌套另一个.msg-warning
.msg-warning {
border: 1px solid red;
padding: 0px 5px;
padding-left: 0px;
}
.blue {
display:inline-block;
width: 12px;
height: 100%;
background-color: blue;
margin-right: 5px;
}
&#13;
<div class="msg-warning"><div class="blue"> </div>Random warning message</div>
&#13;
答案 2 :(得分:0)
使用轮廓和边框属性:
.msg-warning {
outline: 1px solid lightGray;
padding: 0px 5px;
border-left:12px solid #FCF8E3;
}