带有底部箭头的 HTML 注释框

标签 html css

<分区>

我想创建一个带有底部箭头的评论框。但我不知道如何添加这个箭头。这是我要创建的模型。

enter image description here

到目前为止,这是我的代码。

.arrow-div {
    position: relative;
    background: #424242;
    margin: 2em auto;
    color:#eaeaea;
    border-radius:3px;
    height: 2.5em;
    text-align:center;
    width:270px;
 }
<div class="arrow-div">
$167 still needed for this project
</div>

最佳答案

您可以使用 :before 伪选择器:

.arrow-div {
    position: relative;
    background: #424242;
    display:flex;
    align-items: center;
    justify-content:center;
    margin: 2em auto;
    color:#eaeaea;
    border-radius:3px;
    height: 2.5em;
    width:270px;
 }
 
 .arrow-div:before
 {
    content: '';
    position: absolute;
    bottom:-7px; right: 20px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 7px 7.5px 0 7.5px;
    border-color: #042424 transparent transparent transparent;
 }
<div class="arrow-div">
  <p>Blah Blah content...</p>
</div>

关于带有底部箭头的 HTML 注释框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46238903/

上一篇:html - 内部 div css 设置

下一篇:HTML/CSS - 使虚线在不同元素上填充相同

相关文章:

javascript - 如何通过JS将一个元素的第n个子元素的src属性赋值给另一个元素

javascript - 如何编辑一篇博文的 CSS 而不是其他博文以获得 5 星评级系统?

performance - 有没有办法在导致性能不佳时禁用特定的 css 规则?

javascript - 单击表格行的对话框

java - 用 Java 创建动态 PDF

css - 为什么媒体查询中的 CSS 旋转不会旋转回来

html - 为什么 wordpress 生成随机 <br> 并错开我的图像

html - 可以在 <g :actionSubmit> tag? 中添加 css

javascript - 如何将单选按钮组重置为特定值

html - CSS: center textarea inside <td> for 100% table