【问题标题】:Creating shapes with CSS使用 CSS 创建形状
【发布时间】:2012-12-19 13:34:44
【问题描述】:

在我的website,我想制作一个气泡,并找到了一个很棒的教程。但我想做一些改变,但我不知道怎么做。 基本上我想水平翻转小三角形,所以它在右侧而不是左侧垂直。 这是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;
}

【问题讨论】:

标签: css shapes css-shapes


【解决方案1】:

试试下面的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;
}

【讨论】:

  • 谢谢,效果很好。但我似乎看不出有什么不同?
【解决方案2】:

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

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

【讨论】:

  • 兄弟在这种情况下不需要进行转换,因为在 css 代码本身中使用一些 tweeking 很容易。看看我的回答一次。
  • 另见我的答案,也不需要转换。 :)
【解决方案3】:

Here 是一个 jsFiddle 来展示它的工作原理。引用自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>

【讨论】:

    猜你喜欢
    • 2020-04-19
    • 2014-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-07
    • 1970-01-01
    相关资源
    最近更新 更多