Why is my CSS transition not functioning properly with overflow in use?

Can someone help me figure out why this code is not working properly?

body {
  font-size: 40px;
  background-color: black;
}

.fillColor {
  color: transparent;
  text-decoration: none;
  position: relative;
  display: block;
  font-size: 40px;
  -webkit-text-stroke-width: 1px;
  -webkit-text-stroke-color: white;
  ;
}

.fillColor:before {
  content: attr(data-hover);
}

.fillColor:after {
  content: attr(data-hover);
  position: absolute;
  color: white;
  left: 0;
  width: 0;
  transition: width 10s;
  white-space: nowrap;
}

.fillColor:hover:after {
  width: 100%;
}
<p class="fillColor" data-hover="HUNG"></p>

After removing overflow: hidden from the CSS, my code stopped functioning. I'm not sure why this is happening and any insight would be greatly appreciated.

Could someone explain to me the purpose of using overflow:hidden?

Answer №1

Essentially, the purpose of using overflow:hidden is to conceal the scrollbars.

If you change the overflow property to scroll, it will become apparent

overflow:scroll

On the other hand, removing overflow:hidden will cause the fillColor:after element to be displayed.

Answer №2

The overflow property in CSS determines whether the content of a block container element will be cut off if it exceeds the dimensions of the box.

When set to hidden, the content is clipped without any scrollbars provided.

For example, if an element with the class .fillColor:after has properties like width: 0 and overflow: hidden, its content will be clipped to a width of 0px and not visible. However, removing the overflow: hidden property will allow the content to extend beyond the .fillColor:after element and occupy its own width.

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

Enhancing Drupal Views: Changing Filter Criteria from Dropdown to Autocomplete

After setting a new filter criteria in a view, I am trying to make it show as a drop-down instead of autocomplete. I have clicked on settings (next to the name of the new criteria), selected Drop down, and clicked Apply (all displays). However, on preview ...

HTML tables with stripes and row spans

I found the initial table on this link. After reviewing the original table, I am looking to make modifications as shown in the highlighted image below. However, when attempting to add rowspan and colspan attributes to the td elements, I encountered an iss ...

Discover the secret to accessing restaurant menus with Foursquare by utilizing file_get_contents on the designated menu URL

I am encountering an issue with retrieving all the menus for a specific venue ID using the Foursquare API. As a workaround, I have opted to fetch menu details by utilizing 'file_get_contents' from the following menu URL: Snippet of Code : $menu ...

Unable to conceal adjacent element when z-index is set as 1

I encountered an issue where a modal is overlapping another element, and the close button of the underlying element has a z-index of 1. Despite creating a new modal with its own close button, the original close button remains visible on top. I attempted t ...

The Info button in Bootstrap5 is sporting a sleek combination of blue background and black text, deviating from the traditional blue and

Check out my full code for the Random Quote Generator Project on Codepen: here I implemented Bootstrap5 from this link: Bootstrap CDN. The button style btn-info is not displaying correctly in my project. I'm puzzled and would like to understand why ...

Loading JavaScript and CSS files in an EJS file using Node.js

Here is the structure of my folder: server.js app --routes.js views --ace-builds-master --\src-noconflict --ace.js --index.ejs The 'views' directory contains my ace editor components and my index.ejs file. I am trying to include ac ...

The Bootstrap 4 navigation bar is failing to extend fully across the width when a dropdown menu

Here is the code I am using for the navigation bar. When I click on the dropdown button, this is how it appears on my webpage: Click here <nav class="navbar navbar-expand-lg navbar-dark bg-color mb-3"> <a class="navbar-brand" ...

Search for every div element and locate the ul element within it. Calculate the total number of table rows present in the ul element. Add this

There is a list on my website with a sublist called .cart-items. This sublist contains a table with multiple rows. My goal is to iterate through each .cart-select item and count the number of tr elements within the cart-items. The count should then be disp ...

Issues with IE8 compatibility on the website

I'm in the process of developing a website and I'm facing some issues specifically with IE8 or later versions. For reference, here is a temporary link to the site: . 1 The problems I am encountering are as follows: The login/register form disp ...

Creating SEO-friendly URLs for a website that utilizes Ajax technology has been a challenge for me

I am facing a challenge where I need to create URL-friendly links in a completely ajax-based website. What I am currently doing is having an index.php file with only a div of id #content-container. Additionally, I have separate include files such as Home.p ...

Is it possible to adjust the font size of text files that are embedded?

I have been struggling to change the font size of an embedded text file, but the style doesn't seem to be working. Despite trying various approaches, nothing seems to make a difference. <style> pre { font-family: "Courier New", monos ...

Ways to display an icon in Angular 10 only when it is hovered over

Just getting started with Angular and still learning the concepts. Trying to figure out how to show an icon only when it's hovered over. Can anyone assist me? Sorry, can't share the code because of company rules. The icons are for sorting and ...

The issue with Framer motion's whileInView is that it does not animate the element when it is within the viewport in Next.js

In my current Next.js 14 project with the App Router, I decided to play around with animations using Framer Motion. One specific feature I wanted to implement was animating text elements into view as they enter the viewport. The idea is for the text to gra ...

Why are the items I have inserted inside my <div> tag not appearing on the screen?

What could be simpler than this: {this.state.dash ? <div className='dashWrapper slide'> HELLO </div> : null} I've tried everything, but nothing seems to show up inside the div. ...

What is the best way to target a nested selector in CSS?

To ensure the entire cell is filled when a modal is present, the padding of the table should be zero. See image https://i.sstatic.net/Qq2T4.png How can I target the specific selector nested within the table under different classes and IDs? I've expe ...

Modify vanilla JavaScript carousel for compatibility with Internet Explorer

I am currently in the process of creating a website that incorporates a carousel similar to the one found at the following link: https://codepen.io/queflojera/pen/RwwLbEY?editors=1010 At the moment, the carousel functions smoothly on opera, chrome, edge ...

The problem of SVG rendering order requires a solution that does not rely on javascript

I am new to experimenting with inline svg, and I wanted to share my code: <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="350" height="350"> <defs> <style> .ring { transform-origin: 175px 175px; } ...

Adding a special ie7 glow effect to hyperlinks

Currently, I am facing an issue with a website that I am in the process of redesigning. The problem seems to be specific to Internet Explorer 7 (ie7). If you visit dev.indigoniche.com (you may be redirected back to the main site due to a cookie issue, in w ...

Show the initially chosen option in a dropdown menu when updating a record using mysqli

I recently came across a PHP page that handles relocation requests and allows users to edit them as needed. While the add page features dropdown boxes, the edit page simply displays them as text fields. This makes it difficult for users to select a differ ...

iOS nested elements: surrounding edges reveal parent's background

When viewing nested elements on iDevices, the parent's background is visible, creating a border or outline that is consistent across browsers (tested on Chrome and Safari). It has a similar effect to a bleed in printing. Can someone provide assistance ...