Today I Learned - Rocky Kev

Tagged “css”

  1. TIL the alternate keyword

    If 'alternate' appears along with the stylesheet keyword, the linked file is an alternative stylesheet. It won’t be applied to the document, but it will be ready for when we need it.

  2. TIL Logical Properties

    For that sweet sweet Internationalization you want to avoid directional words like 'left', 'right', 'top', and 'bottom'.

  3. TIL Using pseudo-classes in your querySelector!

    let notTuna = document.querySelectorAll('.sandwich:not(.tuna)')

  4. TIL Container Queries are live!

    After @container, elements can respond to a parent container size or style! The only caveat is the containers must declare themselves as possible query targets, which is a small requirement for a large benefit.

  5. TIL ":has" selector

    Before :has(), the subject of a selector was always at the end. Like 'ul > li:hover' or 'ul > li:not(.selected)'. Now we can do ul:has(> li)

  6. TIL individual transform CSS

    We now have individual transform CSS!

  7. TIL Shape-Outside to wrap text

    Shape-outside provides a way to customize this wrapping, making it possible to wrap text around complex objects rather than simple boxes.

  8. TIL no global styles

    Global styles is the largest **anti-pattern** in CSS --- strong DISAGREE.

  9. TIL aspect ratios

    We can target iframe elements directly with a few lines of CSS to preserve their dimensions in responsive layouts, without the need for a wrapper element.

  10. TIL getting the height with Javascript

    Say you wanted the height of a element. getComputedStyle gets you that. BUT -- it may lie about it to avoid css history leak. Instead use computedStyleMap.

  11. TIL adding a helper function for CSS classes

    I like this helper. This lets you quickly add/remove CSS classes to your elements in a easy-to-read way.

  12. TIL fingerprinting with CSS

    Fingerprinting refers to building up enough metadata about a user that you can essentially figure out who they are. JavaScript has access to all sorts of fingerprinting possibilities, which then combined with the IP address that the server has access to, means fingerprinting is all too common.

  13. TIL functions in sass

    You can declare functions in sass using @function. You can even write for loops, return values, and even create @warn and @error.

  14. TIL Little Big Details Easter eggs

    I was in search of Easter Eggs and found this Tumblr littlebigdetails.com. I was trying to find the easter egg in real life,,,. But it looks like the site switched to a JS framework. It looks very svelte, as it uses a lot of shadow dom elements!

  15. TIL passive aggressive easter egg

    Go to this corporate website and open the search (top right) and then submit with an empty search 7-8 times for a passive aggressive response.

  16. TIL how to get what browser with just css

    Today I learned about how to tell what browser you are using with just CSS.

  17. TIL safe areas for mobile browsers

    The problem you quickly encounter is that the visible viewport is not per se the same as the interactive viewport. Mobile browsers tend to prioritize essential UI elements (like the home-bar on IOS) for interactivity at all times.

  18. TIL reduce-motion-blur

    Dizziness and vertigo are symptoms of a vestibular balance disorder. If the user has set up a user preference that they prefer motion-based animation be disabled/reduced, we can tap into that. As web developers, we can also support them.

  19. TIL @Supports

    Unsupported CSS can break things. You typically wrap it in a @Supports rule.

  20. TIL Animista for generating CSS animations

    Animista is one of the best CSS tools you can use for animations. It gives you a collection of pre-made animations that you can use in your CSS.

  21. TIL generating fancy waves for HTML

    Get Waves is another amazing tool that will allow you to create SVG waves for your projects using CSS. It makes it much easier, you just choose the options, then the tool generates the right CSS code for your wave design.

  22. TIL how to use ':where()'

    You can probably also use a helper class like `no-bullets`. But this method does follow a default top-down approach pattern with CSS that i'm starting to also fall in love with.

  23. TIL prefers-color-scheme automatically

    For swapping between light mode and dark mode, you don't need JS. Using the `prefers-color-scheme`, that will automatically run the design code based on the user's preference.

  24. TIL Clippy for generating clip-path art

    Clip-path allows you to define a shape that will determine what parts of your HTML element are shown. You can use it to create all different kinds of shapes!

  25. TIL How to auto-grow textarea with pure css

    To do this, you replicate the content of the '<textarea>' in an element that can auto expand height, and match its sizing.Same font, same padding, same margin, same border… everything.

  26. TIL Disable users from highlighting text

    You can use the 'user-select' property to prevent an element from being highlighted by the user.

  27. TIL the Shared Element Transitions

    These cool effects exist on mobile. And Google and the Chrome team has been pushing for the web to have those complex transitions too.

  28. TIL the @layer feature in CSS

    With '@layer', the entry file can pre-define layers, and their order, ahead of time.

  29. TIL the wbr element

    '<wbr>' is a HTML element that represents a word break opportunity—a position within text where the browser may optionally break a line, though its line-breaking rules would not otherwise create a break at that location.

  30. TIL CSS Vulnerability in Yahoo Mail

    CSS doesn't immediately fail on parse errors. In 2009 it turned out Yahoo Mail was vulnerable to a fairly simple exploit. The attacker sends the user one email with a snippet of code and another email to run the code

  31. TIL add link decoration to help with accessibility

    One of the WCAG requirements is not to rely on color only when you want to distinguish a button or link from the rest of the text. Painting links in blue or another color doesn’t suffice since it still might not be visible for people with color blindness. The most typical method is underlining links; they can also appear in bold font.

  32. TIL an easy way to make rainbow text

    You can create gradient text by tweaking just three simple properties: background-image, color, and background-clip!

  33. TIL you can make your cursor display images

    The cursor element allows you to use 'url()'. It's required to include a fallback keyword (like 'auto') in case the image is broken.

  34. TIL a nice checklist/strikethrough animation

    Animating checkboxes by using the `:checked` pseudo-class. If it's true, then include other things (like a before/after psuedo-class with other effects.)

  35. TIL how to make numbers the same width and prevent shifting layout

    If your font supports it, you can use 'font-variant-numeric: tabular-nums'.

  36. TIL of using the "is" property

    The ':is()' CSS pseudo-class function takes a selector list as its argument, and selects any element that can be selected by one of the selectors in that list.

  37. TIL of this repo who made box shadow images

    That's right! You can make a single-pixel box shadow. You can also create multiple versions on the same line.

  38. TIL of a visual way to see CSS Cascade

    But then questions start arising: is !important higher priority than say, the Shadow DOM generated object?

  39. TIL how to add custom styles in WP Blocks

    Justin Tadlock of WPTavern recreates a theme in block patterns.

  40. TIL writing modes

    The 'writing-mode' CSS property determines if lines are laid our horizontally, or vertically. The direction is determined by the context of the direction of the content.

  41. TIL the hover media feature

    If you're on a phone or tablet, chances are -- you cannot hover. But if you're on desktop using a mouse -- you can!

  42. TIL A nice way to use calc to get margin space

    I love it when bootstrap containers automatically create padding based on size.

  43. TIL that it's ::before, not :before

    So what should you be using? Unless you time travel, double-colon.

  44. TIL Layers in CSS

    CSS goes through a lot of passes to determine style orders. Make the css more specific, and it takes priority. Add a '#', and it takes even more priority. Add a freakin' '!important;', and hurray, you're at the top.

  45. TIL I'm done with FontAwesome

    When I first discovered FontAwesome in 2013, I like everyone thought the same thing -- this is a MAJOR game changer. It is now 2022. As I look back, FontAwesome has become unsustainable.

  46. TIL You can change the blinking line

    The caret-color CSS property sets the color of the insertion caret, the visible marker where the next character typed will be inserted. This is sometimes referred to as the text input cursor.

  47. TIL CSS pseudo-element first-letter, to make a Drop Cap

    You can add a drop cap to a paragraph by using the ::first-letter pseudo-element.

  48. TIL the DOM and CSSOM

    DOM is the html. CSSOM is the design. Together, they become... WEBPAGE-PERSON.

  49. TIL using Flexbox column-gaps

    Using Column-gaps lets you space things out correctly, AND properly lays out your container elements.

  50. TIL CSS variable tricks

    If you want to change the background with Javascript, you can use a CSS variable.

  51. TIL How to actually do CSS Shadows

    A real world shadow has two main distinctive parts. Direct light casts the first shadow and ambient light casts the second.

  52. TIL about Constraint Validation API (forms)

    Inputs are pretty powerful. Right out of the box, they can autocomplete, validate data, create minimum/maximum lengths, allow for patterns, and even provide state!

  53. TIL about this method to generate infinite Utility Helpers with CSS

    Generating tailwind-like utils.

  54. TIL HTML's native hidden attribute

    To hide a DOM element: there's a native HTML attribute called `hidden`.

  55. TIL how to Make a Square with CSS with aspect-ratio

    The first figure is for the top and bottom dimension, the second is for left and right.

  56. TIL Disable pull-to-refresh on mobile

    By default, mobile browsers tend to provide a 'bounce' effect or even a page refresh when the top or bottom of a page (or other scroll area) is reached.

  57. TIL column-count

    Using the column-count property you can break an element's content into a specified number of columns.

  58. TIL Safari's one-off problems

    Safari is the new IE when it comes to web development. All the one-offs you will face

  59. TIL how many vendor prefixes are left as of 2021

    Per CSS Tricks, we have about 28 left!

  60. TIL system light mode and dark mode

    Ever notice on mobile devices or on macs, tabs go from light to dark depending on the time?

  61. TIL Separating purpose and appearance in CSS

    Appearance is how the variable looks. Purpose is the intent of the variable.

  62. TIL Truncating text with Ellipsis

    You know you get a body of text, but you only want a specific amount to be shown?

  63. TIL How CSS get added into the DOM

    Render Tree is CSSOM + DOM Tree with all the correct stylings

  64. TIL column gap for newspaper look

    Use `column-count` and `column-gap` to give it that sweet newspaper look.

  65. TIL Sticky navbars with pure CSS

    Google 'Sticky Header', and you'll get a crapton of tutorials. Here's a vanilla CSS way to do it.

  66. TIL Accessible CSS Accordions

    For years, I've been looking to find a CSS accordion that is also accessible.

  67. TIL CSS Counter

    CSS has a method to automagically generate numbers and pop it into the element itself.

  68. TIL outline-offset

    Some sites remove :focus. Those sites suck. They should instead do this:

  69. TIL injecting links when the user wants to print thew ebpage

    A neat code snippet: If the user prints the page (for some reason), links get injected into the print.

  70. TIL CSS @Supports Rule

    The CSS @supports rule is a great way to check for a new CSS feature.

  71. TIL CSS target everything but last element using Not

    Target everything but the last item in CSS

  72. TIL When to use Serif vs San-serif

    Serifs are recognized for having small decorative lines added as embellishment. San-Serif is basic.

  73. TIL CSS Text Stroke

    Making a outline on text, using text-shadow and the new text-stroke.

  74. TIL using images as borders

    Images as a border? Use cases are like pencil borders, or patterns

  75. TIL Overflow:clip

  76. TIL gap in CSS

    replacing hacky margin-bottom with gap within CSS

  77. TIL writing-mode

    How to flip text so it's sideways, for international reasons.

  78. TIL using math to pick CSS child elements

    These are some sweet CSS psuedoclass tricks.

  79. TIL @extend and it's alternatives

    I learned about `@extend` as a way to grab the styles from a element.

  80. TIL about adding Styling to scrollbars

    You can decorate your scrollbars with CSS

  81. TIL Colorfonts

    But what if you could define more than one color per glyph? That's ColorFonts!

  82. TIL About the first-letter pseudo-element

    There's a `first-letter` pseudo-element.

  83. TIL Switching to SVG for Icon Fonts

    Icon fonts on the web were fundamentally flawed from the beginning. With full SVG support, let's use that

  84. TIL Scroll Margin for anchor links

    When you use anchor links, it jumps to the content with the assigned ID. But it sucks.

  85. TIL Bootstrap 5 removing jQuery will reduce about 83kb of loading time

    Bootstrap 5-alpha1 has been officially launched dropping jQuery as a dependency and also removing browser support for Internet Explorer 10 and 11.

  86. TIL the difference between strong and i

    When to use strong vs i

  87. TIL reversing HTML lists

    Today I learned about the reverse attribute

  88. TIL about the bullet ::marker

    When you have a list element, you had to hack the css to change bullet items. Not anymore!

  89. TIL how to check if a dom element has a specific class

    How to destructure the classList into an array so you can use include()

  90. TIL about styling active/focus together

    Style active and focus at the same time. Some people get to your link or selection by keyboard.

  91. TIL how to use CSS to count things

    Using CSS Counter, counter-reset, and counter-increment.

  92. TIL You can look for elements with specific attributes

    Target elements via CSS with certain attributes

  93. TIL How to target Language

    Target language with CSS

  94. TIL You don't need bootstrap

    Bootstrap is big. Maybe you don't need it

  95. TIL how to center anything in CSS

    How to center anything - a decision tree.

  96. TIL 100vh bug on WebKit (iOS Safari)

    WebKit, iOS Safari is super annoying

  97. TIL Box-sizing

    Setting box-sizing to border-box is a neat trick to avoid any unexpected padding issue. It tells the browser to include any border and padding in the values you specify in that element’s width and height itself. For example, if your element width is 125px, then any padding you add will be included in that width(125px) itself.

  98. TIL difference between justify-content vs justify-items

    The 'justify-content' property aligns columns within the container. The 'justify-items' property aligns grid items within their tracks (not the entire container)

  99. TIL applying a filter directly to a background using backdrop-filter

    backdrop-filter applies to everything behind the element, to see the effect you must make the element or its background at least partially transparent.

  100. TIL clip-path and shape-outside

    You know how you can shape a picture into a circle, and then wrap text around it? You can do that with two features.

  101. TIL How to add a placeholder cursor in an input

    How to add a placeholder cursor in an input

See all tags.