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. Vertical Split Background Colors

Vertical Split Background Colors

Scheduled Pinned Locked Moved General Discussion
4 Posts 2 Posters 2.0k 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
    extra-vitamins
    wrote on last edited by
    #1

    Hey there!
    I have two questions:

    1. How can I make the background color of a page two colors split vertically (ex: left half red, right half blue, split in the middle)?
    2. Is there any way I could also integrate the random color script from this thread: http://laythemeforum.com/topic/674/random-color-background
      So that every time you refresh the page, each half is a different color?

    Thanks!

    1 Reply Last reply
    0
    • mariusjopenM
      mariusjopenM
      mariusjopen
      Global Moderator
      wrote on last edited by
      #2

      Hi @extra-vitamins

      1. I would go for a background image.

      2. That needs some coding. You are fit with jQuery?

      Best!

      Marius

      www.mariusjopen.world

      1 Reply Last reply
      0
      • E
        E
        extra-vitamins
        wrote on last edited by
        #3
        1. Okay, cool. That's what I did originally but I wasn't sure if it was maybe cleaner/faster to code it...
        2. I've just been learning when things come up. Not sure I can figure this one out on my own.
        1 Reply Last reply
        0
        • mariusjopenM
          mariusjopenM
          mariusjopen
          Global Moderator
          wrote on last edited by
          #4

          Hi @extra-vitamins

          I did not do the whole thing but actually you just need to copy the code and use it again_

          <script>
              var colors = ["#fff", '#000', '#f0f', '#0ff', '#00f', '#ff0', '#0f0']
              Frontend.GlobalEvents.on("work", function(layoutObj, type, obj){
                  if(obj.slug == "frontpage"){
                      var ix = getRandomInt(0, colors.length);
                      var color = colors[ix];
                      jQuery('.colors-1').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)
              // Using Math.round() will give you a non-uniform distribution!
              function getRandomInt(min, max) {
                  min = Math.ceil(min);
                  max = Math.floor(max);
                  return Math.floor(Math.random() * (max - min)) + min;
              }
              
              
                  var colors2 = ["#fff", '#000', '#f0f', '#0ff', '#00f', '#ff0', '#0f0']
              Frontend.GlobalEvents.on("work", function(layoutObj, type, obj){
                  if(obj.slug == "frontpage"){
                      var ix = getRandomInt2(0, colors2.length);
                      var color = colors2[ix];
                      jQuery('.colors-2').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)
              // Using Math.round() will give you a non-uniform distribution!
              function getRandomInt2(min, max) {
                  min = Math.ceil(min);
                  max = Math.floor(max);
                  return Math.floor(Math.random() * (max - min)) + min;
              }
          </script>
          

          Then you make two divs:

          <div class="colors-1">COLORS-1</div>
          <div class="colors-2">COLORS-2</div>
          

          This is a quick and dirty method and you might do some adjustments to get it work. But this is how you colud do it.

          Otherwise use images.

          Best!!

          Marius

          www.mariusjopen.world

          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
          I
          Ingi
          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