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. Text colour according to background contrast

Text colour according to background contrast

Scheduled Pinned Locked Moved General Discussion
10 Posts 2 Posters 398 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.
  • X Offline
    X Offline
    XLD
    wrote on last edited by
    #1

    Dear support team,

    I'm using fullscreen images (Carousel Addon).
    Is it possible to display texts (Menus, Text blocks, Captions, Numbers,…) on top of these images according to the contrast of the background?

    In terms of:
    Dark images > White Text
    Bright images > Black Text

    Would be fantastic if you could provide a solution for this.
    Thanks in advance!

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

      I think some people have used mix blend mode

      https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-mode

      to have text that changes its color based on its background

      so do u put your numbers and captions on top of the carousel?

      do you put text blocks on top of your carousel?

      can u post a screenshot or send a link?

      X 1 Reply Last reply
      0
      • arminunruhA arminunruh

        I think some people have used mix blend mode

        https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-mode

        to have text that changes its color based on its background

        so do u put your numbers and captions on top of the carousel?

        do you put text blocks on top of your carousel?

        can u post a screenshot or send a link?

        X Offline
        X Offline
        XLD
        wrote on last edited by
        #3

        @arminunruh

        Hi Armin,

        numbers, captions and text blocks are all on top of the carousel with mix blend mode on (difference).

        This works great on plain and calm backgrounds.
        But gets quite messy in terms of readability when it comes to detailed photos (s. screenshot).

        Just wondered if there's a smarter "global" solution than targeting each illegible element…

        ![0_1664541638063_mixblend.jpf](Uploading 100%)

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

          the screenshot doesnt show

          X 1 Reply Last reply
          0
          • arminunruhA arminunruh

            the screenshot doesnt show

            X Offline
            X Offline
            XLD
            wrote on last edited by XLD
            #5

            @arminunruh mixblend.jpg<

            Mix blend works great on plain and high contrast backgrounds.
            But gets close to illegible when it comes to photos (s. screenshot).

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

              can you send a link

              X 1 Reply Last reply
              0
              • arminunruhA arminunruh

                can you send a link

                X Offline
                X Offline
                XLD
                wrote on last edited by XLD
                #7

                @arminunruh

                Sorry - can't provide a link yet.
                Hope the visual below clarifies what I mean…

                mm.jpg

                1 Reply Last reply
                0
                • X Offline
                  X Offline
                  XLD
                  wrote on last edited by
                  #8

                  @XLD said in Text colour according to background contrast:

                  @arminunruh

                  Hi @arminunruh,

                  did you have a chance to think about the above issue?
                  Thanks in advance!

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

                    you would need to write js code to see which elements are visible right now

                    either use https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect

                    or

                    https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API

                    use different classes for rows where for one class the text should be one color and for the other the text should be another color

                    then change the text colors depending on what type of row is visible atm

                    i dont have time to custom code this for you but if you want to spend €€€ on this you can write me at info@laytheme.com

                    X 1 Reply Last reply
                    0
                    • arminunruhA arminunruh

                      you would need to write js code to see which elements are visible right now

                      either use https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect

                      or

                      https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API

                      use different classes for rows where for one class the text should be one color and for the other the text should be another color

                      then change the text colors depending on what type of row is visible atm

                      i dont have time to custom code this for you but if you want to spend €€€ on this you can write me at info@laytheme.com

                      X Offline
                      X Offline
                      XLD
                      wrote on last edited by
                      #10

                      @arminunruh

                      Thank you for your reply and the solutions provided.

                      Just in case you got me wrong:
                      I created a one row layout with a fullscreen carousel (fixed height: 100vH, filled slides) and text elements "on image".

                      Now I'm trying to change these elements (e.g. the site title) on a specific carousel slide (2) like this:

                      .slug-fullscreen
                      .lay-carousel-slide:nth-child(2)
                      .sitetitle span{
                      color: white !important;
                      }

                      Does this make any sense?

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