Issues with CSS transparent color overlay fading on iOS device (Note: Since the original

I have created a grid of images with a unique effect where a semi-transparent overlay appears when you hover over them, revealing some text.

I wanted to achieve the same effect on mobile devices by making the overlay fade in when tapped instead of hovered over.

I was able to get it working on Android devices, but unfortunately, I'm facing difficulties getting it to work on iOS devices.

I will share my code and some attempted solutions that I have experimented with. Despite being new to JavaScript, I do have some basic knowledge implemented on my website already. However, none of the solutions seem to be effective on iOS devices.

Here is the JsFiddle link to my code:

https://jsfiddle.net/49h450g9/

In building this grid, I utilized Bootstrap and LESS. Here is a snippet of my HTML code:

YOUR UNIQUELY REWRITTEN CONTENT HERE...

CSS Styling:

YOUR UNIQUELY REWRITTEN CONTENT HERE...

Solutions I have attempted so far:

  1. Adding

    onclick=""

To the image-wrap div element

2 adding the following line to my JS file:

$('body').bind('touchstart', function() {});
  1. Integrating the below JS snippet into my script:
$(document).ready(function(){

$(".overlay").hover(function(){
//On Hover - Works on ios
$("p").hide();
}, function(){
//Hover Off - Hover off doesn't seem to work on iOS
$("p").show();
})
});

Despite all these efforts, the functionality does not work as intended on iOS devices. When tapping on the images, neither the text nor the semi-transparent overlay fades in.

This has been a challenging task for me, and after several days of troubleshooting and research, no solution seems to address the issue effectively.

If anyone could offer guidance or assistance, I would greatly appreciate it!

Thank you for your time and support.

Answer №1

Opt for the :active pseudo class over the :hover class. On touch-enabled mobile devices, once a hover is activated, it remains active even after lifting your finger. To deactivate it, you must tap elsewhere on the screen.

Similarly, in jQuery, you can utilize mousedown() and mouseup() functions for achieving the same result. With mousedown(), you can display an overlay while with mouseup(), you can hide it accordingly.

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

Updating the value of a line within a block of n lines (jQuery, PHP, MySQL)

Whenever the "lock" button is clicked, my goal is to have only the line where the click occurred change its status to true and display a locked lock icon. On the other hand, when the "unlock" button is clicked, only the corresponding line should switch its ...

Express server failing to serve js and css files

Currently, I'm working on a ReactJS project with React Router implemented. When attempting to access /dashboard/stream, the server is returning the index.html file successfully. However, there are 301 errors for the CSS and JS files, resulting in noth ...

transferring double quotation marks and square brackets through a parameter

I have an angularjs (1.x) scope set up as follows: $scope.report = { resource: '/public/emplyACH', params: { "employeeId": [78] } }; When I try to access it using console.log (console.log(scope.parms)) I see the output as ...

Unable to modify the font color to white on the CSS navigation bar

I've been attempting to alter the color of the text in my .blou class to white within my navigation menu in WordPress, but for some reason, the color isn't changing. This issue is occurring with the WordPress theme I am using. .nav-menu ul li a ...

Tips for retrieving the selected item from Material-UI DropDownMenu

Hello fellow StackOverFlow users, I am new here so please be patient with me In my React app, I am using Material-UI's DropDownMenu to collect information from users. However, the issue I'm facing is that the value being pushed to state is an in ...

Is there a way to prevent Django from automatically sanitizing HTML when inserting it into a template?

I'm feeling a bit puzzled about this situation because it appears that Django templates offer optional HTML filters, yet there seems to be an automatic process at play.. I am working on creating a demo app where the user triggers an action that execut ...

I'm currently utilizing lint in my Angular 2+ project. Is there a way to arrange the constructor parameters in alphabetical order

I am struggling to organize the constructor parameters in TypeScript while using TSLINT with Angular9. I am looking for a rule similar to member-ordering that can help me sort them effectively. constructor( // Sort these private readonly router: R ...

Bootstrap datepicker embedded within a modal will scroll along with the parent page, rather than the modal itself

I recently encountered an issue with a bootstrap template where I needed to incorporate a datepicker within a modal. The modal contains scrollable content, but when I clicked on the datepicker field and scrolled the page, the datepicker moved with the pa ...

Modify this tooltip feature to delay the hiding of the tooltip by x seconds

I have successfully created a tooltip using the following link: http://jsfiddle.net/GLZFc/ Currently, the tooltip works perfectly fine. However, I would like it to hide after x seconds of inactivity. Additionally, if I mouse over it again, I would like th ...

How can I place text on top of an image with a filter using Bootstrap?

I am facing a challenge of overlaying text on an image with a tinted background color and opacity. While working with Bootstrap 4, I suspect that some classes might be conflicting with each other. This is my current setup: Index.cshtml: <div class=" ...

The markers from KML exported from My Maps are not showing up on the Google Maps JavaScript API

I have a map on Google My Maps that I want to showcase through the Google Maps JavaScript API. This way, I can easily merge multiple maps into one and add paths/markers without needing to code it all manually. Test out the map I'm using by clicking t ...

Determine which JavaScript script to include based on whether the code is being executed within a Chrome extension

I am in the process of developing a Chrome extension as well as a web JavaScript application. I currently have an HTML container. I need the container.html file to include <script src="extension.js"> when it is running in the Chrome extension, and ...

Tips for changing the id of a data-target dynamically?

I am faced with a challenge involving three divs that have different IDs. I want to combine the myModal + i values and assign them to the data-target attribute, but I am uncertain about the correct approach. Here is the snippet of code I am working with ...

The variable is currently undefined because it has an array assigned to it

Upon selecting multiple checkboxes for variants, I am retrieving checked data using the following method: get selectedIdsFromViolCategoriesFormArray(): string[] { return this.violCategories .filter((cat, catIdx) => this.violCategoriesFormArr. ...

Position three paragraphs in the center of a div container

Is there a way to center 3 paragraphs in a div? I have separate divs for each paragraph and one main div that holds all three nested divs. div.first { font-family: 'Kanit', sans-serif; color: aliceblue; width: 30%; float: left; ...

Display item upon hovering and for an extended period upon clicking using jQuery

I am looking to create a functionality where hovering over an area displays item 2 for a certain duration, which is currently working fine with the existing code. However, I also want it to remain visible for a longer period if clicked, but this does not ...

Clicking the React Todo Delete Button instantly clears out all tasks on the list

I am dealing with 2 files: App.js import React, { Component } from 'react'; import './App.css'; import ToDo from './components/ToDo.js'; class App extends Component { constru ...

What is the best way to maintain the position of components (such as a Card component) when one is expanded in a Material-UI and ReactJS project

Currently, I am working with an expandable Card component from Material-UI and using flex for aligning the components. However, when one card expands, it affects the positioning of the other components in the row: https://i.stack.imgur.com/vGxBU.png What ...

Tips on customizing Char.js doughnut charts

How can I make the doughnut thinner while keeping it thicker? What adjustments should be made? I attempted to implement changes and it worked successfully, but now I need to adjust the width. How can I do this? TS File. import { Component, OnInit } from ...

Reorganize external dependencies in the wwwroot directory using gulp

In my development setup using VS 2015, ASP.net vnext, Angular 2, Typescript, and gulp.js, I have successfully automated the process of moving my scripts/**/*.ts files to the wwwroot/app folder. Now, I am looking to extend this automation to include my libr ...