【问题标题】:CSS clip-path with Pseudo class for making a custom footer [duplicate]带有伪类的 CSS 剪辑路径,用于制作自定义页脚 [重复]
【发布时间】:2019-07-06 22:03:20
【问题描述】:

我需要一些帮助来破解 CSS 来为具有伪类和剪辑路径的自定义网站制作页脚。所以我很难让它按应有的方式工作。页脚由两种不同的颜色制成。我进行了一些搜索以查看一些合适的答案;我没找到。我不是太远,但我还不能得到我想要的。

我的 CSS 文件:

.footer_style{
  position: relative;
 margin: 1rem auto;
 min-height: 400px;
 width: 100%;
 display: flex;
 flex-flow: column nowrap;
 align-content: center;
 align-items: center;
 justify-content: center;
 background: #232323;
 // clip-path: polygon(51% 9%, 100% 0, 100% 100%, 1% 100%, 0 19%);
 &:before{
   content: '';
   z-index: -1;
   position: absolute;
   top: -26px;
   left: -11px;
   right: 30px;
   bottom: 30px;
   -webkit-clip-path: polygon(100% 0, 100% 100%, 0 99%, 0 19%);
   clip-path: polygon(100% 0, 100% 100%, 0 99%, 0 19%);
   background: #0465e3;
   -webkit-transform: rotate(6deg);
   transform: rotate(6deg);
   height: 126px;
 }
}

这是我期望的结果:

任何帮助将不胜感激。谢谢!

【问题讨论】:

    标签: html css


    【解决方案1】:

    clip-path 在浏览器中是 not well supported

    简单的linear-gradient 解决方案怎么样?

    body {background:#eef}
    
    footer {
      height: 400px;
      background: 
      linear-gradient(-7deg, #234 395px, transparent 396px), linear-gradient(7deg, #06f 395px, #fff 396px);
    }
    <footer></footer>

    【讨论】:

    • 谢谢兄弟!你救了我的命!
    • @Emmann,乐于助人!
    • 你真的不需要0/cover,你可以删除它
    • @TemaniAfif,是的!
    • @temaniAfif,这似乎是一个重复的问题,但是如果您对其进行测试..当您需要将内容文本放入其中时,您将不会得到相同的结果...我需要一个自定义页脚只有一小部分蓝色..科什的回答对我来说是完美的......
    猜你喜欢
    • 2022-10-22
    • 2020-11-29
    • 1970-01-01
    • 2018-11-27
    • 1970-01-01
    • 1970-01-01
    • 2022-06-15
    • 2016-09-18
    • 2019-02-19
    相关资源
    最近更新 更多