我想从框中删除内部边框或框,如下所示
下方图片:
注意:如果可能的话,我想保留我的代码并添加位
注意2:我不想删除box-shadow
或element
上的:after
这是我的代码笔:https://codepen.io/anon/pen/wEwgRR
#messagebox,#messagebox2{
width:400px;
height:150px;
background:red;
margin: 0 auto;
position:relative;
color:#fff;
padding:12px;
font-size:18px;
border-radius:3%;
box-shadow:0px 8px 9px black;
margin-top:80px;
}
#messagebox:after{
content:'';
position:absolute;
width:50px;
height:50px;
background:red;
bottom:-25px;
right:65%;
transform: rotate(45deg);
color:#fff;
box-shadow:0px 5px 9px black;
}
#messagebox2:after{
content:'';
position:absolute;
width:50px;
height:50px;
background:yellow;
bottom:-25px;
right:65%;
transform: rotate(45deg);
color:#fff;
box-shadow:0px 5px 9px black;
}
<div id="messagebox">
hello world
</div>
<div id="messagebox2">
hello world
</div>
请提前帮助我!!!!
答案 0 :(得分:2)
::before
宽度/高度与父级相同的伪元素创建另一个图层。z-index
值以将其置于::after
伪元素下方,即箭头。演示:
.messagebox {
width:400px;
height:150px;
background:red;
margin: 0 auto;
position:relative;
color:#fff;
padding:12px;
font-size:18px;
margin-top:80px;
}
.messagebox::before {
box-shadow:0px 8px 9px black;
position: absolute;
border-radius:3%;
content: '';
z-index: -2;
bottom: 0;
right: 0;
left: 0;
top: 0;
}
.messagebox:after{
content:'';
position:absolute;
width:50px;
height:50px;
background:red;
bottom:-25px;
right:65%;
z-index: -1;
transform: rotate(45deg);
color:#fff;
box-shadow:0px 5px 9px black;
}
.messagebox2:after{
content:'';
position:absolute;
width:50px;
height:50px;
background:yellow;
bottom:-25px;
right:65%;
transform: rotate(45deg);
color:#fff;
box-shadow:0px 5px 9px black;
}
<div class="messagebox">
hello world
</div>
<div class="messagebox messagebox2">
hello world
</div>
答案 1 :(得分:0)
尝试一下
defaultQuery
.messagebox {
background: red;
border-radius: 12px;
box-shadow: 0 4px 4px 0 rgba(0, 0, 0, 1);
box-sizing: border-box;
color: white;
height: 150px;
margin: 20px auto;
max-width: 400px;
padding: 16px;
position: relative;
}
.messagebox:after {
border: 16px solid black;
border-color: transparent transparent red red;
bottom: -30px;
box-shadow: -4px 4px 4px 0 rgba(0, 0, 0, 1);
box-sizing: border-box;
content: "";
height: 0;
left: 50%;
margin-left: -16px;
position: absolute;
transform: rotate(-45deg);
transform-origin: 0 0;
width: 0;
}