random background olor on split screen
-
Hi,
for a split screen web site done like this :
https://laytheme.com/tutorials/create-a-splitscreen-website.htmlIs there a way I can set a random background color for the right page each time someone load it.
I have tried this :
http://laythemeforum.com:4567/topic/674/random-color-backgroundOn the line that does it: if(obj.slug == "frontpage"){
Instead of "frontpage" I have tried to write the slug of my righ page, but nothing happens.
can anyone help,Thank you
-
you need to set the background of the .grid div container
so not
jQuery('body').css('background-color', color);
but
jQuery('.grid').css('background-color', color);
best to learn how to use the chrome inspector and how css works, you can google it
-
this code that is at the very end of the topic didn't work?
do you have a link to your website?<script> var colors = ["#fff", '#000', '#f0f', '#0ff', '#00f', '#ff0', '#0f0'] window.laytheme.on("newpageshown", function(){ var ix = getRandomInt(0, colors.length); var color = colors[ix]; jQuery('#grid, #custom-phone-grid, .cover-region-desktop, .cover-region-phone, #footer, #footer-custom-phone-grid').css('background-color', color); }); // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random // Returns a random integer between min (included) and max (excluded) function getRandomInt(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min)) + min; } </script>
I don't answer or check forum DMs, please just post on the forum.
Before you post:
Use the Search Feature. Maybe there is already a solution to your issue.
1. Update Lay Theme and all Lay Theme Addons
2. Disable all Plugins
3. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code ", click "Save Changes"
4. When using a WordPress Cache plugin, disable it or clear your cache.
Now see if your problem solved itself.
Go here, see if your problem is listed here:
Troubleshooting
When you post:
1. Post a link to where the problem is
2. If the problem is difficult to explain, post screenshots / link to a video to explain it