Is it possible to update the content of a page using only HTML and CSS, without the need for

Is it possible to update a page's content using only HTML and CSS without JavaScript?

I came across this tutorial, but I'm not sure if updating the page on click without JavaScript is achievable.

Check out this CodePen

@keyframes hide1 {
from {
visibility: hidden;
}
to {
visibility: visible;
}
}
@keyframes hide2 {
from {
visibility: hidden;
}
to {
visibility: visible;
}
}

@mixin set-animation($name) {
  animation: $name 200ms steps(1);
}
h1, h3, h4, p {
  text-align: center;
}
h4 {
width: 400px;
margin: 1rem auto;
}
div {
  width: 140px;
  margin: 0 auto;
}
#click {
  position: absolute;
  left: -20px;
}
#single-click {
  position: absolute;
  cursor: pointer;
  @include set-animation(hide1);
}
#single-click, #double-click {
  user-select: none;
  width: 135px;
  height: 110px;
}
#double-click {
  border: none;
  background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/106891/folders.png");
  background-size: 450px;
  background-position: 301px 0;
}
#click:checked ~ #single-click {
  @include set-animation(hide2);
}
#double-click:focus {
  outline: 0;
}
#click:focus ~ #double-click {
  background-position: 0 0;
}
#double-click:focus {
  background-position: 153px 0;
}
#double-click:focus ~ p {
  opacity: 1;
}
p {
  opacity: 0;
}
footer {
  position: fixed;
  bottom: 0;
  right: 0;
  font-size: 13px;
  background: #DDD;
  padding: 5px 10px;
  margin: 5px;
}
<h1>CSS Double Click</h1>
<h3>Double click detection without Javascript</h3>
<div>
  <input type="checkbox" id="click">
  <label id="single-click" for="click"></label>
  <button id="double-click"></button>
  <p>You double clicked!</p>
</div>
<h4>The folder image is a button.</h4>
<h4>There is a transparent label on top of the button.</h4>
<h4>The label is attached to a checkbox.</h4>
<h4>When the label is clicked, it gains focus and the folder is opened and the checkbox is checked (or unchecked).</h4>
<h4>The checkbox triggers an animation which hides the transparent label for 200ms, allowing the button (folder image) to be clicked.</h4>
<h4>If the user clicks the button quickly enough, the button is focused, displays the full folder, and shows the success message.</h4>
<footer>
  An original pen by <a href="http://codepen.io/ejsado/">Eric</a>.
</footer>

If anyone can assist me with this, I would greatly appreciate it.

Answer №1

The codepen demonstration you provided utilizes the checkbox hack technique:

For more information on the checkbox hack, check out this link: https://css-tricks.com/the-checkbox-hack/

There are numerous possibilities and effects that can be achieved using this method. I encourage you to explore further and have fun experimenting! :D

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

Tips for ensuring all td elements in a table are aligned in the same row

I am currently utilizing the Kendo UI Treeview for my project. I have implemented the functionality to add treeview nodes dynamically, and I am using a Kendo UI template for this purpose. The template definition is as follows: <script id="treetemplate" ...

Unable to locate the specified CSS file

I've been diving into the world of NativeScript and exploring the tutorials provided at . However, I'm facing an issue with getting the platform specific CSS to work properly. Every time I try to run the code, I encounter the following error mess ...

Obtain the values of an array of objects and the values of nested arrays of objects

I have an array of nested objects: const items = [ { id: 1, name: 'banana', selected: true, }, { id: 2, subItems: [ { id: '2a', name: 'apple', sel ...

Trouble getting the x-axis label to appear correctly on jqPlot

I found a great example on the jqPlot examples page and decided to try it out myself. You can check out the original example here: After putting the code into a jsfiddle, I encountered an issue where the chart was not rendering as expected. If you want to ...

Google Analytics 4 is incompatible with the Script tag in Nextjs

I recently developed a website using Nextjs and attempted to integrate Google Analytics into the site. However, I encountered an issue where using the next/script tag did not display any reports, users, or pageviews on the dashboard. Surprisingly, when I r ...

Ways to automatically make a page active upon loading

How can I change the active class when each page is loaded? Here is my jQuery code: $(document).ready(function () { $('.nav li a').click(function(e) { $('.nav li a.active').removeClass('active'); $(this).addClass(&a ...

Issues with CodeIgniter paths causing disruption to CSS background-image declaration

I've been working on a website with backend for two separate customers, each with their own unique URLs. I encountered an issue with Javascript links (ajax calls using url:) but managed to resolve it by using a global variable: var SiteURL='< ...

What is the best approach in JavaScript (jQuery) to loop through every 'a' element on a webpage, sequentially applying a unique style to each one?

Imagine this scenario: On a webpage, there are multiple 'a' tags with different alt tag values: <a href="img1.jpg" class="myClass" alt="0,0,600,200"></a> <a href="img2.jpg" class="myClass" alt="200,0,600,75"></a> <a hr ...

Installing and loading Node.js modules on the fly

I am currently developing a Node.js module called A that relies on another Node.js module, B, from NPM. With new versions of module B being released on NPM, I want my module A to automatically update to the latest version of module B (ensuring it always us ...

Converting a JavaScript hash into a single object: A step-by-step guide

I have an array of objects in the following format: var log=[ { billkey:"Name", billvalue:"ABC" }, { billkey:"Department", billvalue:"Computer" }]; and I want to convert it into a single object like this: var log={ "Name":"ABC", " ...

"Utilize the draggable attribute within the html division element for added

What is the proper usage of the draggable parameter in Dash's html.Div? According to the information found on the official documentation, it states the following: draggable (string; optional): Defines whether the element can be dragged. I initiall ...

What is the process for updating the internal TypeScript version in VS Code?

When using VS Code, I noticed it comes with its own TypeScript version: Is there a way to update this? The current version is 4.9.3. https://i.sstatic.net/vEx85.png ...

When I hover over the navigation bar, a submenu pops up. However, as I try to navigate to the submenu, I often end up accidentally selecting a different item on the navigation bar

I'm trying to find an answer but can't seem to remember where I saw it. Here's the situation: a horizontal nav bar with a dark blue selection and a red sub-menu. When the user hovers over a black arrow, it crosses into a light-blue nav item ...

Looking to utilize AngularJS validation in place of the default browser validation?

I am working on a form that contains two ng-forms for input validation. I have encountered two issues with my forms. 1) I am trying to implement a minlength validation for the Company input, but my current approach doesn't seem to be working. How can ...

Concealing options within Select2

Is there a way to hide certain Select2 options? When I attempt to use CSS like this: <option style="display: none;">...</option> Select2 does not seem to recognize it, unlike when an option is disabled or set as "readonly". Does any ...

Are there any testing frameworks available for JavaScript that are similar to Junit and specifically designed for testing object-oriented JavaScript within Node

What are some recommended methods for testing object-oriented JavaScript in Node.js? For instance, let's consider the following Cat.js class: function Cat(age, name) { this.name = name || null; this.age = age || null; } Cat.prototype.getAge ...

Why does the last-of-type selector work, but the first-of-type doesn't seem to?

The SCSS code snippet below is causing me some confusion: li { &.menu-item-type-custom { margin-bottom: 10px; a { // } &:last-of-type { margin-bottom: 40px; } &:first-of-type { margin-top: 40px; ...

Sequelize - Leveraging Associations in Where Clauses

Within sequelize, my setup includes boards and users with a many-to-many association structured like this: User.hasMany(Board, {through: BoardUsers}); Board.hasMany(User, {through:BoardUsers}); I'm trying to figure out if there's a way to use a ...

Tips for extracting specific field titles from a RESTful API with the help of ExpressJS and Axios

Recently, I have been working on some code that allows me to retrieve data from an external API. Below is an example of the code: //endpoint to fetch data from an external API app.get("/externalapi", (req, res) => { let apiURL = &apos ...

Set up linter rules that utilize `useEffect` in place of `React.useEffect` (utilizing named export rather than full export)

It's important in our codebase to always use: import { useEffect } from 'react'; instead of: import React from 'react'; // use in code as `React.useEffect` Can we enforce this rule with longer eslint rules? If so, how can we impl ...