【问题标题】:Parallax Not functioning properly : Django视差无法正常运行:Django
【发布时间】:2019-07-04 10:39:17
【问题描述】:

我已经下载了模板:http://keenthemes.com/preview/megakit/

在索引页面上有一个视差:

<div class="js__parallax-window" style="background: url(img/1920x1080/04.jpg) 50% 0 no-repeat fixed;">
        <div class="container g-text-center--xs g-padding-y-80--xs g-padding-y-125--sm">
            <p class="text-uppercase g-font-size-14--xs g-font-weight--700 g-color--white-opacity g-letter-spacing--2 g-margin-b-50--xs">Testimonials</p>
            <div class="s-swiper js__swiper-testimonials">
                <!-- Swiper Wrapper -->
                <div class="swiper-wrapper g-margin-b-50--xs">
                    <div class="swiper-slide g-padding-x-130--sm g-padding-x-150--lg">
                        <div class="g-padding-x-20--xs g-padding-x-50--lg">
                            <div class="g-margin-b-40--xs">
                                <p class="g-font-size-22--xs g-font-size-28--sm g-color--white"><i>" I have purchased many great templates over the years but this product and this company have taken it to the next level. Exceptional customizability. "</i></p>
                            </div>
                            <div class="center-block g-hor-divider__solid--white-opacity-lightest g-width-100--xs g-margin-b-30--xs"></div>
                            <h4 class="g-font-size-15--xs g-font-size-18--sm g-color--white-opacity-light g-margin-b-5--xs">Jake Richardson / Google</h4>
                        </div>
                    </div>
                    <div class="swiper-slide g-padding-x-130--sm g-padding-x-150--lg">
                        <div class="g-padding-x-20--xs g-padding-x-50--lg">
                            <div class="g-margin-b-40--xs">
                                <p class="g-font-size-22--xs g-font-size-28--sm g-color--white"><i>" I have purchased many great templates over the years but this product and this company have taken it to the next level. Exceptional customizability. "</i></p>
                            </div>
                            <div class="center-block g-hor-divider__solid--white-opacity-lightest g-width-100--xs g-margin-b-30--xs"></div>
                            <h4 class="g-font-size-15--xs g-font-size-18--sm g-color--white-opacity-light g-margin-b-5--xs">Jake Richardson / Google</h4>
                        </div>
                    </div>
                    <div class="swiper-slide g-padding-x-130--sm g-padding-x-150--lg">
                        <div class="g-padding-x-20--xs g-padding-x-50--lg">
                            <div class="g-margin-b-40--xs">
                                <p class="g-font-size-22--xs g-font-size-28--sm g-color--white"><i>" I have purchased many great templates over the years but this product and this company have taken it to the next level. Exceptional customizability. "</i></p>
                            </div>
                            <div class="center-block g-hor-divider__solid--white-opacity-lightest g-width-100--xs g-margin-b-30--xs"></div>
                            <h4 class="g-font-size-15--xs g-font-size-18--sm g-color--white-opacity-light g-margin-b-5--xs">Jake Richardson / Google</h4>
                        </div>
                    </div>
                </div>
                <!-- End Swipper Wrapper -->

                <!-- Arrows -->
                <div class="g-font-size-22--xs g-color--white-opacity js__swiper-fraction"></div>
                <a href="javascript:void(0);" class="g-display-none--xs g-display-inline-block--sm s-swiper__arrow-v1--right s-icon s-icon--md s-icon--white-brd g-radius--circle ti-angle-right js__swiper-btn--next"></a>
                <a href="javascript:void(0);" class="g-display-none--xs g-display-inline-block--sm s-swiper__arrow-v1--left s-icon s-icon--md s-icon--white-brd g-radius--circle ti-angle-left js__swiper-btn--prev"></a>
                <!-- End Arrows -->
            </div>
        </div>
    </div>

视差图像基本上是用行中的属性定义的:

 <div class="js__parallax-window" style="background: url(img/1920x1080/04.jpg) 50% 0 no-repeat fixed;">

现在要在 django 中使用相同的内容,我将图像的 url 更改为以下内容:

<div class="js__parallax-window" style="background: url({% static 'img_events/1920x1080/04.jpg' %}) 50% 0 no-repeat fixed;" >

在这种情况下,视差无法正常工作的唯一问题是,视差图像大小应该只有 50%,但它会导致推荐和背景图像的高度和位置不匹配,而相同的代码在模板中工作

【问题讨论】:

  • 所以它可以工作,但图像的大小是问题?
  • 你可以这么说,是的不是图像的大小,但我更愿意说内容相对于视差图像的位置

标签: django python-3.x django-templates


【解决方案1】:

这里唯一的问题是&lt;!DOCTYPE html&gt; 没有包含在页面的开头。

【讨论】:

    猜你喜欢
    • 2021-12-12
    • 2021-06-16
    • 1970-01-01
    • 2016-03-16
    • 1970-01-01
    • 2021-04-22
    • 2015-12-08
    • 2019-02-08
    • 1970-01-01
    相关资源
    最近更新 更多