This media is not supported in your browser
VIEW IN TELEGRAM
π Modifying Printed Page Layouts with
#css #page
@page#css #page
Sometimes, users need to print web pages on physical papers for offline use. Also, some users print web pages as PDF documents to save for future use. Some web apps offer server-based features to generate paper-friendly PDF documents, but you can also print any web page using the browserβs native printing feature.
The `page` CSS at-rule offers a way to customize page dimensions, orientation, and margins of printed pages without affecting the visible browser viewport. For example, the following CSS snippet sets a 1-inch margin and A4 landscape size for printed pages:
@page {
size: A4 landscape;
margin: 1in;
}This at-rule comes with `:first`, `:blank`, `:left`, and `:right` pseudo-classes to select specific pages of the printed document. Browse the official MDN documentation to learn more details about `page`.
π2
π Defining Custom List Styles with
#css #counterStyle
@counter-style#css #counterStyle
We often use ordered and unordered lists in HTML documents. For customizing them, standard browsers offer various inbuilt list marker types via the list-style-type CSS property. You can extend these list styles or implement custom styles from scratch with the @counter-style at-rule.
Look at the following CSS code snippet:
@counter-style emojis {
system: cyclic;
symbols: π΄ π π’;
suffix: ' ';
}
ul li {
list-style-type: emojis;
}Moreover, itβs possible to customize existing inbuilt list styles with this at-rule:
@counter-style decimal-mod {
system: extends decimal;
prefix: '( ';
suffix: ' ): ';
pad: 2 '0';
}
ol li {
list-style-type: decimal-mod;
margin-bottom: 2px;
}
ol li::marker {
color: #780794;
}The above CSS definition extends the default decimal list style by adding a prefix, suffix, and zero-padding.
This media is not supported in your browser
VIEW IN TELEGRAM
π
#css #startingStyle
Adding Initial DOM Rendering Transitions with @starting-style#css #startingStyle
When a DOM element gets rendered from an HTML document or JavaScript code snippet, it gets rendered without any initial transition animation. In the past, we typically implemented these initial animations with dynamically switched CSS classes via JavaScript. Nowadays, we can use CSS animations for these situations, but the initial animation concept undoubtedly belongs to the CSS transitions feature. The `starting-style` at-rule lets you set initial styles for a CSS selector, so you can build up a transition animation for the initial rendering step:
button {
padding: 12px;
border: none;
border-radius: 4px;
font-size: 16px;
background-color: #bbb;
opacity: 1;
transform: scale(1);
transition: all 1s linear;
@starting-style {
opacity: 0;
transform: scale(0.5);
}
}
The above code snippet plays a transition animation when a button element gets rendered on the viewport. This transition works even though you dynamically create a new element with JavaScript.
π2
πHow to setup Angular + Supabase
#angular #supabase
π Supabase link β
Article link
#angular #supabase
Supabase as a Firebase alternative
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
π₯2
πDefining Scoped CSS with
#css #scope
@scope#css #scope
By default, the traditional CSS implementation styles web pages with a global scoping concept. Moreover, in the past, no CSS scoping feature was present with the style tag, every style tag was feasible for styling any HTML node, including the root regardless of the style tag position in the DOM tree. The HTML standard tried to support scoping with the scoped attribute, but it was deprecated before becoming a web standard. Now, the modern CSS specification introduced the `scope` at-rule for defining scoped CSS.
For example, you can create a scoped style tag for styling an HTML segment as follows:
<div>
<style>
@scope {
:scope {
background-color: #ddd;
padding: 12px;
}
h3 {
padding: 0 0 6px 0;
margin: 0;
border-bottom: solid 2px #eb7e3b;
}
}
</style>
<h3>Lorem ipsum dolor sit amet</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
The above style tag defines a scoped CSS content for the parent div element with @scope. Here, we targeted the scoped element using the :scope pseudo-class.
π1
This media is not supported in your browser
VIEW IN TELEGRAM
πModern Component-Oriented Responsive Design with
#css #container
The modern CSS specification offers container queries via the @container at-rule for this requirement.
Look at the following sample:
@container#css #container
The modern CSS specification offers container queries via the @container at-rule for this requirement.
Look at the following sample:
<div class="alert">
<h3>Lorem ipsum dolor sit amet</h3>
<button>Lorem ipsum</button>
<button>Lorem ipsum</button>
</div>
.alert {
background-color: #ddd;
padding: 12px;
resize: horizontal;
overflow: hidden;
container-type: inline-size;
}
.alert h3 {
padding: 0 0 6px 0;
margin: 0 0 12px 0;
border-bottom: solid 2px #eb7e3b;
}
.alert button {
padding: 12px;
border: none;
margin-right: 6px;
}
@container (width < 400px) {
.alert button {
width: 100%;
box-sizing: border-box;
}
.alert button:not(:last-child) {
margin-bottom: 10px;
}
}π2
π Handling CSS Precedence with
#css #layer
@layer#css #layer
In web design scenarios, developers typically use multiple CSS selectors and often have to override styles. Even though you donβt override CSS styles with multiple selectors by yourself, every CSS block you write automatically overrides styles from the user-agent stylesheet. CSSβs style overriding process happens based on the browserβs specificity algorithm that calculates a weight for CSS selectors for handling precedence. In the past, every developer tweaked their CSS overriding-related code based on the specificity algorithm since they didnβt have a way to handle CSS precedence without using confusing !important.
π1