Is there a way to change a target div's text when hovering over other div's using css only?

user10478903

I'm working with html, css and php to make a row of image divs. I want to be able to hover over the images individually and have their description text display in a separate div (DivB) in the next row below.

This is the basic structure:

<div class="pic1">Display Picture 1 here</div>
  <div class="pic2">Display Picture 2 here</div>
  <div class="pic3">Display Picture 3 here</div>
  <div class="pic4">Display Picture 4 here</div>
<div class="text-info">Description Text for all above div's displayed here on hover of above div's.</div>

In other words:

If I hover over Image 1, image 1's description is shown in DivB.
If I hover over Image 2, image 2's description is shown in DivB.
If I hover over Image 3, image 3's description is shown in DivB.
Etc.

Parameters:

  1. How do I do this as a css-only solution?
  2. No Jquery.
  3. I may have to do this with up to 1,000 images, so minimizing the code without repeating functions (a thousand times), by using something like arrays or loops would be very valuable.

I have a working solution using Jquery and css as a fiddle here: https://jsfiddle.net/70chk8yn/

I've looked up numerous css examples and fiddles, but not found any close enough to this example for me to use.

vickygill

Here's a working fiddle

#text-info:after {
  content: "Description Text for all above div's displayed here on hover of above div's.";
}

.pic1:hover~#text-info:after {
  content: 'The description for picture 1.';
}

.pic2:hover~#text-info:after {
  content: 'Picture 2 description.';
}

.pic3:hover~#text-info:after {
  content: 'The description for picture 3.';
}

.pic4:hover~#text-info:after {
  content: "Picture 4's description.";
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Is there a way to change the appeareance of an html text when hovering on the div that contains it?

Display DIV when hovering another DIV's child CSS

Change the Brightness of a div when hovering over another div

Change class of other div when hovering on one div

position: absolute; only visible when hovering over the div

Expand image only when hovering over containing div

How to change class of separate div when hovering over link using JQuery

Change color of icon when hovering over div in which it is contained

Getting 2 divs to change colour when hovering over 1 div

CSS div that appears when hovering on anchor; keeping it visible while hovering over div

How to display a div when hovering over an image using CSS/HTML + Transitions?

How to trigger div visibility when hovering over list item in CSS?

How would I change a button's text when it's hovered over using css?

CSS: What's a better way to overlay an image over a div border?

change css of one div by hovering on another div

Change a div`s background image when hover over the image

Change colour of svg paths when hovering over it's container

Hovering over 1 div to change content in another

Hovering over image and displaying text in another div

Change div's text with a button

Displaying button when hovering over div in TailwindCSS

Changing divs when hovering over a different div

Change image when hovering over a list of text

Change image when hovering over text with JavaScript

Using only CSS, show div on hover over <a>

How to change nav text color when scrolled over other div anchors in the page

How to change div's css using toogleClass properly?

Change colors of spans when hovering parent div

How to centre a <div> within several other <div>s (using a mixture of w3.css and css)