围绕div的边框,底部有一个三角形点

时间:2017-03-14 09:55:33

标签: html css html5 css3

有没有办法在CSS中实现这个边界?我有一个带有子弹点列表的DIV,我需要将它包裹在像图像一样的边框中。

enter image description here

4 个答案:

答案 0 :(得分:2)

您可以先创建一个除border-bottom以外的边框元素,然后使用:before:after伪元素在底部添加三角形边框。

div {
  width: 200px;
  height: 150px;
  border: 1px solid black;
  border-bottom: none;
  position: relative;
  background: white;
  margin: 20px;
}
div:after, div:before {
  content: '';
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 50px 101px 0 101px;
  border-color: black transparent transparent transparent;
  top: 100%;
  left: -1px;
  position: absolute;
}
div:after {
  border-color: white transparent transparent transparent;
  top: calc(100% - 1px);
  
}
<div></div>

答案 1 :(得分:1)

看看这个Fiddle

基本上将此css添加到div:

#base {
  background: red;
  display: inline-block;
  height: 55px;
  margin-left: 20px;
  margin-top: 55px;
  position: relative;
  width: 100px;
}

#base:after {
  border-bottom: 35px solid red;
  border-left: 50px solid transparent;
  border-right: 50px solid transparent;
  content: "";
  height: 0;
  left: 0;
  position: absolute;
  top: 54px;
  width: 0;
  -ms-transform: rotate(180deg);
  -webkit-transform: rotate(180deg);
  transform: rotate(180deg);
}

答案 2 :(得分:0)

试试这个:

 .down-arrow {
    display: inline-block;
    position: relative;
    background: darkcyan;
    padding: 15px 0;
    width: 200px;
    text-align: center;
}
.down-arrow:after {
    content: '';
    display: block;  
    position: absolute;
    left: 0;
    top: 100%;
    width: 0;
    height: 0;
    border-top: 20px solid darkcyan;
    border-right: 100px solid transparent;
    border-bottom: 0 solid transparent;
    border-left: 100px solid transparent;
}

DEMO HERE

答案 3 :(得分:0)

以下是该框的代码:

&#13;
&#13;
.box {
    background: #fff;
    border: 1px solid #000;
    display: inline-block;
    height: 55px;
    margin-left: 20px;
    margin-top: 55px;
    position: relative;
    width: 100px;
}

.box:after {
    border-top: 35px solid #fff;
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    content: '';
    height: 0;
    left: 0;
    position: absolute;
    top: 55px;
    width: 0;
}
.box:before {
    border-top: 35px solid #000;
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    content: '';
    height: 0;
    left: 0;
    position: absolute;
    top: 56px;
    width: 0;
}
&#13;
<div class="box">
</div>
&#13;
&#13;
&#13;

我希望它有所帮助