CSS的三角形阴影

时间:2018-12-03 12:46:05

标签: css css3

是否可以使用button和CSS来实现这种三角形阴影设计?

4 个答案:

答案 0 :(得分:1)

You should give a try to the CSS Triangle generator

If you want more information Here are really nice explanations from CSS Tricks

#triangle-bottomright {
  width: 0;
  height: 0;
  border-bottom: 100px solid red;
  border-left: 100px solid transparent;
}

答案 1 :(得分:0)

You can use multiple background and gradient:

.box {
  padding:10px 20px 10px 50px;
  display:inline-block;
  font-size:30px;
  color:#fff;
  background:
    linear-gradient(blue,blue) right/calc(100% - 30px) 100%,
    linear-gradient(to bottom right,transparent 49.8%,grey 50%) left/30px 100%;
  background-repeat:no-repeat;
}
<div class="box"> text</div>

答案 2 :(得分:0)

This will do your work and will work in most of the browsers.

.triangle {
  padding:10px 20px 10px 50px;
  display:inline-block;
  font-size:30px;
  color:#fff;
  background:
    linear-gradient(#1e1e72,#1e1e72) right/calc(100% - 30px) 100%,
    linear-gradient(to bottom right,transparent 49.8%,grey 50%) left/30px 100%;
    -moz-linear-gradient(#1e1e72,#1e1e72) right/calc(100% - 30px) 100%,
    linear-gradient(to bottom right,transparent 49.8%,grey 50%) left/30px 100%;
    -webkit-linear-gradient(#1e1e72,#1e1e72) right/calc(100% - 30px) 100%,
    linear-gradient(to bottom right,transparent 49.8%,grey 50%) left/30px 100%;
    -op-linear-gradient(#1e1e72,#1e1e72) right/calc(100% - 30px) 100%,
    linear-gradient(to bottom right,transparent 49.8%,grey 50%) left/30px 100%;
  background-repeat:no-repeat;
}
<div class="triangle"> FAMILLE</div>

答案 3 :(得分:-1)

try adding a drop shadow filter to the css for the box

 filter: drop-shadow(1px 1px 1px rgba(0,0,0,.5));