What is preventing this hover from activating the text animation?

Looking to create a hover effect in an CMS platform that only allows internal CSS styling. Despite the absence of a head tag, this CMS recognizes style tags and automatically inserts them into the template.

After attempting to export as HTML to troubleshoot the issue without success, I experimented with hierarchy by setting the default state as H1 and the hover state as a div class and ID. This solution is intended for use on EKTRON CMS functioning on HTML5 without the ability to implement JavaScript.

body {
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

h1 {
  margin: 0;
  padding: 0;
}

h1 span {
  display: inline-flex;
  color: #1C7CB3;
}

h1 span:nth-child(even) {
  overflow: hidden;
  transition: ease 0.5s;
  color: purple;
  letter-spacing: -1em;
}

h1:hover span:nth-last-child(even) {
  letter-spacing: 0;
}
<h1>
  <span>F</span><span>lorida</span>
  <span>I</span><span>nstitute</span>
  <span></span><span>of</span>
  <span>E</span><span>ducation</span>
</h1>

My expectation was for the text to animate upon hovering, however, it remains static.

Answer №1

When creating a hover effect, it's important to use the correct selector. In this case, the :nth-last-child(even) selector is being used which selects every even element starting from the last one. This means that the first odd element selected will be

<span>ducation</span>
and the first even element will be <span>E</span>. To select elements starting from the beginning, you should use the :nth-child(even) selector instead.

h1:hover span:nth-child(even)
{ 
    letter-spacing: 0;
}

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

Methods for enlarging a sub-element without any impact on its encompassing parent element

I need the child class to not affect the overflow of the parent when I hover over it. My initial thought was to remove the line position: relative; from the parent, but this solution does not work properly when dealing with multiple nested positions. .p ...

div containing various images of varying sizes

I am working with a layout that requires 4 images to be displayed together within a container. One image should be larger and positioned on the left, while the other three should be uniform in size and placed next to it on the right. Despite my efforts t ...

Having trouble making the JavaScript mouseenter function work properly?

Hi there, I'm having trouble with this code and I can't figure out why it's not working. $('#thumbs > li').mouseenter(function() { $(this).find("div").fadeIn(); }).mouseleave(function(){ $(this).find("div").fadeOut(); ...

Positioning an immovable element beneath a fixed element that can vary in height

I am working on a webpage that features a fixed menu at the top-left corner, followed by the main content. My goal is to ensure that the content appears below the menu, but since I do not know the exact height of the menu in advance (as it can vary based o ...

Allow-Origin-Control, handler.php for emails, and form validation script

I encountered a strange bug recently. There's been some issues with the HTML5 template I downloaded, specifically related to the contact form and MailHandler.php file. Despite having both files in the same directory, when inspecting element in Chrome, ...

Issues with the styling of HTML code

Our website features a main menu with submenus that are intended to be displayed only when hovering over the main menu. However, upon loading the site, the submenu is already visible causing an issue. We need the submenu to appear only when the main menu i ...

Uploading a file to a server using HTML and PHP: a step-by-step guide

Looking to utilize PHP as a proxy for uploading files to a server. Any advice on how I can send the uploaded files along with a Basic Authorization header? ...

Decrease the size of ion-list items in Ionic 2

I found a similar query over on Stack Overflow, but it's related to Ionic 1 where the ion-item still includes ion-content. In Ionic 2, there is no ionic-content element. I've attempted to adjust the height, padding, and margin of both the ion-ite ...

Automatic Addition of Row Numbers Enabled

I'm currently exploring coding and experimenting with creating a scorekeeper for family games. I've managed to add rows dynamically and automatically sum up the entered information in the "total" row at the bottom. However, I'm facing an iss ...

Display a button with an icon only when in responsive mode using HTML, CSS, and Materialize

Is there a way to hide the text on a button but keep the icon visible when viewing on a mobile device? For instance, if a button displays a face icon from MaterializeCSS along with the text "support", I would like to eliminate the text while still showing ...

HTML video audio playing, but screen remains empty

I am facing an issue while trying to watch a video using HTML. The audio plays, but the video remains blank. The video is in MP4 format and can be found at this link. Interestingly, it works when downloaded and viewed, as my friend created it. I even tried ...

Display new information within a div element seamlessly without refreshing the page

Just a heads-up, I'm new to HTML development... Currently working on a website using Bootstrap. There are some buttons on the left side shown in the screenshot, and my goal is to update the content on the right without having to reload the entire pag ...

Begin 5 seconds after loading

First time attempting this task. My goal is to trigger the loading of an I have been trying to write a script for this, but it's not functioning as expected. HTML : <div id="div1"> <a id="single" href="#">Single Play</a> & ...

Creating a central navigation menu for a website

Currently, I am working on incorporating a menu in the center of a webpage (please note that this is not a top navigation menu). Here is the initial setup: https://i.sstatic.net/3arql.png Users are able to click on various menu items to access different ...

What is the best way to alert a user before they navigate away from a page with content in a textarea?

I am attempting to recreate the functionality seen on textareas in Stack Overflow. UPDATE: Following the advice provided here, I have implemented something similar to the following: window.onbeforeunload = function() { var myTextArea = document.getE ...

Filling HTML5 Datepicker Using Information from a Model

Currently, I am in the process of developing a basic scheduling application for a project. To simplify the task of selecting start and end times/dates for our events, we have included a simple DateTime picker in the source code: <input type="datetime-l ...

Is there a way to modify the background hue of an upward facing triangle when a submenu is hovered over?

Access the Code on Fiddle #nav .submenu:before { content:""; position: absolute; width: 0; height: 0; border-bottom: 22px solid #b29600; border-left: 11px solid transparent; border-right: 11px solid transparent; margin: -12px ...

How to send parameters to Bootstrap modal using a hyperlink

I need help confirming the deletion of a datatable row using a Bootstrap modal dialog. When a user clicks on the delete link, I want a modal to appear asking for confirmation. Here is my code: <c:forEach items="${equipes}" var="equ"> ...

Ways to conceal scrollbar track

Is there a method to conceal the track of the scrollbar while keeping the thumb visible? The desired appearance is shown in the following image: https://i.sstatic.net/6TqmM.png However, the current view is as follows: https://i.sstatic.net/tdJq3.png Th ...

What is the best way to fill in the jquery treeselect widget?

I'm struggling with populating the jquery treeselect widget using a json file or any other method. Since I am new to jquery/javascript, I'm sure I must be missing some basics. Although I have obtained the plugin from https://github.com/travist/j ...