<![CDATA[ Calling Dynamic CSS File - My Forums]]> https://forums.modx.com/thread/?thread=104643 <![CDATA[Calling Dynamic CSS File]]> https://forums.modx.com/thread/104643/calling-dynamic-css-file#dis-post-562805
Draft Site:
https://c0092.paas1.tx.modxcloud.com/

Current inline styling:
.parallax {
        section.module.parallax-[[+idx]] {
          background-image: url("[[+parallaxImage]]");
          background-position: 50% 0;
          background-repeat: repeat;
          background-attachment: fixed;
          background-size: cover;
          /* background-color: rgba(0,123,255,0.4); */
          background-blend-mode: screen;
          }

HTML:
<section class="module parallax parallax-[[+idx]]" data-type="background" data-speed="10">
                    <div class="parallax-container">
                        <h2 class="mx-auto d-flex justify-content-center"><span>[[+parallaxTitle]]</span></h2></span>
                    </div>
                </section>

]]>
ceramicmonster Nov 17, 2018, 09:07 PM https://forums.modx.com/thread/104643/calling-dynamic-css-file#dis-post-562805
<![CDATA[Re: Calling Dynamic CSS File]]> https://forums.modx.com/thread/104643/calling-dynamic-css-file#dis-post-562807
I would do it like that:
.parallax {
        section.module.parallax {
        background-position: 50% 0;
        background-repeat: repeat;
        background-attachment: fixed;
        background-size: cover;
        background-blend-mode: screen;
}

<section class="module parallax parallax" style="background-image: url(...);" data-type="background" data-speed="10">
...
</section>


Or
.parallax {
        section.module.parallax {
        background-position: 50% 0;
        background-repeat: repeat;
        background-attachment: fixed;
        background-size: cover;
        background-blend-mode: screen;
}

.p-1 {background-image: url(...);}
.p-2 {background-image: url(...);}
.p-3 {background-image: url(...);}

<section class="module parallax parallax p-1" data-type="background" data-speed="10">...</section>
<section class="module parallax parallax p-2" data-type="background" data-speed="10">...</section>
<section class="module parallax parallax p-3" data-type="background" data-speed="10">...</section>


A good option is also to use javascript to load the right image when parallax comes to viewport. I think that inline CSS for background-image is a good option smiley If you realy want a separate CSS then create a resource with type CSS and generate all backgrunds there. I don't see a point to create a separate CSS for each parallax.

Basically this is not a modx problem smiley Figure it out what is the best way for you and we can give you advice how to do it in modx.

]]>
theuros Nov 18, 2018, 08:34 AM https://forums.modx.com/thread/104643/calling-dynamic-css-file#dis-post-562807
<![CDATA[Re: Calling Dynamic CSS File]]> https://forums.modx.com/thread/104643/calling-dynamic-css-file#dis-post-562806
Then in the head section of the template, you can do this:

<link rel="stylesheet" type="text/css" href="[[!*TvName]]"> 



Another common way to go is to write a custom snippet that evaluates the current conditions (for example, checking the current resource ID), and injects the appropriate CSS file this way:

$modx->regClientCSS('path/to/css/file');




]]>
BobRay Nov 18, 2018, 03:59 AM https://forums.modx.com/thread/104643/calling-dynamic-css-file#dis-post-562806