css - 翻转 CSS 气泡三 Angular 形位置?

标签 css css-shapes

Fiddle

HTML:

<blockquote class="rectangle-speech-border">
    <p>This is a blockquote that is styled to look like a speech bubble</p>
</blockquote>

CSS:

.rectangle-speech-border {
  position:relative;
  padding:50px 15px;
  margin:1em 0 3em;
  border:10px solid #5a8f00;
  text-align:center;
  color:#333;
  background:#fff;
  /* css3 */
  -webkit-border-radius:20px;
  -moz-border-radius:20px;
  border-radius:20px;
}

/* creates larger curve */
.rectangle-speech-border:before {
  content:"";
  position:absolute;
  z-index:10;
  bottom:-40px;
  left:50px;
  width:50px;
  height:30px;
  border-style:solid;
  border-width:0 10px 10px 0;
  border-color:#5a8f00;
  background:transparent;
  /* css3 */
  -webkit-border-bottom-right-radius:80px 50px;
  -moz-border-radius-bottomright:80px 50px;
  border-bottom-right-radius:80px 50px;
  /* reduce the damage in FF3.0 */
  display:block;
}

/* creates smaller curve */
.rectangle-speech-border:after {
  content:"";
  position:absolute;
  z-index:10;
  bottom:-40px;
  left:50px;
  width:20px;
  height:30px;
  border-style:solid;
  border-width:0 10px 10px 0;
  border-color:#5a8f00;
  background:transparent;
  /* css3 */
  -webkit-border-bottom-right-radius:40px 50px;
  -moz-border-radius-bottomright:40px 50px;
  border-bottom-right-radius:40px 50px;
  /* reduce the damage in FF3.0 */
  display:block;
}

/* creates a small circle to produce a rounded point where the two curves meet */
.rectangle-speech-border > :first-child:before {
  content:"";
  position:absolute;
  bottom:-40px;
  left:45px;
  width:10px;
  height:10px;
  background:#5a8f00;
  /* css3 */
  -webkit-border-radius:10px;
  -moz-border-radius:10px;
  border-radius:10px;
}

/* creates a white rectangle to cover part of the oval border*/
.rectangle-speech-border > :first-child:after {
  content:"";
  position:absolute;
  bottom:-10px;
  left:76px;
  width:24px;
  height:15px;
  background:#fff;
}

示例取自:Nicolas Gallagher

基本上这个文本气泡向左和左下角 flex 。我想完全复制它,只是将它放在右下角并向右 flex 。只需翻转即可。

我试过将右侧更改为左侧,但没有成功。谁能告诉我需要改变什么才能翻转这个泡沫?

最佳答案

你是这个意思吗?

如果你想改变几何形状,你应该尝试使用 border-width 和 border-radius。此外,我将伪类从 :after 更改为 :before,反之亦然,元素和 border-radius 从右到左。

.rectangle-speech-border {
  position:relative;
  padding:50px 15px;
  margin:1em 0 3em;
  border:10px solid #5a8f00;
  text-align:center;
  color:#333;
  background:#fff;
  /* css3 */
  -webkit-border-radius:20px;
  -moz-border-radius:20px;
  border-radius:20px;
}

/* creates larger curve */
.rectangle-speech-border:after {
  content:"";
  position:absolute;
  z-index:10;
  bottom:-40px;
  left:400px;
  width:20px;
  height:30px;
  border-style:solid;
  border-width:0 0 10px 10px;
  border-color:#5a8f00;
  background:transparent;
  /* css3 */
  -webkit-border-bottom-left-radius:40px 50px;
  -moz-border-bottom-left-radius:40px 50px;
  border-bottom-left-radius:40px 50px;
  /* reduce the damage in FF3.0 */
  display:block;
}

/* creates smaller curve */
.rectangle-speech-border:before {
  content:"";
  position:absolute;
  z-index:10;
  left:370px;
  width:50px;
  height:30px;
  bottom: -40px;
  border-style:solid;
  border-width:0 0 10px 10px;
  border-color:#5a8f00;
  background:transparent;
  /* css3 */
  -webkit-border-bottom-left-radius:40px 50px;
  -moz-border-bottom-left-radius:40px 50px;
  border-bottom-left-radius:40px 50px;
  /* reduce the damage in FF3.0 */
  display:block;
}

/* creates a small circle to produce a rounded point where the two curves meet */
.rectangle-speech-border > :first-child:before {
  content:"";
  position:absolute;
  bottom:-40px;
  left:425px;
  width:10px;
  height:10px;
  background:#5a8f00;
  /* css3 */
  -webkit-border-radius:10px;
  -moz-border-radius:10px;
  border-radius:10px;
}

/* creates a white rectangle to cover part of the oval border*/
.rectangle-speech-border > :first-child:after {
  content:"";
  position:absolute;
  bottom:-10px;
  left:376px;
  width:24px;
  height:15px;
  background:#fff;
}
<blockquote class="rectangle-speech-border">
    <p>This is a blockquote that is styled to look like a speech bubble</p>
</blockquote>

关于css - 翻转 CSS 气泡三 Angular 形位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31868313/

相关文章:

html - 窗口的第一个 Div 全尺寸,空白

javascript - 标题的固定高度和变化宽度(HTML 表格)

css - 在 CSS3 上带有边框的波浪(或形状?)

html - 我怎样才能制作一个有超过4个 Angular 的div

css - Shiny 的 absolutePanel 中的背景

css - 如何将相同的样式应用于所有直接子类?

javascript - 背景颜色基于实际的巴塞罗那时区并且元素也会发生变化

css - CSS 三 Angular 形是如何工作的?

html - 创建对 Angular 线背景图像

css - 在 td 的各边使用不同的边框