热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

CSS形状外-Firefox浏览器支持

如何解决《CSS形状外-Firefox浏览器支持》经验,为你挑选了2个好方法。

我一直在尝试使用跨浏览器的CSS形状,我已经在Chrome和Safari中使用它没有任何问题,我似乎无法在Firefox中工作(尚未测试IE,不期待那样).

codepen

这是HTML:

PROFESSIONAL PROPERTY MAINTENANCE SERVICES FOR BUSINESSES

Throughout the Northwest of England including Liveprool, Manchester, Preston, Wigan and St. Helens

这是CSS:

.container {
  width: 960px;
  margin: 0 auto;
}
section.hero {
  padding: 8px;
  box-sizing: border-box;
  overflow: hidden;
  width: 100%;
  height: 400px;
  float:left;
  section.slide {
    position:relative;
    .shaped {
      background-size: cover;
      shape-outside: polygon(20% 0, 100% 0, 100% 100%, 0% 100%);
      clip-path: polygon(20% 0, 100% 0, 100% 100%, 0% 100%);
      background-image: url(http://www.e-architect.co.uk/images/jpgs/aberdeen/bon_accord_centre_tonyfreeman221207_04.jpg);
      height: 384px;
      float:left;
      width: 70%;
      float: right;
      shape-margin: 20px;
    }
    .hero-text {
      box-sizing: border-box;
      background-color: #333;
      color: white;
      padding: 30px;
      height: 384px;
      width: 50%;
      h2 {
        margin-bottom: 20px;
      }
    }
  }
}

我尝试过一种Adobe形状的polyfill,它没有任何区别,是否有其他选择,或者我应该考虑完全改变设计?

谢谢



1> web-tiki..:

我建议一起改变方法,FF或IE还不支持 shape-outside ,你可以通过伪元素上的简单转换实现这种布局:

DEMO

section {
  background: url(http://lorempixel.com/output/people-q-c-640-480-9.jpg);
  background-size: cover;
  padding: 5%;
  position: relative;
  overflow: hidden;
  min-width: 700px;
}
section h2,
section p {
  width: 40%;
  padding: 2% 5%;
  position: relative;
  z-index: 1;
}
section h2 {
  width: 50%
}
section:before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 60%;
  height: 300%;
  background: grey;
  z-index: 0;
  -webkit-transform-origin: 100% 0;
  -ms-transform-origin: 100% 0;
  transform-origin: 100% 0;
  -webkit-transform: rotate(20deg);
  -ms-transform: rotate(20deg);
  transform: rotate(20deg);
}

PROFESSIONAL PROPERTY MAINTENANCE SERVICES FOR BUSINESSES

Throughout the Northwest of England including Liveprool, Manchester, Preston, Wigan and St. Helens



2> Weafs.py..:

您可以使用svg's clipPath来进行跨浏览器支持.

.container {
  width: 960px;
  margin: 0 auto;
}
section.hero {
  padding: 8px;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  overflow: hidden;
  width: 100%;
  height: 400px;
  float: left;
}
section.hero section.slide {
  position: relative;
}
.shaped {
  background: url(http://www.e-architect.co.uk/images/jpgs/aberdeen/bon_accord_centre_tonyfreeman221207_04.jpg);
  height: 384px;
  width: 100%;
}
section.hero section.slide .hero-text {
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  background-color: #333;
  color: white;
  padding: 30px;
  height: 384px;
  width: 50%;
}
section.hero section.slide .hero-text h2 {
  margin-bottom: 20px;
}
svg {
  float: right;
}

PROFESSIONAL PROPERTY MAINTENANCE SERVICES FOR BUSINESSES

Throughout the Northwest of England including Liveprool, Manchester, Preston, Wigan and St. Helens


推荐阅读
author-avatar
眭嘀佶毅
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有