Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • 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 1.5k Views
  • 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 Offline
    E Offline
    extra-vitamins
    wrote on Oct 11, 2017, 12:38 AM 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:4567/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
    • M Offline
      M Offline
      mariusjopen
      Global Moderator
      wrote on Oct 11, 2017, 11:56 AM 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 Offline
        E Offline
        extra-vitamins
        wrote on Oct 11, 2017, 6:43 PM 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
        • M Offline
          M Offline
          mariusjopen
          Global Moderator
          wrote on Oct 13, 2017, 8:24 AM 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
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes

          3/4

          Oct 11, 2017, 6:43 PM


          I also code custom websites or custom Lay features.
          💿 Email me here: 💿
          info@laytheme.com

          Before you post:
          1. When using a WordPress Cache plugin, disable it or clear your cache.
          2. Update Lay Theme and all Lay Theme Addons
          3. Disable all Plugins
          4. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"

          This often solves issues you might run into

          When you post:
          1. Post a link to where the problem is
          2. Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
          3. If the problem is difficult to explain, post screenshots / link to a video to explain it
          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.
          3 out of 4
          • First post
            3/4
            Last post
          0
          • Recent
          • Tags
          • Popular
          • Users
          • Search