简体   繁体   English

在流星上实现视差初始化

[英]Materialize Parallax Initialization on Meteor

I'm using materializecss as a front-end framework for my personal website I am currently developing. 我正在使用materializecss作为我当前正在开发的个人网站的前端框架。 I used their starter Parallax template and everything works, but for some reason my Parallax images are not showing. 我使用了他们的入门视差模板,并且一切正常,但是由于某些原因,我的视差图像未显示。 I believe it has something to do with the initialization. 我相信这与初始化有关。

snippet of one of the parallax for the HTML: HTML视差之一的代码段:

<template name="parall">
    <div class="parallax"><img src="/public/background1.jpg">
    </div>
</template>

JS: JS:

if (Meteor.isClient) {
    Template.parall.onRendered(function(){
        $(".parallax").parallax();
    });
}

if (Meteor.isServer) {
    Meteor.startup(function () {
        // code to run on server at startup
    });
}

Have you tried rendering your images with css? 您是否尝试过使用CSS渲染图像?

.parallax {
 background-image: url("/background1.jpg");
}

Simply try removing "public" from your img src, and instead use "/background1.jpg". 只需尝试从img src中删除“ public”,然后使用“ /background1.jpg”即可。 [ Assuming "public" directory is in your route project folder ]. [假设“公共”目录在您的路线项目文件夹中)。

You dont have to specify "public" while accessing resources stored in public directory. 访问存储在公共目录中的资源时,不必指定“公共”。 It is one among the few reserved directory names in meteor structure. 它是流星结构中为数不多的保留目录名称之一。

将div.parallax包裹在div.parallax-container中

Wrap the div in a parallax-container as already posted 如前所述,将div包裹在视差容器中

<div class="parallax-container">
    <div class="parallax"><img src="/images/parallax1.jpg"></div>
</div>

and add the following in your CSS 并在CSS中添加以下内容

.parallax{
    position:static!important 
}

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

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