简体   繁体   English

带页脚的div倾斜无法正常工作

[英]skewed div with footer doesn't work properly

So, i'm trying to build a website with skewed sections. 因此,我正在尝试建立一个带有倾斜部分的网站。

On the main content of the webpage i have no problem at all. 在网页的主要内容上,我完全没有问题。

The only problem is on the footer. 唯一的问题在页脚上。 There is a little blank space between the footer and the bottom of the page caused by the last skewed section. 最后一个歪斜部分导致页脚和页面底部之间有一些空白。 I had already tried to change the position, display, margin, padding of all the elements (body, html, div section, footer, etc.. ) but not seems to be working... 我已经尝试过更改所有元素(body,html,div,div,footer等)的位置,显示,边距,填充,但似乎无法正常工作...

This is the skew code i'm using: 这是我正在使用的偏斜代码:

$deg: 3deg;
.skew {
    -ms-transform: skewY($deg); /* IE 9 */
    -webkit-transform: skewY($deg); /* Chrome, Safari, Opera */
    transform: skewY($deg);
}

This is the jsfiddle i've made with my code: http://jsfiddle.net/1keobbqc/ 这是我用我的代码制作的jsfiddle: http : //jsfiddle.net/1keobbqc/

I hope you guys can help me on this one here! 我希望你们能在这里帮助我! Thanks! 谢谢!

This is to be expected, as the screen size grows the angle of your skewed footer will not always be able to stay aligned properly with your small footer. 这是可以预料的,因为屏幕尺寸会增大,但倾斜的页脚的角度将无法始终与小页脚保持正确对齐。 What you can do is use media queries to adjust the angle at certain break points so it stays more level like so: 您可以做的是使用媒体查询在某些断点处调整角度,以使其保持更高水平,如下所示:

$deg: 3deg;
$deg-media: 8deg;

.skew {
   -ms-transform: skewY($deg); /* IE 9 */
   -webkit-transform: skewY($deg); /* Chrome, Safari, Opera */
   transform: skewY($deg);
}

.skew-rev {
   -ms-transform: skewY(-$deg); /* IE 9 */
   -webkit-transform: skewY(-$deg); /* Chrome, Safari, Opera */
   transform: skewY(-$deg);
}

@media only screen and (max-width: 1400px){ 
   .skew {
      -ms-transform: skewY($deg-media); /* IE 9 */
      -webkit-transform: skewY($deg-media); /* Chrome, Safari, Opera */
      transform: skewY($deg-media);
   }

   .skew-rev {
      -ms-transform: skewY(-$deg-media); /* IE 9 */
      -webkit-transform: skewY(-$deg-media); /* Chrome, Safari, Opera */
      transform: skewY(-$deg-media);
   }

}

Here is an exaggerated example to show you the media queries working, adjust your browser to above/under 800px: 这是一个夸张的示例,向您展示正在运行的媒体查询,将浏览器调整为800px以上/以下:

FIDDLE 小提琴

If what you want is to keep the angle constant, and want to make sure that the left side adjusts perfectly, just state 如果要保持角度恒定,并要确保左侧调整完美,请说明

transform-origin: left bottom;

this way, the vertical distance between the footer and the bottom at the left border will be constant (but the right size of the footer will be lower as the width of the page increases) 这样,页脚和底部边框底部之间的垂直距离将是恒定的(但是页脚的右侧大小将随着页面宽度的增加而减小)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM