How to create a gradient css with an arrow down connected to a container

心已入冬 提交于 2019-12-01 13:16:52

You can use css clip-path, but the browser support is not that great.

.gradient{
  height: 300px;
  background: rgb(0,105,173);
  background: linear-gradient(45deg, rgba(0,105,173,1) 0%, rgba(34,84,132,1) 100%);
  display: flex;
  justify-content: space-around;
  align-items: center;
  /* Clip-path */
  /* clip-path: polygon(0% 0%, 100% 0%, 100% calc(100% - 30px), 60% calc(100% - 30px), 50% 100%, 40% calc(100% - 30px), 0% calc(100% - 30px));
  padding-bottom: 30px; */
  /* Fixed-width arrow */
  clip-path: polygon(0% 0%, 100% 0%, 100% calc(100% - 30px), calc(50% + 40px) calc(100% - 30px), 50% 100%, calc(50% - 40px) calc(100% - 30px), 0% calc(100% - 30px));
}
<div id="app" class="gradient">
  <h1 class="display-1 my-5">Lorem Ipsum</h1>
</div>

Here is another idea more supported than clip-path but without transparency.

.gradient{
  height: 250px;
  background: 
    /* 28.3px = cos(45deg) x 40px  
       225deg = 180deg + 45deg
    */
    linear-gradient( 225deg, transparent 28.3px,#fff 29px) bottom left /50% 40px,
    linear-gradient(-225deg, transparent 28.3px,#fff 29px) bottom right/50% 40px,
    
    /*Your gradient*/
    linear-gradient(to bottom right, red,yellow ,blue);
  background-repeat:no-repeat;
}
<div id="app" class="gradient">
</div>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!