这可能是一个快速修复,我只是不明白发生了什么。
我看到了这个问题的答案 Create a complex CSS shape (speaking bubble)我想做类似的东西。所以在我出于某种原因的尝试中, :before 伪元素没有显示在“父”div 之外。我试图让它看起来像一个对话泡泡,所以我需要元素显示在 div 之外。
这是我的代码
HTML
<div class="image">
<img class="test" src="http://fc00.deviantart.net/fs71/f/2011/322/e/2/e292b11555866aec8666ded2e63ee541-d4gl4vg.png" alt="leopard" />
</div>
CSS
body {
background-color: #333;
}
.image {
position:relative;
width:360px;
background:orange;
border-radius: 15px;
overflow: hidden;
margin-left: 15px;
}
.image:before {
position: absolute;
z-index: 1;
content: '';
background-color: #fff;
border: solid 0 transparent;
top: 50px; left: -1.25em;
width: 5em; height: 1em;
transform: rotate(45deg) skewX(75deg);
-moz-box-shadow: inset 0 0 5px #000000, -3px 0px 2px 6px #000;
-webkit-box-shadow: inset 0 0 5px #000000, -3px 0px 2px 6px #000;
box-shadow: inset 0 0 5px #000000, -3px 0px 2px 6px #000;
}
.test {
display:block;
width:100%;
}
这是一个代码笔。 Demo
感谢回答。
最佳答案
移除 overflow: hidden 并将你的 border-radius
添加到 .image
和 .test
http://codepen.io/anon/pen/bFElG
关于html - :before element not displaying outside div speech-bubble,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18754330/