Below you see two columns. One with texts from the English. To the right Danish articles. It’s made by two Query Loops, one for each category. In this way you can create multilingual sites.
Category: English Tutorials
WordPress tutorials in English.
-
Animation and parallax – custom code in WordPress
Animations, Effects and Custom Code in WordPress
Animations and Parallax
Plugin: Blocks Animation – CSS Animations for Gutenberg Blocks
Parallax Javascript Library
Rellax.js
Rellax.js
Here you can download Rellax.js:
Rellax need this script at the end of your page or post:
<!-- initiate Rellax Js --> <script> // Place this script at the end of the page. // Start Rellax var rellax = new Rellax('.rellax'); // Destroy and create again parallax with previous settings // rellax.refresh(); </script>
How can I give a <div> or similar container elements full width?
Here you have to have a closer look at the WP code. In your browser try to inspect a div, and note it’s width. If you do this you can see, that the div has a class named alignfull. Add this class to the WP markup:
<!-- Put the cover inside a div element --> <div class="rellax alignfull" data-rellax-speed="3" style="width:100vw;">
Don’t tell it.
Show it!
CSS animations
How to add custom code
e.g. from jsFiddle or CodePenCustom Code: CSS, HTML and JavaScript
And yes – in this particular order:
- Add a custom HTML block.
- Copy the CSS and place it in a <style> element.
- Next insert the HTML
- After the HTML-element(s) add theJavaScript.
In the Custom HTML block the code above could look like this:
<style> #square { background-color: yellow; width: 125px; height: 125px; border: 3px solid black; } @keyframes example { from {left: 0px;} to {left: 200px} } .animate { position: relative; animation-name: example; animation-duration: 4s; } </style> <!-- Her følger HTML --> <div id="square"></div> <h3>Click the yellow square</h3> <script> let runAnimation = function(){ square.classList.add("animate"); setTimeout(clearClass, 4000); } // element.addEventListener("click", myAddClassFunction); square.addEventListener("click", runAnimation); // let clearClass = function(){ square.classList.remove("animate"); } </script>
Click the yellow square!
Custom Code in WP
Animations
Parallax
CSS
JavaScriptMaps
… and much more …
Q.E.D.
-
Animation
This animation is made by the Animate Gutenberg Blocks Plugin.
-
Gallery from w3 tutorial
from this turtorial: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_slideshow
-
JSON Array in WP
This page is a demonstration of the turotial “JSON Band List”. Here the contents of the JSON band list is looped out in my post.
let bands = { "List": [ { "Band": "The Kinks", "Stage": "Blue", "Image": "https://multimusen.dk/wp-content/uploads/image-4-1.png" }, { "Band": "Velvet Underground", "Stage": "Orange", "Image": "https://multimusen.dk/wp-content/uploads/punk.jpeg" }, { "Band": "Aura", "Stage": "Green", "Image": "https://multimusen.dk/wp-content/uploads/image-3-1.png" }, { "Band": "Ozzy Osborne", "Stage": "Black", "Image": "https://multimusen.dk/wp-content/uploads/manga-band.jpeg" }, { "Band": "Mozart Rock Experience", "Stage": "Pink", "Image": "https://multimusen.dk/wp-content/uploads/manga-band.jpeg" }, { "Band": "Sigurds Ulvetime", "Stage": "Blue", "Image": "https://multimusen.dk/wp-content/uploads/manga-band.jpeg" }, { "Band": "Pink Floyd", "Stage": "Orange", "Image": "https://multimusen.dk/wp-content/uploads/manga-band.jpeg" } ] }
for ( let i = 0; i
" result.innerHTML += "" result.innerHTML += bands.List[i].Band + "
" result.innerHTML += ""
}
Rellax – in practise
Here is a parallax effect made via the Rellax library. Here is the recipe:
- Add the divs that you want to animate.
- At the bottom of the page add the Rellax Library
Also see this page. There you’ll see the actual code.
Images
Convert the image to HTML and add the relevant data.
Rellax in a cover block
Parallax Effects by Rellax Js
Demonstration of the Rellax Js Library.
Stray <p> tags
If you have whitespace in the code WP will add <p> tags, and such tags may ruin you JavaScript – or at least throw errors in the console. This will happen as soon as you save the page or post. This is most annoying.
That’s why there is no space between the tags in the code above.
In your editor you can install a plugin that will remove whitespace in the code.
You can animate any HTML element, be it <p>, <img>, <article>, <figure> etc.
Karrusel
Karusellen er fremstillet i Kadence Blocks “Gallery Adv.”