What is the reason that CSS clamp() does not function properly when using only zero without any units?

Check out my pen where I demonstrate a bug: https://codepen.io/dimakrutoo/pen/PoGZymb

When the value of --layoutWMin is changed from "0px" to "0", it causes the calculations to fail.

Why does the clamp() function not work with a zero value without units?

UPD

For a clearer example, take a look here: https://codepen.io/dimakrutoo/pen/RwGarWY

Answer №1

I didn't cover everything in my response due to character limitations.

Although I can't provide a full explanation, it's worth noting that the clamp function resolves to max(MIN, min(VAL, MAX)). You can find more information at https://developer.mozilla.org/en-US/docs/Web/CSS/clamp(). When the first parameter is 0 and the second has a unit, max and min behave similarly.

There are numerous posts on Stack Overflow with many accepted and upvoted answers that now seem inaccurate because they claim that 0 and 0px are equivalent (according to the specification as far as I can tell).

It could be a bug or a feature, but it's crucial to be aware of this distinction. Thank you for bringing attention to it.

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

Executing a function a specific number of times in Jquery

I have a query regarding JQuery related to randomly placing divs on a webpage. The issue I'm facing is that it currently does this indefinitely. Is there a way to make it run for a specific duration and then stop? $(document).ready(function () { ...

A guide on applying color from an API response to the border-color property in an Angular application

When I fetch categoryColor from the API Response, I set border-left: 3px solid {{element.categoryColor}} in inline style. Everything is functioning correctly with no development issues; however, in Visual Studio, the file name appears red as shown in the i ...

The navigation bar components created with Bootstrap are experiencing issues with their active state functionality

I created a Navbar using Bootstrap code but I am facing an issue where the 'active' state is not being applied to the Navbar elements on my webpage. I have been attempting to add and remove the active class on the Navbar elements, but I have bee ...

"Extracting Text from Images: Convert Images to Text using Optical Character Recognition

While referencing a live Codepen demonstration available at this link, the application functions correctly when the "choose file" button is clicked to upload an image from the local computer and extract text from it. However, my question is how can I uploa ...

Is there a way to retrieve JSON data from a different domain and incorporate it into my own website?

I am attempting to utilize JSON data from "" and display the data on my website. My goal is to extract the JSON field name "Stats" and retrieve the sub-field name '\"v\"'. You can refer to the documentation provided by purpleair here: h ...

Utilizing .NET MVC for incorporating HTML attributes with @HTMLTextAreaFor

I'm encountering an issue when trying to add HTML attributes to a text area using the @HTML command. Specifically, I am attempting to include a class name, but it doesn't seem to be working as expected. Below is the code snippet that I am workin ...

How to align items at the center in material-ui styling

I have a row of cards inside a container that I want to align in the center with equal spacing around them. I am using the material-ui UI library for the layout. Despite adding the justifyContent: center property, the cards are not evenly spaced. This is ...

Tips for centering text and icon on a Bootstrap navigation bar

I am currently developing an Angular 4 application that includes a navigation bar with text and font awesome icons. While the UI looks good in web view, I'm facing alignment issues when it comes to mobile view (minimized screen). Despite my efforts, ...

I am having trouble with my custom-button class not successfully overriding the btn background color property. Can anyone provide insight

Utilizing the bootstrap5 variant-button mixin, I aim to create a custom-colored button. While I have successfully altered the default hover effect color, I am encountering difficulty in setting the background color of the button itself. Upon inspecting the ...

Effectively handling server downtime with AngularJS $resource

I've implemented this code in my services.js file: angular.module('appServices', ['ngResource']). factory('User',function ($resource) { return $resource('http://localhost\\:3001/api/user/:id', { ...

Updating Gmaps iFrame URL with AJAX

I am currently attempting to update the SRC of an iFrame by using a URL obtained via AJAX from the backend database. I want the maps to change when a button is clicked. An error message displayed inside the iFrame reads, "404. That’s an error. The reque ...

Can the text within an li element be accessed using Xpath even with varying attributes?

Instead of directly using: driver.FindElement(By.XPath("//ul[3]/li/ul/li[7]")).Text I am exploring ways to retrieve the text by utilizing Xpath along with different attributes like text(), contains(), and so on. //ul[3]/li/ul/li//[text()='My Data&a ...

The image tag fails to appear on the browser when the client attempts to access it

Greetings, I am new to web development. I am attempting to create a simple static website that only displays an image in the header tag of an HTML file. The server seems to be working correctly in sending responses to the client, but the problem lies in t ...

CSS Word Breaker: Shattering Text into Pieces

Is there a way to prevent long words in the <p> tag from breaking awkwardly in the browser? I attempted to use the CSS property word-break: break-all;, but it seems that Firefox and Opera do not support this feature. Additionally, normal words are al ...

What is the best way to eliminate the data-0 attribute from a div element?

Here is an example of my HTML code. <div id="asa" class="bg" data-0="transform:scale(1, 1); opacity:1" data-1000="transform:scale(2, 1); opacity:0.5" data-5000="transform:scale(2, 2); opacity:1&qu ...

Ways to apply inline styling with CSS in a React class-based component

Is it possible to apply inline CSS in a React class component? Here is an example of the CSS I have: { font-size: 17px; 
 font-family: Segoe UI Semibold; color: #565656; text-shadow: 0 1px 1px white; } While this CSS works fine ...

The indicated size of the viewport does not match the anticipated value

My goal is to incorporate responsive web design into my project and I have specified the viewport size as follows: <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> I expected this setting to adjust the vie ...

"Send the selected radio button options chosen by the user, with the values specified in a JSON format

My current task involves inserting radio button values into a MySql database using Angular. The form consists of radio buttons with predefined values stored in a json file. Below is an example of how the json file is structured: //data.json [{ "surve ...

What sets XHTML 1.1 apart from other document types?

Visit this page for more information: XHTML 1.1 makes it simple to create various display formats, including printing pages, wireless device and PDA pages, and browser pages for television by creating a new CSS (cascading style sheet) for the specific ...

The image is not properly aligned with the background image

I'm currently working on a page design using bootstrap and css where I want images to fade and reveal the background when hovered over. The challenge I'm facing is that although all images are set to 100px in size, there is white space visible ar ...