【问题标题】:Div: Css after with clip-path is not working correctly [duplicate]Div:使用剪辑路径后的Css无法正常工作[重复]
【发布时间】:2018-05-12 17:26:25
【问题描述】:

我想像这样显示聊天气泡。我使用 div 使用 CSS 类和 :after 和 clip-path 显示气泡。

风格:

    .right-bubble {
    margin-top: 12px;
    padding: 5px 8px;
    font-size: 13px;
    position: relative;
    background: #1e87f0;
    border-radius: 5px;
    text-align: right;
    color:white;
    box-shadow: 0 5px 15px rgba(0,0,0,.08);
    z-index: 1;
    }

    .right-bubble:after {
    width: 10px;
    height: 45px;
    bottom: 0;
    background: #1e87f0;
    right: -4px;
    clip-path: polygon(0 70%, 0% 100%, 100% 100%);
    }

HTML:

    <div class="right-bubble">
       <p>Welcome, adfdf adsfsdf adsfsdffa adsfdfadsf asdfsdf Please 
       wait. Our agent will join you shortly.asdfadsf adfd asdff asdf 
       fasdfdsf
       </p>
    </div>

它只显示圆角框。它不显示右下箭头。

【问题讨论】:

  • 要出现伪元素,您需要添加content:"";
  • 添加内容:"";不起作用。

标签: html css


【解决方案1】:

<style>
.right-bubble {
    margin-top: 12px;
    padding: 5px 8px;
    font-size: 13px;
    position: relative;
    background: #1e87f0;
    border-radius: 5px;
    text-align: right;
    color:white;
    box-shadow: 0 5px 15px rgba(0,0,0,.08);
    z-index: 1;
    width:50%;
    border-bottom-right-radius: 0;
}

.right-bubble p{
    text-align: left;
    margin: 0;
    padding: 10px;
}

.right-bubble:after {
    width: 10px;
    height: 45px;
    bottom: 0;
    background: #1e87f0;
    right: -4px;
    clip-path: polygon(0 70%, 0% 100%, 100% 100%);
}
.arrow-right {
    width: 0; 
    height: 0; 
    border-top: 20px solid transparent;
    border-bottom: 00px solid transparent;
    border-left: 20px solid #1e87f0;
    position:absolute;
    right:-5%;
    bottom:0;
}
</style>

<!-- HTML -->
<div class="right-bubble">
    <p>Welcome, Sir this is your message</p>
    <div class="arrow-right"></div>
</div>

【讨论】:

  • 显示箭头。但它非常大。我想展示一个小的。另外,我如何以类似的方式显示左箭头?
猜你喜欢
  • 1970-01-01
  • 2016-12-19
  • 2019-07-12
  • 1970-01-01
  • 2020-02-26
  • 2018-05-07
  • 2017-01-04
  • 1970-01-01
  • 2021-12-30
相关资源
最近更新 更多