2

在我的网站上,我想制作一个语音气泡,并找到了一个很棒的教程。但我想做一些改变,但我不知道怎么做。基本上我想水平翻转小三角形,所以它在右侧而不是左侧垂直。这是CSS:

.bubble
{
    margin-top: 100px;
    position: relative;
    width: 200px;
    height: 100px;
    text-align: center;
    line-height: 100px;
    background-color: #fff;
    border: 8px solid #666;
    -webkit-border-radius: 30px;
    -moz-border-radius: 30px;
    border-radius: 30px;
    -webkit-box-shadow: 2px 2px 4px #888;
    -moz-box-shadow: 2px 2px 4px #888;
    box-shadow: 2px 2px 4px #888;
}


.bubble:after
{
    content: ' ';
    position: absolute;
    width: 0;
    height: 0;
    left: 38px;
    top: 100px;
    border: 15px solid;
    border-color: #fff transparent transparent #fff;
}
4

3 回答 3

3

试试下面的CSS:

.bubble:after {
    -moz-border-bottom-colors: none;
    -moz-border-image: none;
    -moz-border-left-colors: none;
    -moz-border-right-colors: none;
    -moz-border-top-colors: none;
    border-color: orange orange transparent transparent; // See here i change the color
    border-style: solid;
    border-width: 15px;
    content: " ";
    height: 0;
    position: absolute;
    right: 38px; // see here for position
    top: 100px;
    width: 0;
}

.bubble:before {
    border: 25px solid;
    content: " ";
    height: 0;
    position: absolute;
    right: 30px; // see here for position
    top: 100px;
    width: 0;
}
于 2013-01-05T04:36:02.637 回答
2

是一个 jsFiddle 来展示它的工作原理。引用自纯 CSS 气泡

CSS

.bubble {
    margin-top: 100px;
    position: relative;
    width: 200px;
    height: 100px;
    text-align: center;
    line-height: 100px;
    background-color: orange;
    -webkit-border-radius: 30px;
    -moz-border-radius: 30px;
    border-radius: 30px;
}

.bubble:after {
    content:"";
    position:absolute;
    bottom:-20px; 
    left:50px; 
    border-width:20px 0 0 20px; 
    border-style:solid;
    border-color: orange transparent;
    display:block; 
    width:0;
}

HTML

    <div class="bubble">
        nice
    </div>
于 2013-01-05T04:40:03.200 回答
0

现在我通过翻转元素来修复它。还有另一种方法是正确的方法吗?

-moz-transform: scaleX(-1);
-o-transform: scaleX(-1);
-webkit-transform: scaleX(-1);
transform: scaleX(-1); 
于 2013-01-05T04:36:27.747 回答