What is the correct way to utilize href in CSS content property?

Below is the content of a box I have:

https://i.sstatic.net/QmG5i.png

When the above box is hovered over, it flips to this:

https://i.sstatic.net/QsS9t.png

This block's HTML code is as follows:

<div class='tiles'>
  <div class='col'>
    <a href=""></a>
    <a href="#"></a>
    <a href="#"></a>
    <a href=""></a>
    <div class='box'></div>
  </div>

I am using CSS to show before and after values using content:

       .col:nth-child(2) .box:before {
        content: "Maps Available";
        background: #e4a001;
        }
        .col:nth-child(2) .box:after {
          content:' Google Map : Click    \A'
          'Apple Map: Click \A  \A';

          background:#e4a001;
        }

In the code provided above, I want to add 'href' so that when the user clicks on 'click' (as shown in the second picture), they are directed to Google and Apple maps accordingly. I tried using attr(href) but it did not work. I also understand that href cannot be included in CSS. I acknowledge that CSS cannot achieve this. Is there any alternative solution available? Any assistance would be appreciated.

Answer №1

Present or conceal the links as required:

.box {
  width:150px;
  height:150px;
  position:fixed;
  left:50%;
  top:50%;
  transform:translate(-50%, -50%);
}

.front, .back {
  width:100%;
  height:100%;
  position:absolute;
  left:0;
  top:0;
  transition:transform 0.5s linear;
  background-color:#f44336;
  backface-visibility: hidden;
}

.back {
  transform:rotateY(180deg);
}

.box:hover .front {
  transform:rotateY(180deg);
}

.box:hover .back {
  transform:rotateY(0deg);
}
<div class="box">
  <div class="front">
    Maps
  </div>
  <div class="back">
    Google Map: <a href="http://www.google.com">Click</a>
    <br><br>
    Apple Map: <a href="http://www.apple.com">Click</a>
  </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

Guide on extracting the text from the <script> tag using python

I'm attempting to extract the script element content from a generic website using Selenium. <script>...</script> . url = 'https://unminify.com/' browser.get(url) elements = browser.find_elements_by_xpath('/html/body/script[ ...

"Streamlining data entry with an uncomplicated HTML form input that accepts multiple values from a

As I understand it, a barcode scanner functions as nothing more than a keyboard that transmits keycode 13 after each scan. My task is straightforward: I have a basic form with only one input field and I want the ability to scan numerous barcodes and then c ...

Tips for improving the speed of loading infinite scroll pages

I am currently working on scraping over 100k rows from the provided URL. The data goes back approximately a month, loading in batches of 7-8 rows at a time. My current approach involves using a macro to scroll down the page slowly, which is effective but ...

Insert the AJAX loader graphic

Hello! I may not be a master of jQuery, but I've been tinkering with some source code and stumbled upon an ajax script. I'm feeling a bit lost on how or where to insert an ajax loader image in this snippet: $.post(webroot+'quickLookUp.php&a ...

Is it better to import and use useState and useEffect, or is it acceptable to utilize React.useState and React.useEffect instead?

When I'm implementing hooks for state, effect, context, etc, this is my usual approach: import React, { useState, useEffect, useContext } from 'react'; However, I recently discovered that the following also works perfectly fine: import Re ...

Triggering transitionend event once with an added if condition

Currently, I have an application of an if statement that examines whether an element contains a style attribute. In the event that the style attribute is absent, it appends inline styling. Conversely, if the style attribute exists, it is removed. Furthermo ...

Rendering HTML or links sourced from encoded JSON data with JavaScript

After making an ajax call, I receive the following data: {"dataList":[{"date":"August 27, 2013","text":"<a href=\"http:\/\/www.example.com\/test.aif\" title=\"Click here to listen\" target=\"\">Click her ...

Having trouble getting $.ajax to function properly in conjunction with fullcalendar js?

Currently in the process of utilizing the Smart Admin Theme, specifically focusing on the functionality within the calendar page. The calendar's core features are operational, allowing for the creation and placement of new events on the map. My curr ...

Background image specifically for the Fullcalendar sun component

When setting a background image for Sunday in the month view, I noticed that the day "Sunday" in the header is also getting the same background. The CSS for the table thread has classes like .fc-sun and .fc-mon set as well, but I'm not sure how to rem ...

Customizing the color of cells in an HTML table within a JSON based on their status

Would you like to learn how to customize the color of cells in an HTML table based on the status of a college semester's course map? The table represents all the necessary courses for your major, with green indicating completed courses, yellow for cou ...

Send a MySQL query and an HTTP request to an SMS gateway through JavaScript

I have a scenario where data is being received by my confirm.php file. In this file, I have the following code and currently facing an issue with the javascript part. Any help and suggestions would be greatly appreciated. The objective of my javascript is ...

Guidelines for dynamically passing HTML attribute values into a CSS selector using a variable in Protractor

After successfully locating the button on the row using its value stored in the "title" HTML attribute, I am now faced with the task of passing a dynamic value to this attribute. To achieve this, I have declared it as a variable. However, I am unsure about ...

What are the steps to submit a Textbox form?

My current setup includes a search box and a button that users click to execute the search. However, I am looking to enhance the functionality by allowing users to press "enter" instead of clicking the search button. How can I achieve this modification? B ...

Curved edges achieved without the need for relative positioning

Can anyone help me with a specific code snippet to achieve rounded corners for this page ? Currently, I am using the PIE.htc file which only works when I declare position:relative; throughout the layout, causing disruptions. Is there a code workaround that ...

EJS file not displaying stylesheets and images correctly during rendering

I'm currently in the process of building a website, but when I try to render an ejs file (index.ejs), only the HTML portion is displayed without showing any stylesheets, fonts, or images. Here is the code snippet for linking the stylesheets: <!D ...

What is the process for setting up a file route in Laravel 5.1?

I am currently using Datatable within Laravel 5.1 and I am facing an issue with loading the Datatable using jQuery. I am unsure of how to properly add a JSON file to change the language settings. Here is the code snippet from my blade page: <script> ...

I need to know how to create a patch request in Vue.js and simultaneously modify the marks input for specific individuals by using v-model

Hello there, I am currently developing a student assessment input form using vuejs, express, and mongoDB. The backend API is complete and functioning properly when tested with postman. Here is the code: // UPDATE MARKS router.patch('/:studentId' ...

Use JavaScript to switch the h1 title when selecting an option from the dropdown menu

As a beginner in coding, I am struggling to find a solution using an if statement for this particular problem. Although I can achieve the desired result with HTML code and options, this time I need to use arrays and an if function. My goal is to create a ...

Autocomplete feature enhanced with the ability to validate and clear out

Here's a snippet of my HTML code: <div class="form-group"> <label for="date_chargement" class="col-sm-4 control-label">Minimum loading date:</label> <div class="col-sm-2"> <input type="text" class="form-control te ...

Is it possible to launch a browser window using javascript?

I need to open a new Internet Explorer browser window and I am currently using the following code: window.open("http://jsc.simfatic-solutions.com", "mywindow"); However, I would like to know how can I open a new IE window with a fresh session? ...