steps to transform an image into a clickable link

I'm struggling with a simple question and need some help.

#tps_block {
  height: 45px;
  width: 940px;
}
#tps_point1 {
  width: 351px;
  background: url("http://www.jenierteas.com/templates/default/images/hp_usp.png") 0 0 no-repeat;
  text-indent: -9999px;
  display: block;
  height: 100%;
  float: left;
}
#tps_point1:hover {
  background: url("http://www.jenierteas.com/templates/default/images/hp_usp.png") 0 -45px no-repeat;
}
#tps_point2 {
  width: 284px;
  background: url("http://www.jenierteas.com/templates/default/images/hp_usp.png") -351px 0 no-repeat;
  text-indent: -9999px;
  display: block;
  height: 100%;
  float: left;
}
#tps_point2:hover {
  background: url("http://www.jenierteas.com/templates/default/images/hp_usp.png") -351px -45px no-repeat;
}
#tps_point3 {
  width: 305px;
  background: url("http://www.jenierteas.com/templates/default/images/hp_usp.png") -677px 0 no-repeat;
  text-indent: -9999px;
  display: block;
  height: 100%;
  float: left;
}
#tps_point3:hover {
  background: url("http://www.jenierteas.com/templates/default/images/hp_usp.png") -677px -45px no-repeat;
}
<div id="tps_block">
  <div id="tps_point1"><a href="#">Point 1</a>
  </div>
  <div id="tps_point2"><a href="#">Point 2</a>
  </div>
  <div id="tps_point3"><a href="#">Point 3</a>
  </div>
</div>

There are three images displayed side by side, each changing when hovered over. The images are also links that will take the user to another page upon clicking.

The hover effect is working fine, but I can't seem to get the linking to function properly.

If anyone could provide assistance, it would be greatly appreciated.

JSFiddle: http://jsfiddle.net/ahmadka/Fjmnt/

Answer №1

If you have the ability to edit the HTML code, simply remove the inner div tags and apply the same styles directly to the links:

<div id="tps_block">
  <a href="#" id="tps_point1">Point 1</a>
  <a href="#" id="tps_point2">Point 2</a>
  <a href="#" id="tps_point3">Point 3</a>
</div>

Check out the updated jsFiddle for reference: http://jsfiddle.net/Fjmnt/7/

Answer №2

Here is a great workaround in case you cannot make changes to the HTML code.. apply the following CSS.

#tps_box a {
    display: block;
    width: 100%;
    height: 100%;
}

This code will expand the <a> element to cover the entire div, making it clickable.

Demo on jsFiddle

Answer №3

<div id="unique_block">
  <a href="#"><div id="unique_point1"></div></a>
  <a href="#"><div id="unique_point2"></div></a>
  <a href="#"><div id="unique_point3"></div></a>
</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

Addressing the issue of compatibility with iPhone 5 and 5S in both portrait and landscape modes

I made an attempt to conceal certain elements specifically on iPhone 5 & 5S in both portrait and landscape orientations, but unfortunately, it ended up affecting all iPhone devices. Below is the code snippet used: @media only screen and (min-device ...

Stretching the limits: Combining and expanding your Styled Components theme

I am facing a situation where I have a component library built using Styled Components that has its own theme settings which are not meant to be overridden. Now, I need to incorporate this component library into another project that also uses Style Compone ...

Adjust parent div size automatically when child is resized - jQuery Resizable Plugin

I need some assistance with jQueryUI Resizable. How can I resize only the height of the parent div when the child div is resized and touches the bottom end of the parent div? Additionally, I want to ensure that the child div does not go outside the boundar ...

Is there a way to retrieve the creation date and time or last modification date and time from images in iOS Photos, such as those in the

Hello there! I am currently new to iOS and have been working on developing an iOS application that requires checking the creation date and modification date of images in iOS Photos in order to sort them by time. I am using ALAssetsLibrary to list all imag ...

The jQuery execCommand feature fails to generate a pop-up when used within the contenteditable attribute of an HTML tag

Trying to implement an inline text editor using the jQuery execCommand function. Below is a snippet of my source code: /*******************************************************************/ /********** Click: inner of contenteditable text-editor div *** ...

Guide on positioning an SVG button within a form

I am attempting to design a form with two input fields and a button. Rather than using a plain text button, I prefer to utilize an SVG graphic for the button; however, it is not aligning correctly. Consider the following HTML and CSS: body { backg ...

Designing an HTML and CSS footer navigation bar

Can you help me create a footer menu using HTML and CSS? Check out this image for reference Any tips on how to style it with cascading style sheets? <footer> <ul> <li><a href="">Home</a> </li> <li> ...

Arrange grid column elements (similar to aligning with justify: flex-start)

<item> <h2 class='title'> TITLE </h2> <video-item> <img src="https://placehold.it/1600x1100"> </video-item> <overview> <p>CONTENT</p> < ...

Ways to access the HTML file displayed in the FireFox new tab interface

After opening a new tab in Firefox, I stumbled upon an HTML file that I had believed to be lost after overwriting it on my server. Surprisingly, it's nowhere to be found in my home folder. How can I retrieve it without risking clicking on it and poten ...

Implement consistent styling across several elements within a component

const GreenRow = styled.div` background-color: green; ` const RedRow = styled.div` background-color: red; ` const YellowRow = styled.div` background-color: yellow; ` const GreyRow = styled.div` background-color: grey; ` const MyComponent = () => ...

A way to insert a line break in an HTML document without using the <br> tag is

<div id="unique_1" class="unique" style={{display:"flex"}} > <div class="item1">11</div> <div class="item2">77</div> <div class="item3">22</div&g ...

Looking for a JavaScript code to create a text link that says "submit"?

Here is the code I have, where I want to utilize a hyperlink to submit my form: <form name="form_signup" id="form_signup" method="post" action="/" enctype="multipart/form-data"> ... <input type="submit" value="Go to Step 2" name="completed" /> ...

Tips for validating multiple email addresses in Kendo UI

I provided a similar code structure <td> <label for="email" class="required">To:</label></td> <td><input type="email" id="email" name="Email" class="k-textbox" placeholder="e.g. <a href="/cdn-cgi/l/email-protect ...

What is the best way to ensure that circles only touch each other by their edges?

Trying to align three circles touching each other has been a challenge for me. Although I have successfully managed to make two touch, the third one remains elusive. How can I ensure that all three circles are in contact with each other, especially when th ...

The autoComplete feature in my ReactJs form is not functioning properly

I have a form in React where I would like to enable auto complete so that when users input the same value again, it will be suggested as an auto complete option. Below is the code snippet: <form className={classes.container} noValidate> <Grid c ...

Querying val results in an empty string being returned

In my application, I have the following HTML code snippet: <tr style="cursor:pointer;"> <td>100101</td> <td>Monkey</td> <td>Nuts<td> <td>Cow</td> <td>Soup</td> <t ...

The class in my CSS is currently impacting all the menu bar items, but I specifically want it to only affect my photo gallery

<div class="gallery"> <a tabindex="1"><img src="images/smile.jpg"></a> <a tabindex="1"><img src="images/smile.jpg"></a> <a tabindex="1"><img src="images/smile.jpg"></a> ...

What strategies can I use to keep text-area from wrapping onto a new line?

I'm having trouble with styling my description column <template v-slot:item.description="{ item }" class="description" style="overflow-wrap: normal"> {{ item.description }} </template> CSS <style scoped> ...

Tips for shortening button text within a flex child element

I'm struggling to achieve a specific layout using flexbox. I require one child element that does not shrink, and two child elements that can shrink/grow and be truncated based on their content while considering the sizes of their content. My current ...

CSS creates captivating image hover transitions with span elements

<a href=""><img src=""><span>content</span></a> When I hover over the image, the content within the span appears using relative positioning with display set to none and absolute positioning in the span tag. My query is regard ...