Modify the hovering feature to be activated by clicking for devices with touch screen capabilities

Looking for assistance with hover states on touch devices. For touch devices, the hover state should appear after a single tap, with a second tap needed to activate the link.

I have modernizr with touch-events enabled, but I'm unsure how to implement this in my scenario.

<div class="frontblock">
    <a href="">
        <div class="more">Description Here</div>
        <img src="http://upload.wikimedia.org/wikipedia/commons/1/1c/CSS.png" />
    </a>
</div>
.frontblock {
    padding: 0;
    overflow: hidden;
    position: relative;
    height: auto;
    background: #333;
    width: 50%;
}
.frontblock img {
    width: 100%;
    height: 100%;
    display: block;
}
.frontblock .more {
    background: #FFF;
    position: absolute;
    text-align:center;
    margin-top: 130px;
    z-index: 100;
    left: 0;
    opacity: 0;
    width:100%;
    height:100%;
    -webkit-transition: all 500ms ease-out;
    -moz-transition: all 500ms ease-out;
    -o-transition: all 500ms ease-out;
    -ms-transition: all 500ms ease-out;
    transition: all 500ms ease-out;
}
.frontblock:hover .more {
    opacity: 0.8;
}

View it on jsfiddle http://jsfiddle.net/rhodesign/nhDbL/


Allow me to clarify my issue.

  • I have various boxes, similar to a portfolio page (.frontblock).
  • Each box is linked to a different page and displays an image.
  • When hovered over, the box is covered with descriptions (.more).
  • Clicking the link will open the corresponding page.

On mobile devices (touchscreens), I want the hover effect (.more) to trigger after the first tap and require a second tap to activate the link.

Answer №1

Give this a shot.

Here's a simple code snippet for you to try out:

$(document).ready(function(){
    var links = $('.block-link');    
    $('.block-link').click(function(){
        $(this).addClass('selected');
        $(".block-link").attr("href", "http://www.example.com/");
    });
});

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

Instructions for adding and deleting input text boxes on an ASP.NET master page

*I am currently facing an issue with adding and removing input textboxes for a CV form using ASP.NET in a master page. Whenever I click on the icon, it doesn't seem to work as intended. The idea is to have a textbox and an icon "+" to add more textbox ...

Showing a hidden div after an unsuccessful AJAX call

Encountering an issue with displaying a div notification using the code snippet below: $.ajax({ url: url, cache: false, async: false, success: function (data) { response = jQuery.parseJSON(data); }, error: functi ...

Select the input element in CSS that does not have a parent with the class name 'classname'

In my stylesheet, I have a specific rule that styles various input fields and select elements. However, I'm facing an issue where this styling is being applied to all text fields on the page, including ones inside certain elements with a specific clas ...

Unwillingness of Ajax to accept Names containing apostrophes as a parameter

$(".loadingPnl").removeClass('hdn'); var siteurlA = window.location.protocol + "//" + window.location.host + _spPageContextInfo.siteServerRelativeUrl; var callUrl = siteurlA + "/_layouts/15/SynchronyFinancial.Intranet/CreateMySite.aspx/S ...

Exploring the functionality of the SVG tag tref in Microsoft Edge

I experimented with using the svg tag tref according to the W3C SVG specification 1.1 in the following manner: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>< ...

How can I capture a screenshot of the div displaying pictures uploaded by the user on the frontend?

Take a look at this code snippet. It allows users to upload images, move them around, resize, and rotate them once uploaded. $(function() { var inputLocalFont = $("#user_file"); inputLocalFont.change(previewImages); function previewImages() { ...

Refreshing datatable information - parsing JSON into table rows

My challenge is with a table that is initially server-side rendered. I am looking for a way to refresh the data in the table upon a click event. The issue lies in how to link specific JSON object properties to specific columns. The JSON object contains a ...

Codeigniter experiencing issues with loading CSS file

Currently, I am utilizing codeigniter for a specific project of mine. However, I have encountered an issue related to CSS. The problem seems to be with the loading of CSS files as I keep receiving a 404 error when trying to load them. Surprisingly, all oth ...

Utilizing jQuery to Trigger a JavaScript Function in a Separate File

Here is my question: I currently have 2 files: //File1.js function TaskA() { //do something here } //File2.js function TaskB() { //do something here } $(function() { TaskA(); }); The issue I am facing is that the TaskB function in File2.js ...

Angularjs still facing the routing issue with the hashtag symbol '#' in the URL

I have recently made changes to my index.html file and updated $locationProvider in my app.js. After clicking on the button, I noticed that it correctly routes me to localhost:20498/register. However, when manually entering this URL, I still encounter a 4 ...

Identify Unintended Javascript Modifications in Ajax Request

We have developed a unique Javascript file for our clients to utilize. This innovative snippet captures a screenshot of the website it is executed on and then securely transmits it back to our server using jQuery.post() Given the sensitive nature of our i ...

The execution of JS code is being hindered by PHP codeigniter

Utilizing some pre-owned code in my current project The code snippet below is responsible for adding a product to the wishlist within the view <p class="p"><a<?php echo "onclick='addtowishlist($product->id)'"; ?>>Add To W ...

Sending the $scope.master data to the subsequent form

I have a data set stored in the $scope.master array, and I have attempted to pass this information when submitting the form as shown below: <form novalidate class="css-form" method='post' action='www.example.com'> <INPUT type= ...

What is the best way to adjust the row and column layout in bootstrap?

As I was creating a layout to showcase all of the bootstrap cards in a neat and organized manner, I noticed a peculiar issue that's been bothering me. Everything looks great when the columns are filled or when there's only one card present. Howev ...

analyzing information from a variety of HTML tables

I am currently working on extracting financial data from Income Statements tables within 8-K Forms retrieved from the Edgar Database (http://www.sec.gov/edgar/searchedgar/companysearch.html). Here are a couple of examples: Apple Alcoa The specific table ...

What is the reason behind receiving email alerts whenever visitors access my website?

While developing a website, I ran some tests and noticed that whenever I visit the URL, an email notification is generated. However, the notification received is just a blank one. Could this issue be related to what I entered in the action field? <for ...

Creating responsive tabs that transition into a drop-down menu for mobile devices is a useful feature for

I am looking to create a responsive tab design that drops down like the example shown below: Desktop/Large Screen View https://i.stack.imgur.com/hiCYz.png Mobile View https://i.stack.imgur.com/gRxLv.png I have written some code for this, but I am unsure ...

JS custom scrollbar thumb size issues in relation to the scroll width of the element

I recently implemented a custom scrollbar for a component on my website. To determine the length of the scrollbar thumb, I use the formula viewportWidth / element.scrollWidth;. This provides me with a percentage value that I then apply to the thumb elemen ...

Javascript malfunctioning - exhausted all troubleshooting options

My JavaScript code consists of a single line, but I keep encountering the "getElementById null" error. document.getElementById("menu-background").style.left = "0"; HTML: <html> <head> <title></title> <link rel="style ...

Verify that the images have been successfully loaded

I'm in the process of loading 8 images that all share a common class name. For example: <img class="commonClass" src="..." alt="" /> <img class="commonClass" src="..." alt="" /> <img class="commonClass" src="..." alt="" /> How can ...