首页 > 解决方案 > 页脚由两个直角三角形组成

问题描述

我正在制作一个网站,我希望页脚看起来像这样:https ://imgur.com/a/JuHHHkM

它基本上是两个相互重叠的三角形。我试图制作这样的三角形:

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

但是因为宽度取决于你在右边框中放了多少像素,所以我不能使用宽度:100%。

有什么选择吗?提前致谢

标签: cssfooter

解决方案


您可以使用渐变轻松实现此目的:

.footer {
  height:100px;
  background:
   linear-gradient(to bottom right,transparent 49.5%,blue 50%),
   linear-gradient(to bottom left,transparent 49.5%,green 50%);
}
<div class="footer">
</div>

如果您不希望三角形为全宽,也可以调整大小:

.footer {
  height:100px;
  background:
   linear-gradient(to bottom right,transparent 49.5%,blue 50%) right/80% 100% no-repeat,
   linear-gradient(to bottom left,transparent 49.5%,green 50%) left/80% 100% no-repeat;
}
<div class="footer">
</div>


推荐阅读