Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. General Discussion
  3. random background olor on split screen

random background olor on split screen

Scheduled Pinned Locked Moved General Discussion
3 Posts 2 Posters 443 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E
    E
    etienne
    wrote on last edited by
    #1

    Hi,
    for a split screen web site done like this :
    https://laytheme.com/tutorials/create-a-splitscreen-website.html

    Is 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/topic/674/random-color-background

    On 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

    1 Reply Last reply
    0
    • arminunruhA
      arminunruhA
      arminunruh
      Global Moderator
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • arminunruhA
        arminunruhA
        arminunruh
        Global Moderator
        wrote on last edited by
        #3

        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>
        
        1 Reply Last reply
        0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        Online Users
        Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
        laytheme.com
        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Recent
        • Tags
        • Popular
        • Users
        • Search