【发布时间】:2018-05-18 22:26:57
【问题描述】:
我目前正在使用一个视差效果,它占据了首页的整个背景。 我的问题是我想将高度设置为 50%.. 但那不起作用。
代码:
<header class="parallax-window" data-parallax="scroll" data-image-src="img/picture.jpg" alt="test">
.parallax-window {
position: relative;
overflow: hidden;
width: 100%;
height: 50%; //Not working.. why?
}
<script src='https://code.jquery.com/jquery-2.2.4.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/parallax.js/1.4.2/parallax.min.js'></script>
<script >// SMOOTH SCROLLING
$(function() {
$('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html, body').animate({
scrollTop: target.offset().top
}, 900);
return false;
}
}
});
});
$('.parallax-window').parallax({imageSrc: 'img/picture.jpg'});
</script>
【问题讨论】:
标签: html css height parallax parallax.js