Clickable Bootstrap Overlay Linked for Interaction

I'm seeking some help with a Bootstrap image gallery I'm developing. In my portfolio, there are several images displayed, and when hovered over, an "overlay" appears with an icon that users can click to open a Lightbox;

<div class="container-fluid full-width">
  <div class="row row-no-gutter">
    <div class="col-md-push-0 col-md-12 col-sm-12 col-sm-push-0 content">
      <div class="isotope_items">
        <div class="single_item link web-design col-md-3 col-sm-6 col-xs-12">
          <div class="work-inner">
            <div class="work-overlay">  
              <div class="overlay-in">
                <div class="work-info">   
                  <div class="work-links">                                             
                    <a href="images/work-1.jpg" class="image-link lightbox"><i data-icon="W" class="icon" style="color:white"></i></a>
                  </div>
                </div>
              </div>
            </div>
              <a href="images/work-1.jpg" class="image-link lightbox"><img src="images/work-1.jpg" class="img-full-width" alt="" ></a>
          </div>
        </div>
      </div>

Relevant CSS;

.work-inner {
  position: relative;
}

.work-overlay {
  position: absolute;
  color: #fff;
  width: 100%;
  height: 100%;
  text-align: center;
  -webkit-transition: all 0.5s ease;
  -moz-transition: all 0.5s ease;
  -ms-transition: all 0.5s ease;
  -o-transition: all 0.5s ease;
  transition: all 0.5s ease;
}

.overlay-in {
  display: table;
  height: 100%;
  width: 100%;
}

... (CSS continuation)

The issue is that only the icon is clickable, causing problems on mobile devices where accurate clicking is difficult. I want the entire image to be clickable instead of just the data icon.

Updated code - Apologies for the length!

Answer №1

Resolution implemented:

Following our conversation and review of the sample code provided at 35.153.183.88/portfolio, it was concluded that to address the issue, the anchor tag needed to encompass the div element triggering the overlay instead of just the icon.

Thus, the updated structure including the anchor tag is as follows:

// Other Divs
<div class="work-inner">
    <a href="images/work-1.jpg" class="image-link lightbox">
        <div class="work-overlay"> 
             // Other divs/image/icon.
        </div>
    </a>
</div>

The initial advice is retained below for reference.

/======== Outdated response continued below. ========/

If the template structure does not allow for moving the image inside the anchor tag, alternative options include duplicating the anchor tag around the image or solely moving the image out from the icon's container.

To maintain link styling for the icon in the second scenario, the "image-link lightbox" css classes should be incorporated into the icon's classes like so:

<i data-icon="W" class="icon image-link lightbox" style="color:white"></i>

We hope this solution proves beneficial to you.

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

Utilize both versions of Bootstrap seamlessly without causing any disruptions or issues

With a unique situation at hand, I find myself needing to display two different versions of Bootstrap on the same page. My Umbraco CMS relies on Bootstrap version 2.x by default, while my frontend pages utilize Bootstrap 4. However, certain Bootstrap 4 wid ...

Bootstrap 4 ordering feature is non-functional

I am looking to rearrange the layout for Desktop and mobile devices, currently this is how it's structured: On Med+ : https://i.sstatic.net/E9ZHo.png On small: https://i.sstatic.net/VG6j1.png The placement on Desktop is fine. However, on mobile I ...

How can I replicate the X axis on both ends of a horizontal bar chart using only one dataset in Chart.js version 3.x?

Is there a way to duplicate the X axis ticks on both the bottom and top of a chart? I know there were solutions for older versions of Chartjs, but the options have changed in version 3.x. Previously, you could use something like this: xAxes: [ { ...

Exploring the asp.net MVC framework with the integration of HTML5 date input

Currently, I am working on an ASP.NET MVC project using Visual Studio 2013. One of the issues I am encountering is related to a date input field. When I click on the field and focus on it, the automatic HTML5 datepicker does not appear. If I enter the da ...

Eliminate the error notification on the login page if it corresponds to the input

I am facing an issue with my login page and the API for password validation. Even when the password matches, an error message is still being displayed. This is because I am looping through the data and need to break the loop once a match is found. How can ...

The element in the HTML source code evades detection by Selenium

Given: Python 3.11.2 Selenium 4.8.2 Chrome as the browser engine I am searching for the following HTML code snippet: <input type="text" class="datepicker apex-item-text apex-item-datepicker hasDatepicker" size="32" value= ...

Issues with image mapping functionality

When working with image mapping, I encountered an issue where changing the width and height of the image caused some drawing issues. Specifically, when hovering over certain circles that were drawn on the image, hover-content1 was supposed to appear. Afte ...

displaying a Google Map within a designated container

I'm currently working on a basic website layout that consists of a full-width banner, a left menu (200px), and right content (600px). I have a simple jQuery script set up to load the content on the right-hand side when any of the five menu items are c ...

Creating a dynamic web design with HTML and CSS: how to overlay multiple styles of text on

Previously, I inquired about adding text to the gray area of an image. Some experts recommended using <span>, but this resulted in all the text appearing in a single line (as it is inline), even though it was set to display:block. How can I achieve s ...

How to perfectly align images in nivo slider

Currently, I am utilizing the nivo Slider within a div that has been styled with a width of 100%. Despite the slider functioning splendidly, I am encountering an issue where the images do not properly align in the center due to the javascript script consi ...

The position of the mouse on the canvas following a CSS scaling

I'm currently working on finding the mouse coordinates on an HTML5 canvas element. I set the canvas dimensions to 700x700. When I hover over the canvas, I aim to retrieve the X,Y coordinates of the mouse. Everything goes smoothly until I resize the c ...

Connect AngularJS with Bootstrap Popover for seamless data binding

I am currently working on dynamically populating the data-title and data-content of a Bootstrap popover using JSON data generated by an AngularJS controller. Snippet from Controller: $scope.popoverContent = {name: {title: "title", content: "content"}} S ...

Achieving vertical text next to horizontal text in Tailwind CSS

I am facing difficulties with tailwind layout and text alignment as I attempt to create a responsive design for both mobile and large screens: https://i.sstatic.net/s8uO3.png https://i.sstatic.net/28NiX.png Despite my efforts in the Tailwind Play, I am ...

How can I prevent duplicate IDs when submitting a form through AJAX within a while loop?

While submitting a form using Ajax within a while loop, I encountered an issue where the same form ID is being used multiple times due to the loop. As a result, the form only submits once. I believe that I need to generate a unique ID for each iteration of ...

The HTML image file input restricts the user's selection to images stored in the gallery

On mobile devices, when I press the input it displays two options: camera and gallery. However, I only want to select from the gallery. How can I disable the camera option? ...

Inserting a vertical barrier in the midst of the content

I am struggling to create a vertical divider and align the text properly in the top right corner of my screen. https://i.sstatic.net/UqURE.png Currently, I am facing issues with displaying the divider and positioning the text correctly. <div class="r ...

Guide on incorporating the font-awesome library in your project

Forgive me if this sounds like a silly question, but I am completely new to javascript and its libraries. I stumbled upon a similar issue as described in this thread, where the accepted solution included the following line: <link rel="stylesheet" href ...

What is the best way to implement data loading on scroll in HTML with AngularJS?

I'm working with a HTML Dynamic Table <div class="clearfix reportWrapper" > <div class="reportTable"> <table class="table table-bordered footerBGColor"> <thead fix-head class="headerTable"> ...

Having difficulty with utilizing the sendKeys() method within the paragraph tag using Selenium WebDriver

Below is an image showing the page I want to make changes to: https://i.sstatic.net/jRtlT.png This is the HTML code snippet: <div id="taTextElement7190829193028565" class="ng-pristine ng-untouched ng-valid ta-bind" contenteditable="true" ta-bind="ta- ...

Having trouble with JavaScript in a project I'm trying to replicate

For my coding practice, I am working on a project where clicking on the images should change the main product displayed along with its color. However, nothing happens when I click on the products. Can anyone point out what I might be doing wrong? Here is ...