How can I make a CSS only speech bubble with a border?

可紊 提交于 2019-12-06 01:41:00
Joseph Marikle
<div>Hello Stack Overflow!<span></span></div>
div span:after {
    content: "";
    display: block;
    width: 0;
    height: 0;
    position: absolute;
    left: 50%;
    bottom: -51px;
    margin-left: -15px;
    border-width: 20px 20px 30px 20px;
    border-style: solid;
    border-color: #000 transparent transparent transparent;
}

http://jsfiddle.net/QYH5a/

For the Unicode character approach you suggested, the most appropriate would be ▼ U+25BC BLACK DOWN-POINTING TRIANGLE. I don't know whether iOS has glyphs for it.

samccone

Here is a similar solution:

http://jsfiddle.net/JyPBD/2/

<div>Hello Stack Overflow!<span></span></div>
body {
   background: #ccc;   
}

div {
    position: relative;
    background: #fff;
    padding: 10px;
    font-size: 12px;
    text-align: center;
    -webkit-border-radius: 20px;
    -moz-border-radius: 20px;
    border-radius: 20px;
    border: 1px solid #333;
}
div:after {
    content: "";
    display: block;
    width: 0;
    height: 0;
    position: absolute;
    left: 50%;
    bottom: -60px;
    margin-left: -16px;
    border-width: 30px 20px 30px 20px;
    border-style: solid;
    border-color: green transparent transparent transparent;

}

div span
{
    border-color: #FF0000 transparent transparent;
    border-style: solid;
    border-width: 25px 15px;
    bottom: -51px;
    margin-left: -65px;

    position: absolute;
    z-index: 10;
}

You could use the filter property with box-shadow() to do it...

-webkit-filter: drop-shadow(1px 1px 1px #111) drop-shadow(-1px -1px 1px #111);

jsFiddle.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!