How can I create div with a pointed top with CSS

核能气质少年 提交于 2019-11-29 11:55:53

If you dont want to use a image you could do something like this. But working with an image is lot easier in this case.

body {
    background-color: #CCC;
}

.wrapper {
    
}

.outer {
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 205px 32px 205px;
    border-color: transparent transparent #ffffff transparent;
    position: absolute;
}

.inner {
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 200px 32px 200px;
    border-color: transparent transparent #ea2225 transparent;
    margin-left: -200px;
    margin-top: 5px;
    position: absolute;
}

.fix {
    background-color: #FFF;
    height: 10px;
    width: 410px;
    position: absolute;
    margin-top: 32px;
}

.red {
    width: 396px;
    height: 300px;
    background-color: #ea2225;
    margin-top: 37px;
    position: absolute;
    border-left: 7px solid #FFF;
    border-right: 7px solid #FFF;
    border-bottom: 6px solid #FFF;
-webkit-box-shadow: 3px 5px 5px 0px rgba(48,48,48,1);
-moz-box-shadow: 3px 5px 5px 0px rgba(48,48,48,1);
box-shadow: 3px 5px 5px 0px rgba(48,48,48,1);
}
<div class="wrapper">
     <div class="fix"></div>
<div class="outer">
   
  <div class="inner"> 
    
  </div>
    
</div>
  
</div>
   <div class="red"></div>

See http://jsfiddle.net/0csqog8s/

this should get you started:

Update

This is an updated fiddle which is much better presented.

.first {
  display: inline-block;
  width: 3em;
  height: 3em
}
.second {
  position: relative;
  display: inline-block;
  width: 3em;
  height: 3em
}
.third {
  position: absolute;
  display: inline-block;
  width: 0;
  height: 0;
  line-height: 0;
  border: 1.5em solid transparent;
  margin-top: -1em;
  border-bottom: 1em solid #007BFF;
  left: 0em;
  top: 0em
}
.forth {
  position: absolute;
  display: inline-block;
  width: 0;
  height: 0;
  line-height: 0;
  border: 1.5em solid #007BFF;
  border-bottom: 1.5em solid #007BFF;
  left: 0em;
  top: 1.5em
}
<span class="first"><span class="second"><i class="third"></i><i class="forth"></i></span></span>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!