Adjusting the font color when hovering over multiline text

I am currently in the process of coding a website for my job, and I am working on changing the text color when it is hovered over. However, there seems to be a break in my code causing the text not to highlight all at once. Any guidance or suggestions on how to improve this would be greatly appreciated.

function updatemenu() {
  if (document.getElementById('responsive-menu').checked == true) {
    document.getElementById('menu').style.borderBottomRightRadius = '0';
    document.getElementById('menu').style.borderBottomLeftRadius = '5';
  } else {
    document.getElementById('menu').style.borderRadius = '0px';
  }
}
  .column {
  flex: 20%;
  height: 130px;
  padding: 10px;
  margin: 5px;
  text-align: center;
  text-decoration: none;
}

.container {
  display: flex;
  color: #FFFFFF;
  font-family: Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  font-size: 20px;
  text-decoration: none;
}

.container a {
  text-decoration: none;
  color: #FFFFFF;
}

a:hover {
  color: #977847;
<div class='header'>

  <div class="container">
    <span class="column">
          <a href=""> Address line one </a>
        <br>
        <a href=""> Address line two </a>
        <br>
        <br>
        <a> Follow Us: </a> <a href="https://www.facebook.com/"><i class="fa-brands fa-facebook-f" ></i></a>
     </span>
    <div class="column">
      <a> second column </a>
      <a> This is second column of our grid system</a>
    </div>
    <div class="column">
      <a> Third column </a>
      <a> This is third column of our grid system</a>
    </div>
  </div>
</div>

I have experimented with creating different classes based on the element, but due to being in a flexbox, the text only highlights when hovering over the entire section rather than just the text itself.

Despite trying to remove the breaks in the code with pre and white-space formatting, it has caused issues with the formatting of the header. Any assistance would be greatly appreciated. I have reviewed other solutions posted here and believe there may be an issue in my code that I have overlooked.

Answer №1

After contemplating the issue, I devised the following solution:

/*rest of code remains unchanged*/
span:hover a {
    color: #977847;
    transition: 0.3s;
    
}

span:hover i {
    color: #FFFFFF;
    transition: 0.3s;

}
/* rest of code unchanged*/
    
<!--Remaining code same-->
  <div class="container">
       <div class="column">
      <span style = "color: #977847;">
          <i class="fa-solid fa-location-dot"></i><a href=""> Address line one </a>
          <br>
          <a href=""> Address line 2 </a>
      </span>
<!--Remaining code same-->

Answer №2

It seems like you're looking to change the color of all links in a single column when that column is hovered over, is that correct?

If so, modify the selector for your last CSS rule (the one defining the hover color) in this way:

.column:hover a {
  color: #977847;
}

This means that when hovering over a .column element, the text color of all a links inside it will change.

(Please note that I've added some background styling to ensure white text is visible when not hovered)

function updatemenu() {
  if (document.getElementById('responsive-menu').checked == true) {
    document.getElementById('menu').style.borderBottomRightRadius = '0';
    document.getElementById('menu').style.borderBottomLeftRadius = '5';
  } else {
    document.getElementById('menu').style.borderRadius = '0px';
  }
}
body {
  background: #ccc;
}

.column {
  flex: 20%;
  height: 130px;
  padding: 10px;
  margin: 5px;
  text-align: center;
  text-decoration: none;
}

.container {
  display: flex;
  color: #FFFFFF;
  font-family: Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  font-size: 20px;
  text-decoration: none;
}

.container a {
  text-decoration: none;
  color: #FFFFFF;
}

.column:hover a {
  color: #977847;
}
<div class='header'>

  <div class="container">
    <span class="column">
          <a href=""> Address line one </a>
        <br>
        <a href=""> Address line two </a>
        <br>
        <br>
        <a> Follow Us: </a> <a href="https://www.facebook.com/"><i class="fa-brands fa-facebook-f" ></i></a>
     </span>
    <div class="column">
      <a> second column </a>
      <a> This is second column of our grid system</a>
    </div>
    <div class="column">
      <a> Third column </a>
      <a> This is third column of our grid system</a>
    </div>
  </div>
</div>

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

What are the solutions for resolving problems with the display and functionality of a multi-page form in Internet Explorer?

I am currently working on a form and you can view it at this link: http://jsfiddle.net/pPWr3/14/ While the form displays correctly in Chrome and Firefox, I am experiencing display and functionality issues when using Internet Explorer 9. The problems inclu ...

Issue with Bootstrap grid borders

I am currently working on a grid system that displays flight information in 10 columns, with a select button and price in 2 columns. I am facing an issue where adding a border to separate the select button section from the rest of the flight information on ...

Can a local image be incorporated into an HTML or CSS project through the use of Javascript or alternative methods?

I've been trying, but all I can manage is: <img width='220' height='280' src='chrome-extension://okjaohhbffepkcfacapapdhkmnebgiba/johnny.jpg' class="me"/> Unfortunately, this code only works in Chrome. Is there a ...

waiting to display information until it is necessary

I am currently working on optimizing my website for improved loading speed and responsiveness. Users can scroll through up to 4k images, apply filters, and sort them based on their preferences. Below is the code snippet for my filtering function: function ...

Transform your Email Template with Inline Styling to mimic a Bootstrap grid, ranging from col-md-6 to col-12 styling

Currently, I am looking to create an email template. Typically, I create my email templates with each content/row separated. However, this time I need to design an email template with a layout that consists of 2 columns on desktop and switches to 1 column ...

clear the input field of any entered text type

Just starting out with Javascript! Below is some code: This code is taken directly from the HTML page <form action="#" id="ToolKeywordSearch"> <input type="text" class="ProductFinderText" id="ToolSearchField"onblur="if(this.value==& ...

Implementing a feature that loads older posts on a webpage as users scroll down

Spent hours trying to get my site to automatically load older posts on scroll down with no luck. Any assistance is greatly appreciated :) After researching, [this tutorial][1] seemed like the best solution so I followed it step by step and integrated ever ...

Populate a database with information collected from a dynamic form submission

I recently created a dynamic form where users can add multiple fields as needed. However, I'm facing a challenge when it comes to saving this data into the database. You can view a similar code snippet for my form here. <form id="addFields" me ...

Excel-like JSON Data Grid using jQuery

I am in need of a data grid similar to an Excel sheet. My primary focus is on filtering capabilities only (refer to the image below). Can anyone offer assistance with this? ...

Having trouble with bootstrap carousel malfunctioning on Firefox browser?

I'm experiencing an issue with the carousel slider on my website. It seems to only be working in Chrome and not in Mozilla Firefox. You can view the live site at: Below is the code I have used for the carousel: <header id="myCarousel" class="car ...

Output the contents of a nested object

After setting up a variable containing music library data... var library = { tracks: { t01: { id: "t01", name: "Code Monkey", artist: "Jonathan Coulton", album: "Thing a Week Three" }, t02: { id: " ...

How can I modify the border color of a Material Ui TextField component?

I've been struggling to figure out how to customize the color of the TextField border. I want to change it from the default grey to black. Below is a simplified version of my UpdatePage.js file: const useStyles = makeStyles(() => ({ updatePage ...

What is the best method for saving a chosen radio button into an array?

I am currently developing an online examination system where questions are retrieved from a database using PHP and displayed through AJAX. I am facing an issue where I am unable to capture the selected radio button value and store it in an array. Despite e ...

The v-data-table is unable to fetch the user list information from the API using Axios

How can I solve the issue of displaying "No data available" in the user list data table on my userDirectory page? I have created a userDirectory page with a subheader and a data table from Vuetify, but it seems to have no data available. <template> ...

Setting the default value in setState in React Native allows you to initialize state

const fetchData = async (key) => { try { const jsonData = await AsyncStorage.getItem(key) return jsonData != null ? JSON.parse(jsonData) : false; } catch(error) { console.log(error); } } useEffect ...

Utilize Axios to send data in real-time to update any changes made to an input field in

Just wanted to write about this topic because I have a burning question. (Please note that the code in this post is just an example). I'm struggling with sending the input content of name_contact on each change without using a button. Is it even poss ...

Unauthorized access detected during ajax request triggered by onpaste event

Recently, I encountered an issue with my asp.net mvc website where an ajax call to the server stopped working in IE 11, despite previously working fine in IE 8. The error message pointed to an access denied exception in jQuery 1.7.1 at h.open(c.type,c.url, ...

Working with promises and Async/Await in Express/node can sometimes feel ineffective

Currently, I am delving into the world of node and express with the aim to create a function that can extract data from a CSV file uploaded by the user. My challenge lies in the fact that the data is being outputted as an empty array before it goes through ...

Retrieve the numerical worth of a specific offspring component

I am currently working with the following HTML structure: <td class=​"prd-var-price"> ​<div class=​"price-total">​ <span class=​"price-unit">​€​</span> ​<span class=​"price-value">​ ...

The $routeProvider is unable to load the view specified in ngRoute

I am currently in the process of implementing ngRoute into my application, but I am facing challenges with getting it to function properly. To showcase my efforts, I have developed a basic app. index.html: <!DOCTYPE html> <html ng-app="tester"& ...