On this page you will see a HTML/CSS cheatsheet of new browser APIs and maybe something interesting.
.text-based-on-background {
--bg: #ccc;
background: var(--bg);
color: lch(from var(--bg) calc((49.44 - l) * infinity) 0 0);
}
More info at devongovett.
attr(id type(<custom-ident>), none)
for view transition names
Or use attr
like color: attr(data-custom-color type(<color>), red);
to read <p data-custom-color='blue'></p>
More info at bram.us.
field-sizing
to resize textarea, select, and input
If using field-sizing
define min-block-size
min-inline-size
max-inline-size
to constrain the element from becoming too much small or too much large.
textarea, select, input {
field-sizing: content;
}
textarea {
min-block-size: 3.5rlh;
min-inline-size: 20ch;
max-inline-size: 50ch;
}
select {
min-inline-size: 5ch;
min-block-size: 1.5lh;
}
input {
min-inline-size: 7ch;
}
Examples
interpolate-size
calc-size()
to animate width and height
Prevously this required JavaScript. Now it just works with CSS:
:root {
interpolate-size: allow-keywords;
}
div p {
overflow: hidden;
transition: all 0.2s;
height: 0;
}
div:hover p {
height: auto; /* this will now animate */
}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
More info at developer.chrome.com.
...post will be updated over time