The Chrome team's work must be exciting! Getting first-hand at the latest browser version and making cool demos to show off new features must feel great. Of course, I don't envy it at all! (You ask why?)
Back to the point, have you seen the release notes of Chrome 133? It is currently in beta, but the Chrome team has released a series of great new articles and impressive demos that are hard to ignore. I decided to put them together.
attr()
Widely used functions!
We have been able to use HTML attributes in CSS for a while, but it is limited to content
attributes and parses only strings.
<h1 id="Some-text">Some text</h1>
h1::before { content: ' (Color: ' attr(data-color) ') '; }
Bramus shows how to use it in Chrome 133 for any CSS attribute, including custom attributes. For example, we can get the value of the attribute and use it for the color
attribute of the element:
h1 { color: attr(data-color type(<color>), https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15bfff) }</color>
Of course, this is a simple example. But it shows that there are three components here:
- Properties (data-color)
- Type (type(
)) - Arbitrage value (https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15bffff)
Attributes are defined by ourselves. It is very convenient to be able to insert wildcards into tags and use them for style settings. type()
is a new feature that helps CSS identify the type of value being processed. If we are using numeric values, we can use a more concise writing method. For example, suppose we use attributes to set the font size of an element:
<div data-size="20">Some text</div>
Now we can set the font-size
attribute (unit in px):
h1 { font-size: attr(data-size px, 16); }
Arbitrage values are optional and may not be required depending on your use case.
Scrolling status in container query!
This is amazing! If you ever wanted a way to style the sticky element when it is in a "sticky" state, you'll know how cool it is to have such a feature. Adam Argyle uses the classic pattern of the alphabetical list and applies styles to the letter title when it is pasted to the top of the viewport. The same is true for scrolling snap elements and scrolling container elements.
In other words, when the elements are "stick", "snap", and "scrollable", we can style them.
A small example you need to open in the Chromium browser:
The overall idea (I only know so much now) is that we register a container...a container we can query. We set a container-type
for the container, which is the scroll type we are using. In this case, we use sticky positioning where the element is "paste" to the top of the page.
<h1 id="Some-text">Some text</h1>
The container cannot query itself, so it basically has to be a wrapper for the elements we want to paste. The menu is a little special because we have the <nav></nav>
element, which is usually populated with an unordered link list. So our <nav></nav>
can be used as a container for our query, because we are actually pasting the unordered list to the top of the page.
h1::before { content: ' (Color: ' attr(data-color) ') '; }
We can put the sticky logic directly on <nav></nav>
because it actually contains the pasted content:
h1 { color: attr(data-color type(<color>), https://www.php.cn/link/93ac0c50dd620dc7b88e5fe05c70e15bfff) }</color>
If we are using a sticky footer instead of a menu, we can use stuck: bottom
. But the point is that once the <nav></nav>
element is pasted to the top, we can apply styles to it in the @container
block as follows:
<div data-size="20">Some text</div>
Nesting other selectors in it seems to work as well. For example, when the navigation is sticky, we can change the link in the menu:
h1 { font-size: attr(data-size px, 16); }
So, yes. As I said, being part of the Chrome development team, it must be cool to get started with these features. Thank you very much to Bramus and Adam for continuing to introduce us to new features and the great effort to make such a great demo.
The above is the detailed content of Chrome 133 Goodies. For more information, please follow other related articles on the PHP Chinese website!

CSS Grid is a powerful tool for creating complex, responsive web layouts. It simplifies design, improves accessibility, and offers more control than older methods.

Article discusses CSS Flexbox, a layout method for efficient alignment and distribution of space in responsive designs. It explains Flexbox usage, compares it with CSS Grid, and details browser support.

The article discusses techniques for creating responsive websites using CSS, including viewport meta tags, flexible grids, fluid media, media queries, and relative units. It also covers using CSS Grid and Flexbox together and recommends CSS framework

The article discusses the CSS box-sizing property, which controls how element dimensions are calculated. It explains values like content-box, border-box, and padding-box, and their impact on layout design and form alignment.

Article discusses creating animations using CSS, key properties, and combining with JavaScript. Main issue is browser compatibility.

Article discusses using CSS for 3D transformations, key properties, browser compatibility, and performance considerations for web projects.(Character count: 159)

The article discusses using CSS gradients (linear, radial, repeating) to enhance website visuals, adding depth, focus, and modern aesthetics.

Article discusses pseudo-elements in CSS, their use in enhancing HTML styling, and differences from pseudo-classes. Provides practical examples.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

WebStorm Mac version
Useful JavaScript development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
