I am looking to emphasize text in alignment with the slide image

I'm currently in the process of building a movie information page similar to what you see in cinemas, where I pull images and titles from an external source.

The goal of my code is to dynamically highlight the title corresponding to each image when the slideshow transitions, indicating which movie is being displayed. However, I'm struggling with establishing the proper connection between the images and texts.

Any assistance or guidance on this matter would be greatly appreciated. Thank you.

html:

<table align="center">
          <tr>
            <td>

              <!--   slide -->

              <div class="slide"  style="width: 550px; height: 620px" align="center">
                <ul class="home_ul">
                  <c:forEach var="img" items="${moviedata }" varStatus="no">
                    <a href="../movielist/MDetail?mid=${img.mid }"><li class="home_li"><img src="../m_img/movie/${img.imgurl}"
                      alt=""  width="500px"  height="600px"  name="color${no.index }" /></li></a>
                  </c:forEach>
                </ul>
              </div>

            </td>
            <td>

              <!--   movielist-->

              <div>
                <ul class = "mlist">
                  <c:forEach var="rank" items="${moviedata }" varStatus="no">
                  <li>
                    ${no.index + 1 }.  <a  href="../movielist/MDetail?mid=${rank.mid }">${rank.name }</a>
                  </li>
                  </c:forEach>
                </ul>
              </div>

            </td>
          </tr>
 </table>



html Result :

...

CSS:

<style>
.mlist{
  list-style:none;
  display:flex;
  align-content:flex-start;
  flex-direction: column;
  flex-wrap: wrap;
  width: 250px;
  text-align: left;
}

.mlist li {
  display:inline-block;
  border:1px solid black;
  border-top: 1px solid black;
  width:260px;
  height:50px; 
  margin:3px 0 0;
}
.mlist li:hover {
  border:1px solid red; height:50px;
}

</style>


JavaScript:

const all = ele => document.querySelectorAll(ele) ...

Answer №1

To effectively keep track of your slide, consider utilizing variables.

As you navigate through the slides, use these 2 variables to store the ID of the current highlighted element and the element from which you want to remove the highlight. Remember to execute this script every time you switch slides.

If you are working with positions in your scenario, apply the style to the new position and remove it from the previous position.

Linking text to an image depends on your specific implementation. They could share a common position value or a container element. When using a position with an ID attribute, remember that IDs cannot start with a number. You can concatenate a string with a numeric value like "myElementId_"+ pos to ensure validity in HTML.

This results in myElementId_1, which is a valid HTML format.

Simply add styling to this element and remove it from the previous one as needed.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exclude all elements within a div with the class name using jQuery's serialize() function

I am attempting to filter out hidden form values from the jQuery output of serialize(). The invisible inputs/selects are nested within div.ui-tabs-hide elements. I need to include all input and select elements within divs that do not have the ui-tabs-hide ...

Utilize Angular to connect NavBar partial HTML with a controller variable

Encountering an issue where my search term in the navigation bar is not binding to a controller variable due to it being out of scope. Attempting to utilize ng-model in the partial HTML navbar to connect the input value with the controller variable. Parti ...

What is the best way to make the Bootstrap navbar stay fixed at the top of the

I am currently experiencing an issue with the Bootstrap navbar while using version 5.0. Whenever the Bootstrap navbar expands, the content below it also moves down, which is not the desired behavior. I want the content to remain in place. I tried set ...

Searching for an index of a value fails after functions have been anonymized

I recently created a basic javascript animation that involves swapping images on a carousel and fading them in and out. My goal is to generalize the functions so that I can repurpose them for other projects. While most of the animation is functioning corr ...

HTML Plant with background removed

I have been attempting to create a tree structure similar to the image provided. However, I am encountering difficulty in getting the background stripes to align properly for a specific row. When resizing the browser window, the stripes do not remain fixed ...

Showing a dynamic number of elements based on the value of a CSS variable can be achieved by manipulating

Within my code, I have a CSS variable called --num that holds a numerical value. Under the same parent, I have N HTML elements as children. Element n and element n+1 are neighboring siblings. Essentially, all N elements are adjacent to each other. Is the ...

What is the best technique for vertically aligning text within two divs placed side by side?

Thank you for taking the time to read this. I have a piece of code similar to the one below. While using line-height works when there is only one line of text, it becomes problematic when the comments section contains multiple lines. I am wondering what w ...

Is it possible to display a photo pixel by pixel using CSS and HTML?

Have you ever considered if it would save space to print out an entire image using CSS and HTML pixel by pixel? I'm not referring to using background-image or anything like that, but something along these lines: <div style="height:1px, width:1px, ...

Modifying the TR class appears to be ineffective in this instance

I am attempting to update the TR className using JavaScript. However, for some reason it does not appear to be working properly (please note that it must also work in IE8). <html> <head> <style> tr.test {background-color:#000000; ...

The combination of Bootstrap and Django does not support responsive design

My code is not working correctly, and I'm struggling to identify the errors. The website I'm working on has subpages, but the responsive design doesn't seem to be functioning properly. Could this issue be related to mistakes in my HTML/CSS c ...

Does Vue.js interfere with classList.remove functionality?

When working with Vue.js, I encountered an issue where elements would briefly flash curly braces to the user before being hidden. To combat this problem, I implemented the following solution: HTML: <div class="main hide-me" id="my-vue-element"> ...

problem with creating a django template script

Hello, I am currently working on a code that is responsible for executing various functions within the template. I have utilized scripts to verify these functions using if-else statements and for loops. However, I am encountering some errors during this pr ...

Execute a webpage in the background using PHP

Currently, I'm working on creating a basic PHP script to fetch four images from a server. The catch is that each time I retrieve a new image, I have to access a webpage first - like this: http://example.com/Set.cgi?Image=1 I don't have the abili ...

Generate a link that can easily be shared after the content has loaded using

One feature on my website involves a content container that displays different information based on which list item is clicked (such as news, videos, blogs, etc.). This functionality is achieved by using jQuery's load method to bring in html snippets ...

Creating a custom design for a dropdown menu in the Bootstrap navbar

My Bootstrap navbar has a unique color scheme for the navbar itself and the letters, as indicated in the following CSS: .jumbotron { background-color:#2d4c60 !important; } nav.navbar { background-color: #2d4c60; } .nav.navbar-nav.navbar-ri ...

Learn how to display only certain elements when triggered by the click of another

I have developed a tab system where each tab contains a unique set of questions and answers. The structure of the tabs is exactly as I envisioned, but I am facing challenges with toggling the display of answers when their respective questions are clicked. ...

What is the best way to send a single variable in an ajax request to multiple PHP files?

How can I send a single variable in an ajax call to multiple PHP files using the URL method? Here is my data: <select name="districts" id="district_list" class="update" onChange="getDist(this.value)" > <option value="d1">east</option> ...

Customizing Paths in Express Handlebars

I have a query regarding setting up custom folders in Express.js Here's my situation: I need to implement logic where if a specific name is present in my database, the paths for CSS and JS files should be altered before rendering. By default, my pat ...

What is the best way to interact with all the rendered DOM elements in React that were created using the map method

return <div> <div >{'Audios'}</div> {urls.map(url => <div > <audio controls src={url} ref={(element) => this.audioRefs.push(element)} /> </div>)} </div>; I a ...

triggering phpmailer to send an email upon data deletion

My current system includes a form that successfully adds a user to a MySQL database table and also sends an email with the new information to a specified address. However, I am now facing an issue with implementing a form that is meant for deleting record ...