html - 网站45度 Angular 分割背景色

标签 html css background responsive-design angle

谁能告诉我为响应式网站获得像这样的缩放分割背景效果的最佳方法。在 HTML5 和 CSS3 中使用:Example background effect

我已经尝试过渐变,但得到了锯齿状的边缘,在我深入研究另一种方法之前,如果有任何想法,我将不胜感激。理想情况下必须回到 IE9。

谢谢

最佳答案

希望这有帮助:http://codepen.io/ZsharE/pen/VYRPwW !

HTML

<div class="shape">
  <div class="top"></div>
  <div class="shape-content">
      <h1>Diagonal background</h1>
  </div>
</div>

CSS

html, body {
    margin: 0px;
    padding: 0px;
}

.shape {
    width: 100%;
    margin:0 auto;
    position: relative;
    background: #468d91;
}

.shape-content {
    max-width: 1170px;
    margin:0 auto;
  padding: 200px 15px 200px 15px;
}

.shape-content h1 {
    margin: 0px;
    padding: 0px 15px;
    z-index: 9;
    position: relative;
    color: #ffffff;
    font-size: 50px;
    font-family: 'Open Sans', sans-serif;
    text-align: center;
    text-shadow: 0px 2px 4px #444444;
    font-weight: 300;
}

.top {
  position: absolute;
    top: 0;
    left: 0;
  border-style:solid;
  border-color:transparent transparent #3c888b #3c888b;
  z-index: 1;
}

JS

function angle() {
    var w = $(window).width();
    var h = $(".shape").height();
    $('.top').css('border-right-width', w - 3);
    $('.top').css('border-bottom-width', h - 3);
}

$(document).ready(function(){

    $(window).bind("load", function(){
        angle();
    });

    $(window).resize(function(){
        angle();
    });

});

关于html - 网站45度 Angular 分割背景色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28387055/

相关文章:

javascript - 如何在jquery中每组新数据后面放置一个br标签

html - CSS:输入字段和选择选项错误?

css - mgwt IconHandler 和颜色 3 位十六进制错误

swift - 当应用程序处于后台模式时获取通知

javascript - HTML5 Canvas 中的透视渲染

jquery - 使用 jQuery 将 accesskey 设置为键盘数字键盘键

css - 固定 DIV 上出现的 Quicktime 视频

javascript - 我如何将数组划分为子数组,每个子数组包含 5 个元素,并将单独的类应用于每个子数组中的元素

ios - 我的应用程序进入暂停状态的原因是什么?

css - 如何让背景图像在 CSS 和 HTML 中工作?