2013-02-14 56 views
4

什么是你最好的选择或方法来创建一个形状,如附件链接完整的CSS中看到的,这是可能的吗?创建一个复杂的CSS形状(说泡泡)

我做过CSS平行四边形的研究和测试,例如但还没有取得任何成功。

看到这里的形状 - >>http://tinypic.com/r/352ge3b/6

complex speech bubble

+0

你有什么这么远吗? - 提供尽可能多的关于您所取得的进展的信息是一个好主意。 – Raad 2013-02-14 14:30:56

+0

你不得不使用几个元素和很多CSS3变换,但它是可能的。先去自己,当遇到问题时,回来;) – BenM 2013-02-14 14:32:00

+0

是的,这是可能的! – Christoph 2013-02-14 15:01:06

回答

9

我曾经有过这样的事情,只需要一个元素就可以完成 - 而且可以完成,我只是不认为这是像这样做的最佳解决方案。

DEMO

HTML

<div class='speech-bubble'>Hello!</div> 

CSS

.speech-bubble { 
    position: relative; 
    margin: .5em auto; 
    padding: 1em; 
    width: 10em; height: 4em; 
    border-radius: .25em; 
    transform: rotate(-4deg) rotateY(15deg); 
    background: #629bdd; 
    font: 2em/4 Century Gothic, Verdana, sans-serif; 
    text-align: center; 
} 
.speech-bubble:before, .speech-bubble:after { 
    position: absolute; 
    z-index: -1; 
    content: ''; 
} 
.speech-bubble:after { 
    top: 0; right: 0; bottom: 0; left: 0; 
    border-radius: inherit; 
    transform: rotate(2deg) translate(.35em, -.15em) scale(1.02); 
    background: #f4fbfe; 
} 
.speech-bubble:before { 
    border: solid 0 transparent; 
    border-right: solid 3.5em #f4fbfe; 
    border-bottom: solid .25em #629bdd; 
    bottom: .25em; left: 1.25em; 
    width: 0; height: 1em; 
    transform: rotate(45deg) skewX(75deg); 
} 
0

不完全是,你要寻找的,但我和CSS3的角度玩弄和旋转并提出这样的:

body { 
    color: #FFF; 
    font-family: sans-serif; 
} 

.outer { 
    position: relative; 
    height: 120px; 
    width: 120px; 
    margin: 50px; 
    padding:10px; 
    perspective:150; 
    -webkit-perspective:150; 
} 

.inner { 
    border-radius: 15px; 
    padding:50px; 
    position: absolute; 
    background-color: #80BFFF; 
    transform: rotateY(10deg); 
    -webkit-transform: rotateY(10deg); 
    box-shadow: -4px -4px 0px #3399FF; 
} 

.inner:after { 
    content: ' '; 
    position: absolute; 
    width: 0; 
    height: 0; 
    left: 20px; 
    top: 115px; 
    border: 15px solid; 
    border-color: #80BFFF transparent transparent #80BFFF; 
} 

这是我的HTML的东西

<div class="outer"> 
    <div class="inner">Yay!</div> 
</div> 
+0

谢谢!我会试试这个,回复我的想法。 – 2013-02-14 17:44:37