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

Choose Background color

Scheduled Pinned Locked Moved General Discussion
4 Posts 4 Posters 874 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.
  • A
    A
    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
      RichardR
      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
        R
        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
          arminunruhA
          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

          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