Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

231
Views
Change page background when hovering over a link

I want to have two different links and when hovering over one it changes the entire PAGE background to a different background-image-url. Then when I hover over the second link it changes the background-image-url to another picture. Is this possible? I am using Angular, I was thinking at first I could do this in css but I now think something more will be required. Any guidance would be greatly appreciated.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

It won't be possible with pure CSS because selectors are unable to ascend.

What you're trying to achieve can be easily done though. Just attach hover events to the links and in the event handlers, add a certain CSS class to the page. And then define the styles for that class of course.

To add the class, what you need to do is set a state value to a certain value and in the page element, add *ngClass="{bgLink1: hovered === 'link1'}" or something like that. You get the idea.

about 4 years ago · Juan Pablo Isaza Report

0

<!DOCTYPE html>
<html>
<body>
    <a href="https://stackoverflow.com" id="link1"></a>
    <a href="https://stackoverflow.com/questions" id="link2"></a>
</body>
<style>
body {
    background: red;
    display: flex;
    justify-content: center;
    align-items: center;
}

#link1 {
    margin: 5vw;
}

#link2 {
    margin: 5vw;
}

#link1:hover body {
    background: url('');/*any url you want for the picture*/
}

#link2:hover body {
    background: url('');/*another url you want for the other picture*/
}
</style>
</html>

I really hope I could help you, if not it wouldn't hurt to write the question another time but with code or something so I can understand what you want

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!