Search code examples
cssshapescss-shapes

Creating shapes with CSS


At my website i want to make a speech bubble and found a great tutorial for doing so. But i want to do some changes, but i dont know how to. Basicly i want to flip the little triangle horizontally, so its vertical on the right side instead of the left. Here is the 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;
}

Solution

  • Here is a jsFiddle to show it working. Referenced from Pure CSS Bubbles

    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>