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. Choose Background color

Choose Background color

Scheduled Pinned Locked Moved General Discussion
4 Posts 4 Posters 288 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.
  • A Offline
    A Offline
    anagase
    wrote on last edited by anagase
    #1

    Hi guys!
    I would like to add to my site an option to let the user choose the background color.
    This is a nice example for that:
    https://www.photosalonhelga.com/

    Any idea or suggestions for including this?
    thank you as usual!!

    1 Reply Last reply
    0
    • RichardR Offline
      RichardR Offline
      Richard
      Global Moderator
      wrote on last edited by Richard
      #2

      Dear @anagase

      Thats a cool addition! :)

      If i am correct, you can create this will some basic knowledge of Custom HTML, CSS & JS:

      https://laytheme.com/documentation.html#custom-javascript

      https://www.khanacademy.org/computing/computer-programming/html-css

      We could apply this code using ' + More - +HTML ' in the Gridder or through 'Lay Options - Custom HTML & CSS '

      Screen Shot 2020-09-14 at 2.51.54 PM.png

      When we inspect the page, ( https://www.khanacademy.org/computing/computer-programming/html-css/web-development-tools/a/using-the-browser-developer-tools )

      we can see that each colour has a 'data-color'- attribute: with each having its own 'background-color'.

      Screen Shot 2020-09-30 at 11.38.54 AM.png

      Now when we look at the 'body' of the website we see the data-color attribute, controlling the background colour of the website:

      Screen Shot 2020-09-30 at 11.39.16 AM.png

      So when the Colour button is clicked on the website, based on what was clicked; the 'data-color' atrribute is changed in the 'body'

      I did some quick research and found what i think to be similar ideas:

      https://stackoverflow.com/questions/33555810/how-to-make-each-element-change-color-when-clicked

      https://stackoverflow.com/questions/7874320/updating-the-value-of-data-attribute-using-jquery

      I hope this helps, let me know :)

      Have a wonderful day and thank you for using Lay Theme

      Best
      Richard

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Remco van Dun
        wrote on last edited by
        #3

        Hi @anagase

        Do you perhaps care to share how you made this work on your website!? Looks great and trying to figure it out myself.

        best,
        Remco

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

          hey man!

          js like

          <script>
          jQuery(".blue").on("click", function(){
          jQuery("body").attr("data-bg-color", "blue");
          })
          </script>
          

          css like:

          body[data-bg-color="blue"],
          body[data-bg-color="blue"] #grid,
          body[data-bg-color="blue"] .cover-region-desktop .cover-inner,
          body[data-bg-color="blue"] #footer-region,
          body[data-bg-color="blue"] #custom-phone-grid, 
          body[data-bg-color="blue"] .cover-region-phone .cover-inner
          {
          background-color: blue;
          }
          

          then of course you'd need to add some html for your blue button and style it
          in "custom html at bottom"

          <div class="blue"></div>
          

          css:

          .blue{
          position: fixed;
          bottom: 20px;
          left: 50%;
          z-index: 10;
          transform: translateX(-50%);
          }
          

          something like that

          and then you'd need to create more buttons, not just blue

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          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
          R
          renno
          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