谁能告诉我为响应式网站获得像这样的缩放分割背景效果的最佳方法。在 HTML5 和 CSS3 中使用:
我已经尝试过渐变,但得到了锯齿状的边缘,在我深入研究另一种方法之前,如果有任何想法,我将不胜感激。理想情况下必须回到 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/