CSS-only way to change underlying elements property?

Is there a method to “passively” (with CSS only) change the body’s background when a “hover”-event is detected on a element on the page?

Something like

Read More

body div:hover which would trigger the body’s background-image

I’d like to do this that way because I have no idea of coding but run a wordpress-site…

Related posts

Leave a Reply

2 comments

  1. There are no CSS parent selectors, but you may be able to achieve your goal by using a fixed-position div with a negative z-index, which is a sibling of the hovered element:

    .fixed {
      position: fixed;
      z-index: -1;
    }
    
    button:hover ~ .fixed {
      left: 0px;
      top: 0px;
      height: 100%;
      width: 100%;
      background: yellow;
    }
    <button>Hover over me</button>
    <p>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    </p>
    <button>Hover over me</button>
    <div class="fixed"></div>

    Fiddle