Creating shapes with CSS

泪湿孤枕 提交于 2019-12-11 03:29:18

问题


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;
}

回答1:


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>



回答2:


try below 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;
}



回答3:


For now i fixed it by flipping the element. Is there another method that is the correct way to do it?

-moz-transform: scaleX(-1);
-o-transform: scaleX(-1);
-webkit-transform: scaleX(-1);
transform: scaleX(-1); 


来源:https://stackoverflow.com/questions/14168564/creating-shapes-with-css

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