Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8165307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:30:20+00:00 2026-06-06T19:30:20+00:00

I am creating a light box. When you hover over an image, the accompanying

  • 0

I am creating a light box. When you hover over an image, the accompanying text and relative images should also light up. However, the accompanying text is not.

They are all within the same class, but the text is a within a p tag further down the page.

Here is the website: http://www.rosiehardwick.co.uk

.nationaltrust {
background-color:red;
-webkit-transition: opacity 0.5s linear; 
opacity: 0.05;
}


.nationaltrust:hover {
-webkit-transition: opacity 0.5s linear; 
opacity: 1;
}

And html:

 </div>
<div id="image-wrap">
<div class="nationaltrust">
<img src="/images/ss.gif"/>
<img src="/images/aw.gif"/>
</div>

</div>

<div id="para-wrap">
<div class="nationaltrust"><p>
blahblah</p></div></div>

Thanks for any help, I’m quite new to this,

Tom

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T19:30:21+00:00Added an answer on June 6, 2026 at 7:30 pm

    I think you might misunderstand how the class/hover thing is supposed to work. When you write:

    .someClass:hover {color: red}
    

    You’re telling the browser “when any element with the class ‘someClass’ is hovered, make its color red”. It doesn’t mean “Make every element with the class ‘someClass’ red“.

    If I understand you correctly, you want hovering one element to change the style of a separate element. There are two ways of doing this – 1) put both the image and text inside a single containing element, then apply the :hover styles to them, or 2) use some javascript to make the connection between the two and adjust styles as needed.

    For #1:

    HTML:

    <div class="nationalTrust">
        <img src="/images/ss.gif"/>
        <p class="caption">Blah blah</p>
    </div>
    

    CSS:

    .nationalTrust:hover img {
        opacity: 1;
        background-color: red;
    }
    
    /* Just to show that you can have different styles for the text and image*/
    .nationalTrust:hover .caption {
        opacity: 0.85; 
    }
    

    That might not work, for what you want to do: It may be too restrictive to contain both the image and text inside one element. In that case, some javascript is the way to go. This example uses jQuery to simplify things:

    HTML:

    <img class="nationaltrust" src="/images/ss.gif"/>
    
    <p class="nationaltrust-caption">Blah-blah</p>
    

    Javascript:

    $(function(){
        $('img.nationaltrust').hover(
            function(){
                $('p.nationaltrust-caption').addClass('active'); //When the image is hovered, add the 'active' class to the caption
            },
            function(){
                $('p.nationaltrust-caption').removeClass('active'); //Remove the class when un-hovered.
            }
        )
    });
    

    Now, that javascript is very quick and dirty, but it should do what you want. The problem is that you’re going to need to write separate code for each image/caption you have on the page (presuming they all have different classes). It’s easy enough to write the HTML and JS so that they’ll work with any number of different images – let us know if you’d like to see that example, too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a silver light 4 application which shows Hindi text using my
I am creating an application of light in which i am displaying image of
I am creating a light RPG game where a character is able to equipment
I hope someone out there can shed some light on the topic of creating
Creating liquid layouts is an immense pain. Now, I totally understand that tables should
Creating a JApplet I have 2 Text Fields, a button and a Text Area.
I'm creating an inset border effect between paragraphs by using a light border as
I am creating a Silverlight 4 application with Entity Framework, RIA Services and MVVM-Light
I've been using the popular MVVM Light toolkit: here for creating my Windows Phone
hopefully someone here can shed some light on my issue :D I've been creating

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.