CSS – Place Self

CSS – place-self Property ”; Previous Next CSS place-self is a shorthand property that aligns the individual items in both block and inline directions simultaneously, similar to properties like align-self and justify-self in layout systems like Grid or Flexbox. The first value is used if the second value is not set. This property is a shorthand for the following CSS properties: align-self justify-self Possible Values auto − Aligns the item based on the parent”s align-self value. normal− Based on the layout mode, the effect of normal keyword changes: Behaves like start on replaced absolutely-positioned boxes, and as stretch in all other absolutely-positioned boxes, when the layout is absolutely-positioned. Behaves like stretch in static position of absolutely-positioned layouts. Behaves like stretch for flex items. Behaves similar to stretch for grid items, except for the boxes which have an aspect ratio or an intrinsic size where it behaves like start. Does not apply to block-level boxes , and to the table cells. self-start− Items are aligned to the edge of the alignment container corresponding to the start side of the item, in the cross-axis. self-end − Items are aligned to the edge of the alignment container corresponding to the end side of the item, in the cross-axis. flex-start − Aligns the cross-start margin edge of the flex item with the cross-start edge of the line. flex-end− Aligns the cross-end margin edge of the flex item with the cross-end edge of the line. center− Margins of flex-item box is centered within the line on the cross-axis. When the cross-size of an element is larger than the container, the content overflows equally in both directions. baseline, first baseline, last baseline − First baseline, and last baseline are synonym to baseline. First and last refer to the line boxes within the flex items. These values specify the involvment of first- or last-baseline alignment in the alignment of the content. start is the fallback alignment for first-baseline and end for last-baseline. stretch − When the combined size of the items along with the cross-axis is less than the size of the container, and the item is sized as auto, its size is increased equally, maintaining the values of max-height / max-width. Applies To Block-level boxes, absolutely-positioned boxes, and grid items. Syntax Keyword Values place-self: auto center; place-self: normal start; Positional Alignment place-self: center normal; place-self: start auto; place-self: end normal; place-self: self-start auto; place-self: self-end normal; place-self: flex-start auto; place-self: flex-end normal; Baseline Alignment place-self: baseline normal; place-self: first baseline auto; place-self: last baseline normal; place-self: stretch auto; CSS place-self – normal start Value The following example demonstrates the place-self: normal start property aligns Item 2 to the start of its grid cell − <html> <head> <style> .container { background-color: red; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 100px; grid-gap: 10px; margin: 20px; width: 300px; } .container > div { background-color: greenyellow; border: 3px solid blue; text-align: center; margin: 5px; width: 60px; height: 50px; } .item2 { place-self: normal start; } </style> </head> <body> <div class=”container”> <div>Item 1</div> <div class=”item2″>Item 2</div> <div>Item 3</div> <div>Item 4</div> </div> </body> </html> CSS place-self – auto center Value The following example demonstrates the place-self: auto center property aligns Item 2 at the center of its grid cell − <html> <head> <style> .container { background-color: red; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 100px; grid-gap: 10px; margin: 20px; width: 300px; } .container > div { background-color: greenyellow; border: 3px solid blue; text-align: center; margin: 5px; width: 60px; height: 50px; } .item2 { place-self: auto center; } </style> </head> <body> <div class=”container”> <div>Item 1</div> <div class=”item2″>Item 2</div> <div>Item 3</div> <div>Item 4</div> </div> </body> </html> CSS place-self – center normal Value The following example demonstrates the place-self: center normal property aligns Item 2 at the center horizontally and vertically of its grid cell − <html> <head> <style> .container { background-color: red; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 100px; grid-gap: 10px; margin: 20px; width: 300px; } .container > div { background-color: greenyellow; border: 3px solid blue; text-align: center; margin: 5px; width: 60px; height: 50px; } .item2 { place-self: center normal; } </style> </head> <body> <div class=”container”> <div>Item 1</div> <div class=”item2″>Item 2</div> <div>Item 3</div> <div>Item 4</div> </div> </body> </html> CSS place-self – end normal Value The following example demonstrates the place-self: end normal property aligns Item 2 on the right edge of its grid cell vertically and horizontally to the top edge of its grid cell − <html> <head> <style> .container { background-color: red; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 100px; grid-gap: 10px; margin: 20px; width: 300px; } .container > div { background-color: greenyellow; border: 3px solid blue; text-align: center; margin: 5px; width: 60px; height: 50px; } .item2 { place-self: end normal; } </style> </head> <body> <div class=”container”> <div>Item 1</div> <div class=”item2″>Item 2</div> <div>Item 3</div> <div>Item 4</div> </div> </body> </html> CSS place-self – start auto Value The following example demonstrates the place-self: start auto property aligns Item 2 to the start of its grid cell − <html> <head> <style> .container { background-color: red; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 100px; grid-gap: 10px; margin: 20px; width: 300px; } .container > div { background-color: greenyellow; border: 3px solid blue; text-align: center; margin: 5px; width: 60px; height: 50px; } .item2 { place-self: start auto; } </style> </head> <body> <div class=”container”> <div>Item 1</div> <div class=”item2″>Item 2</div> <div>Item 3</div> <div>Item 4</div> </div> </body> </html> CSS place-self – self-start auto Value The following example demonstrates the place-self: self-start auto property positioned Item 2 at the start of the row vertically and automatically in the horizontal direction −

CSS – Text Effects

CSS Filters – text-effect Property ”; Previous Next CSS provides an extremely powerful tool that can help in addition of special visual effects to text, images, background, borders, etc. The filters are useful in adjusting the rendering of these aspects of a webpage. In this chapter, we will discuss about each CSS filter in detail with examples. The filter property can have value as none or one or more functions listed later in the chapter. If no or an invalid parameter is passed to any function, it returns none. The functions that accept the parameter value in percentage (%), also accepts the same value expreseed in decimal. For example, 55% can be passed as 0.55 Multiple functions can be passed to filter property; just that you need to add space between them. When multiple functions is passed, these filters are applied in the order they are passed. The same filter function can be repeated. For example: filter:blur(20px) hue-rotate(45deg) blur(15px). Following is the list of functions that can be used with filter property: Sr.No. Function Parameter Description Example 1 blur() Radius of blue effect (px, rem, etc) Applies a blur effect to the input image. filter:blur(10px); 2 brightness() Value is a percentage or a decimal(%). 0% – black image, 100% – no effect, over 100% – brightens element. Adjusts the brightness of the element. filter:brightness(62% | 0.62); 3 contrast() Value is a percentage or a decimal(%). 0% – grey, 100% – no effect, over 100% – creates contrast. Adjusts the contrast of the element. filter:contrast(200%); 4 grayscale() Value is a percentage or a decimal(%). 0% – no effect, 100% – completely grayscale. Converts the element to grayscale. filter:grayscale(80%); 5 drop-shadow() Value specifies the horizontal and vertical offset, the blur radius, and the color of the shadow. Applies a drop shadow effect to the element filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5)); 6 hue-rotate() Value is an angle in degrees. Applies a hue rotation to the element. filter:hue-rotate(80deg); 7 invert() Value is an angle in degrees. Inverts the colors of the element. filter: invert(75%); 8 opacity() Value is a percentage. 0% – fully transparent, 100% – fully opaque. Adjusts the transparency of the element. filter: opacity(75%); 9 saturate() Value is a percentage. Adjusts the saturation of the element. filter: saturate(200%); 10 sepia() Value is a percentage. Adjusts a sepia effect to the element. filter: sepia(90%); 11 url() Value is the path of XML file that specifies an SVG filter, and may include an anchor to a specific filter element. For applying SVG filters. filter:url(svg-url#element-id); CSS filter – blur() The blur() function is used to add blur effects to the text or an image. The function can have following value as parameter: blur radius: specified as a <length> value. The greater the value, more will be the blur effect. Default value is 0. The function does not accept percentage value. Here is an example: <html> <head> </head> <body> <h2>Blur effect </h2> <div> <h3 style=”filter: blur(2px); font-size: 3rem;”>Blur(5px)</h3> <img style=”filter: blur(5px); width: 400px; height: 300px;” src=”images/red-flower.jpg” alt=”showing blur effect”> </div> <div> <h3 style=”filter: blur(0.5rem); font-size: 3rem;”>Blur(2rem)</h3> <h3>Blur(5px)</h3> <img style=”filter: blur(5px); width: 400px; height: 300px;” src=”images/red-flower.jpg” alt=”showing blur effect”> </div> <div> <h3>Blur(2rem)</h3> <img style=”filter: blur(2rem); width: 400px; height: 300px;” src=”images/red-flower.jpg” alt=”showing blur effect”> </div> </body> </html> CSS filter – brightness() brightness() function is used to add brightness effect to the text or an image, by applying a linear multiplier value. This makes the element look brighter or darker. The function can have following value as parameter: amount: specified as a <number> or a <percentage> value. Value less than 100%, makes the element darker. Value over 100%, makes the element bright. Value equal to 100% have no effect. Default value is 1. Negative values are not allowed. Here is an example: <html> <head> </head> <body> <h2>Brightness effect </h2> <div> <h3 style=”filter: brightness(120%); font-size: 2rem;”>Brightness(120%)</h3> <img style=”filter: brightness(120%); width: 400px; height: 300px;” src=”images/red-flower.jpg” alt=”showing brightness effect”> </div> <div> <h3 style=”filter: brightness(0.38); font-size: 2rem;”>Brightness(0.38)</h3> <h3>Brightness(120%)</h3> <img style=”filter: brightness(120%); width: 400px; height: 300px;” src=”images/red-flower.jpg” alt=”showing brightness effect”> </div> <div> <h3>Brightness(0.38)</h3> <img style=”filter: brightness(0.38); width: 400px; height: 300px;” src=”images/red-flower.jpg” alt=”showing brightness effect”> </div> </body> </html> CSS filter – contrast() contrast() function is used to add contrast effect to the text or an image. The function can have following value as parameter: amount: specified as a <number> or a <percentage> value. Value less than 100%, decreases the contrast. Value over 100%, increases the contrast. Value equal to 0% or 0, will make the element fully gray. Value equal to 100% have no effect. Default value is 1. Negative values are not allowed. Here is an example: <html> <head> </head> <body> <h2>Contrast effect </h2> <div> <h3 style=”filter: contrast(20%); font-size: 2rem;”>Contrast(120%)</h3> <img style=”filter: contrast(120%); width: 400px; height: 300px;” src=”images/red-flower.jpg” alt=”showing contrast effect”> </div> <div> <h3 style=”filter: contrast(0.5); font-size: 2rem;>Contrast(0.38)</h3> <h3>Contrast(120%)</h3> <img style=”filter: contrast(120%); width: 400px; height: 300px;” src=”images/red-flower.jpg” alt=”showing contrast effect”> </div> <div> <h3>Contrast(0.38)</h3> <img style=”filter: contrast(0.38); width: 400px; height: 300px;” src=”images/red-flower.jpg” alt=”showing contrast effect”> </div> </body> </html> CSS filter – Drop Shadow Effect Drop Shadow is a blurred version of the image, shown in

CSS – Place Content

CSS – place-content ”; Previous Next CSS place-content is a shorthand property that aligns content in both the block (column) and inline (row) axes simultaneously. It is used to set both the align-content and justify-content properties in a single declaration. This property is a shorthand for the following CSS properties: align-content justify-content Possible Values start − Items are aligned to each other against the start edge of the container in the corresponding axis. end − Items are aligned to each other against the end edge of the container in the corresponding axis. flex-start − Aligns the items at the start of the flex container. flex-end − Aligns the items at the end of the flex container. center − Aligns the items at the center of the flex container. left − Aligns the items to the left side of the alignment container. This value acts like start if the property”s axis is not parallel to the inline axis. right − Aligns the items to the right edge of the alignment container in the appropriate axis. This value acts like start if the property”s axis is not parallel to the inline axis. space-between − Items within the alignment container are evenly distributed, with equal spacing between adjacent items, with thefirst and last items are aligned with the main-start and main-end edge. baseline, first baseline, last baseline − These values specify the involvment of first or last baseline alignment in the alignment of the content. First and last baseline are synonym to baseline. First and last refer to the line boxes within the flex items. The start is the fallback alignment for first-baseline and end for last-baseline. space-around − Items within the alignment container are evenly distributed. Each pair of adjacent elements has the same spacing before the first and last items is half the distance between adjacent items. space-evenly − Items within the alignment container are evenly distributed, with equal spacing between adjacent items and at the main-start and main-end edges. stretch − If the total size of items along the main axis is smaller than the alignment container, auto-sized items increase their size equally to fill the container, respecting max-height/max-width constraints. safe − Used with an alignment keyword and when the item overflows the container, causing any loss of data, the alignment is set as per the start value. unsafe − Used with an alignment keyword and even if the item overflows the container, causing any loss of data, the alignment value passed is honored. Applies To Multi-line flex containers. Syntax Positional Alignment place-content: center start; place-content: start center; place-content: end left; place-content: flex-start center; place-content: flex-end center; Baseline Alignment place-content: baseline center; place-content: first baseline space-evenly; place-content: last baseline right; Distributed Alignment place-content: space-between space-evenly; place-content: space-around space-evenly; place-content: space-evenly stretch; place-content: stretch space-evenly; The first property value is align-content and the second is justify-content. If the second value is missing, the first value is used for both, as long as it is valid. If it is invalid for both, the entire value is invalid. CSS place-content – center start Value The following example demonstrates property place-content: center start aligns flex items horizontally towards the center and vertically towards the top of the container − <html> <head> <style> .flex-container { background-color: red; height: 300px; border: 2px solid black; display: flex; flex-wrap: wrap; place-content: center start; } .flex-container > div { flex-basis: 100px; height: 50px; margin: 5px; background-color: greenyellow; } </style> </head> <body> <div class=”flex-container”> <div>Flex item 1</div> <div>Flex item 2</div> <div>Flex item 3</div> <div>Flex item 4</div> <div>Flex item 5</div> <div>Flex item 6</div> <div>Flex item 7</div> </div> </body> </html> CSS place-content – start center Value The following example demonstrates property place-content: start center aligns flex items along the left edge of the container horizontally and vertically in the center of the container − <html> <head> <style> .flex-container { background-color: red; height: 300px; border: 2px solid black; display: flex; flex-wrap: wrap; place-content: start center; } .flex-container > div { flex-basis: 100px; height: 50px; margin: 5px; background-color: greenyellow; } </style> </head> <body> <div class=”flex-container”> <div>Flex item 1</div> <div>Flex item 2</div> <div>Flex item 3</div> <div>Flex item 4</div> <div>Flex item 5</div> <div>Flex item 6</div> <div>Flex item 7</div> </div> </body> </html> CSS place-content – end right Value The following example demonstrates property place-content: end right aligns the flex items to the right edge horizontally and the bottom edge vertically − <html> <head> <style> .flex-container { background-color: red; height: 300px; border: 2px solid black; display: flex; flex-wrap: wrap; place-content: end right; } .flex-container > div { flex-basis: 100px; height: 50px; margin: 5px; background-color: greenyellow; } </style> </head> <body> <div class=”flex-container”> <div>Flex item 1</div> <div>Flex item 2</div> <div>Flex item 3</div> <div>Flex item 4</div> <div>Flex item 5</div> <div>Flex item 6</div> <div>Flex item 7</div> </div> </body> </html> CSS place-content – flex-start center Value The following example demonstrates property place-content: flex-start center aligns the flex items horizontally towards the left edge and vertically towards the center of the container − <html> <head> <style> .flex-container { background-color: red; height: 300px; border: 2px solid black; display: flex; flex-wrap: wrap; place-content: flex-start center; } .flex-container > div { flex-basis: 100px; height: 50px; margin: 5px; background-color: greenyellow; } </style> </head> <body> <div class=”flex-container”> <div>Flex item 1</div> <div>Flex item 2</div> <div>Flex item 3</div> <div>Flex item 4</div> <div>Flex item 5</div> <div>Flex item 6</div> <div>Flex item 7</div> </div> </body> </html> CSS place-content – flex-end center Value The following example demonstrates property place-content: flex-end center aligns the flex items horizontally towards the right end and vertically towards the center of the container − <html> <head> <style> .flex-container { background-color:

CSS – Printing

CSS Printing ”; Previous Next Printing is an important aspect of any application or webpage. Print of a content can be made very different from its interface look. While printing a user may want to: Use images with higher resolution for more clearer and better result. Adjust the application”s or website”s layout, as per the size and shape of the page. Enhance the overall appearance of the application or website on printing. Provide additional styles only applicable for printing. In order to manage all your printing needs and process, you may take an account of the points referred in this article. CSS Printing – Using A Print Style Sheet You can have a stylesheet explicitly for printing needs and link it to your code. Add the following code block in your html: <link href=”/path/to/print.css” media=”print” rel=”stylesheet” /> CSS Printing – Using Media Queries and @page At-Rule CSS provides the @media at-rule, that can be used to set different styling needs for your webpage when printed on a page or displayed on screen, using the options print and screen, respectively. You can add the following code block at the end of your stylesheet. This is an example. @media print { /* All print related styles to be added here */ #header-part, #footer-part, #nav-part { display: none !important; } } The above code snippet will not print the styles of #header-part, #footer-part, and #nav-part, while printing. The various aspects of pages, such as, orientation, dimension, margin, etc. can be adjusted and modified using the @page at-rule. All the pages or sub-set of some pages can be targeted using this rule, while taking the print. CSS Printing – Print Requests Detection The events beforeprint and afterprint are sent by the browsers to let the content determine, when the printing may have occurred. This feature can be used to adjust the printing layout and the user interface during printing process. CSS Printing – Using @page at-rule In the following example, the content of the webpage is divided into sections, which when opened in print format, breaks into different pages and the margin of the pages is also set in the print format. <html> <head> <style> @page { size: landscape; margin: 15%; } section { page-break-after: always; break-after: page; background-color: aquamarine; width: 500px; } @media print { button { display: none; } } </style> </head> <body> <article> <section> <h2>Header1</h2> <p> Section one </p> </section> <section> <h2>Header2</h2> <p> Section two </p> </section> <section> <h2>Header3</h2> <p> Section three </p> </section> </article> <button style=”background-color: green; color: white; font-size: 1em;”>Print</button> <script> const button = document.querySelector(“button”); button.addEventListener(“click”, () => { window.print(); }); </script> </body> </html> CSS Printing – Using @media Query The following example demonstrates the use of a media query (@media), where a format or style is specified for screen display and the same content is changed for print format. On click of Print button, the page layout and style changes. <html> <head> <style> @media screen { h2 { font-size: large; font-family: Verdana, Geneva, Tahoma, sans-serif; color: blue; font-style: normal; } } @media print { h2 { font-family: cursive; font-style: italic; color: red; } } @media print { button {display: none;} } </style> </head> <body> <article> <section> <h2>Header1</h2> <p> Section one </p> </section> <section> <h2>Header2</h2> <p> Section two </p> </section> <section> <h2>Header3</h2> <p> Section three </p> </section> </article> <button style=”background-color: green; color: white; font-size: 1em;”>Print</button> <script> const button = document.querySelector(“button”); button.addEventListener(“click”, () => { window.print(); }); </script> </body> </html> CSS Printing – Use Of afterprint Event Following example demonstrates the use of afterprint event and post printing the page closes itself and goes back to the last page. <html> <head> <style> @media screen { h2 { font-size: large; font-family: Verdana, Geneva, Tahoma, sans-serif; color: blue; font-style: normal; } } @media print { h2 { font-family: cursive; font-style: italic; color: red; } } @media print { button {display: none;} } </style> </head> <body> <article> <section> <h2>Header1</h2> <p> Section one </p> </section> <section> <h2>Header2</h2> <p> Section two </p> </section> <section> <h2>Header3</h2> <p> Section three </p> </section> </article> <button style=”background-color: green; color: white; font-size: 1em;”>Print</button> <script> const button = document.querySelector(“button”); button.addEventListener(“click”, () => { window.print(); }); window.addEventListener(“afterprint”, () => self.close); </script> </body> </html> CSS Printing – Link To An External Style Sheet The print styles can be added in a file and the same CSS file can be linked to your html code, as an external stylesheet. Refer the example below: <html> <head> <link href=”print.css” media=”print” rel=”stylesheet” /> <style> @media screen { h2 { font-family: Verdana, Geneva, Tahoma, sans-serif; font-style: normal; color: rebeccapurple; } } </style> </head> <body> <article> <section> <h2>Header1</h2> <p> Section one </p> </section> <section> <h2>Header2</h2> <p> Section two </p> </section> <section> <h2>Header3</h2> <p> Section three </p> </section> </article> <button style=”background-color: green; color: white; font-size: 1em;”>Print</button> <script> const button = document.querySelector(“button”); button.addEventListener(“click”, () => { window.print(); }); </script> </body> </html> Print Page Previous Next Advertisements ”;

CSS – Writing Mode

CSS – writing-mode Property ”; Previous Next CSS writing-mode property is used to specify the direction of text content flows within an element. It specifies whether text should be displayed horizontally or vertically. It is particularly useful for handling text orientation in non-Latin scripts, such as Chinese, Japanese, and Arabic, as well as for creating creative and visually interesting layouts. Possible Values horizontal-tb − Default value. It sets the text to be laid out in horizontal writing mode, where text flows from left to right and top to bottom, as in most Western languages. vertical-rl − This value specifies a vertical writing mode from right to left, commonly used for scripts like Chinese, Japanese, or Korean. Text flows vertically, starting from the right and proceeding to the left. vertical-lr − Similar to vertical-rl, this value also represents a vertical writing mode, but the text flows from left to right, which is used in scripts like Mongolian. sideways-rl − This value specifies vertical text flow from top to bottom, but positions the text from right to left. This value is used for vertical scripts like Mongolian or some forms of vertical Japanese text, where the characters are rotated 90 degrees clockwise and read from right to left. sideways-lr − This value specifies vertical text flow from bottom to top, but positions the text from left to right. The lr, lr-tb, rl, tb, tb-lr, and tb-rl writing modes in CSS are deprecated, and should no longer be used. Instead, you should use the horizontal-tb or vertical-lr writing modes. The following table shows the deprecated writing modes and their equivalents: Deprecated Value Equivalent Value lr horizontal-tb rl horizontal-tb lr-tb horizontal-tb tb vertical-lr tb-lr vertical-lr tb-rl vertical-rl Applies to All the HTML elements except table row groups, table column groups, table rows, and table columns. DOM Syntax object.style.writingMode = “horizontal-tb|vertical-rl|vertical-lr|sideways-rl|sideways-lr”; CSS writing-mode – horizontal-tb Value The following example demonstartes writing-mode property set to value horizontal-tb, where text is read from left to right and top to bottom − <html> <head> <style> .box { width: 250px; background-color: pink; writing-mode: horizontal-tb; } </style> </head> <body> <h2>CSS writing-mode: horizontal-tb</h2> <div class=”box”> Lorem ipsum dolor sit amet, consectetur adipiscing 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. </div> </body> </html> CSS writing-mode – vertical-rl Value The following example demonstartes writing-mode property set to value vertical-rl, where text is read from right to left and top to bottom − <html> <head> <style> .box { height: 250px; background-color: pink; writing-mode: vertical-rl; } </style> </head> <body> <h2>CSS writing-mode: vertical-rl</h2> <div class=”box”> Lorem ipsum dolor sit amet, consectetur adipiscing 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. </div> </body> </html> CSS writing-mode – vertical-lr Value The following example demonstartes that the writing-mode property set to value vertical-rl value, where text is read from left to right and top to bottom: − <html> <head> <style> .box { height: 250px; background-color: pink; writing-mode: vertical-lr; } </style> </head> <body> <h2>CSS writing-mode: vertical-lr</h2> <div class=”box”> Lorem ipsum dolor sit amet, consectetur adipiscing 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. </div> </body> </html> CSS writing-mode – sideways-rl Value The sideways-rl value is only supported by Firefox Browser. The following example demonstrates that writing-mode property set to value sideways-rl, where text read vertically from top to bottom, with characters arranged from right to left − <html> <head> <style> .box { height: 300px; background-color: pink; writing-mode: sideways-rl; } </style> </head> <body> <h2>CSS writing-mode: sideways-rl – This example is only supported by Firefox Browser.</h2> <div class=”box”> Lorem ipsum dolor sit amet, consectetur adipiscing 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. </div> </body> </html> CSS writing-mode – sideways-lr Value The sideways-lr value is only supported by Firefox Browser. The following example demonstrates that writing-mode property set to value sideways-lr, where text is read vertically from top to bottom, with characters arranged from left to right − <html> <head> <style> .box { height: 300px; background-color: pink; writing-mode: sideways-lr; } </style> </head> <body> <h2>CSS writing-mode: sideways-lr – This example is only supported by Firefox Browser.</h2> <div class=”box”> Lorem ipsum dolor sit amet, consectetur adipiscing 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. </div> </body> </html> CSS writing-mode – Asthetic Use (english Language) The

CSS – Inset

CSS – inset ”; Previous Next The CSS property inset is a shorthand for the other CSS properties top, right, bottom, and / or left. It follows the same multi-value syntax as that of margin CSS property. The inset property specifies the physical offsets, irrespective of the writing mode, direction, and text orientation of the element. Possible Values The CSS property inset takes the same set of values as left CSS property, which are as follows: <length> − Can specify a negative, null or positive value. <percentage> − Percentage of the container”s width. auto − Default value. Browser calculates the left position. inherit − Specifies the same value as computed from its parent element. Applies To All positioned elements. Syntax inset = <”top”>{1,4} /* <length> values */ inset: 5px; /* value applied to all edges */ inset: 5px 10px; /* top/bottom left/right */ inset: 3px 5px 8px; /* top left/right bottom */ inset: 3.4em 5em 4em 4em; /* top right bottom left */ /* <percentage>s of the width (left/right) or height (top/bottom) of the containing block */ inset: 15% 10% 10% 10%; /* Keyword value */ inset: auto; CSS inset – Four Length Values The following example demonstrates the use of inset property with four length values passed to it, which determines the top, right, bottom and left offset values. <html> <head> <style> div { background-color: green; width: 180px; height: 120px; position: relative; } .inset-ex { writing-mode: sideways-rl; position: absolute; inset: 25px 45px 35px 15px; background-color: greenyellow; } </style> </head> <body> <div> <span class=”inset-ex”>Inset – 4 values</span> </div> </body> </html> CSS inset – Three Length Values The following example demonstrates the use of inset property with three length values passed to it, which determines the top, right, bottom and left offset values. <html> <head> <style> div { background-color: green; width: 180px; height: 120px; position: relative; } .inset-ex { writing-mode: sideways-rl; position: absolute; inset: 25px 35px 15px; background-color: greenyellow; } </style> </head> <body> <div> <span class=”inset-ex”>Inset – 3 values</span> </div> </body> </html> CSS inset – Two Length Values The following example demonstrates the use of inset property with two length values passed to it, which determines the top, right, bottom and left offset values. <html> <head> <style> div { background-color: green; width: 180px; height: 120px; position: relative; } .inset-ex { writing-mode: sideways-rl; position: absolute; inset: 25px 35px; background-color: greenyellow; } </style> </head> <body> <div> <span class=”inset-ex”>Inset – 2 values</span> </div> </body> </html> CSS inset – One Length Value The following example demonstrates the use of inset property with just one length value passed to it, which determines the top, right, bottom and left offset values. <html> <head> <style> div { background-color: green; width: 180px; height: 120px; position: relative; } .inset-ex { writing-mode: sideways-rl; position: absolute; inset: 35px; background-color: greenyellow; } </style> </head> <body> <div> <span class=”inset-ex”>Inset – 1 value</span> </div> </body> </html> CSS inset – Percentage Value The following example demonstrates the use of inset property with two percentage values passed to it, which determines the top, right, bottom and left offset values. <html> <head> <style> div { background-color: green; width: 180px; height: 120px; position: relative; } .inset-ex { writing-mode: sideways-rl; position: absolute; inset: 25% 35%; background-color: greenyellow; } </style> </head> <body> <div> <span class=”inset-ex”>Inset – 2 % values</span> </div> </body> </html> CSS inset – Mixed Values The following example demonstrates the use of inset property with mixed values, i.e., one length and another as percentage values passed to it, which determines the top, right, bottom and left offset values. <html> <head> <style> div { background-color: green; width: 180px; height: 120px; position: relative; } .inset-ex { writing-mode: sideways-rl; position: absolute; inset: 0.25em 10%; background-color: greenyellow; } </style> </head> <body> <div> <span class=”inset-ex”>Inset – mixed values</span> </div> </body> </html> CSS inset – auto Value The following example demonstrates the use of inset property with auto value passed to it, which determines the top, right, bottom and left offset values. <html> <head> <style> div { background-color: green; width: 180px; height: 120px; position: relative; } .inset-ex { writing-mode: vertical-lr; position: absolute; inset: auto; background-color: greenyellow; } </style> </head> <body> <div> <span class=”inset-ex”>Inset – auto</span> </div> </body> </html> CSS inset – Related Properties The following table lists all the related properties of CSS inset: Property Description bottom Sets the vertical position of a positioned element at the bottom. left Sets the horizontal position of a positioned element on the left side. right Sets the horizontal position of a positioned element on the right side. top Sets the vertical position of a positioned element at the top. margin Shorthand for setting the margin of an element. inset-block Specifies the logical block start and end offsets of an element. inset-inline Specifies the logical block start and end offsets of an element in the inline direction. Print Page Previous Next Advertisements ”;

CSS – Max Inline Size

CSS – max-inline-size Property ”; Previous Next CSS max-inline-size property specifies the maximum horizontal or vertical size of an element”s block, determined by its writing mode and equivalent to either max-height and max-width based on the writing mode value. The max-inline-size property sets the maximum width for horizontal writing modes and the maximum height for vertical writing modes, respectively. A companion property, max-block-size defines the other dimension. Possible Values The max-inline-size property accepts the same values as max-height and max-width. Applies To Same as width and height. Syntax <length> Values max-inline-size: 300px; max-inline-size: 25em; <percentage> Values max-inline-size: 40%; Keyword Values max-inline-size: none; max-inline-size: max-content; max-inline-size: min-content; max-inline-size: fit-content; max-inline-size: fit-content(20em); CSS max-inline-size – <length> Value The following example demonstrates the max-inline-size: 300px property sets the maximum width of the element to the 300px − <html> <head> <style> div { background-color: greenyellow; border: 3px solid red; max-inline-size: 300px; } </style> </head> <body> <div> <h2>Tutorialspoint</h2> <h4>CSS max-inline-size: 300px</h4> </div> </body> </html> CSS max-inline-size – <percentage> Value The following example demonstrates the max-inline-size: 80% property sets the maximum width of the element to the 80% − <html> <head> <style> div { background-color: greenyellow; border: 3px solid red; max-inline-size: 80%; } </style> </head> <body> <div> <h2>Tutorialspoint</h2> <h4>CSS max-inline-size: 80%</h4> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p> </div> </body> </html> CSS max-inline-size – <max-content> Value The following example demonstrates the max-inline-size: max-content property allowed the width of the div element to expand horizontally to fit the content − <html> <head> <style> div { background-color: greenyellow; border: 3px solid red; max-inline-size: max-content; } </style> </head> <body> <div> <h2>Tutorialspoint</h2> <h4>CSS max-inline-size: max-content</h4> </div> </body> </html> CSS max-inline-size – With Vertical Text The following example demonstrates the max-inline-size property with writing-modes to display text in vertical direction − <html> <head> <style> div { background-color: greenyellow; border: 2px solid blue; margin: 10px; padding: 5px; block-size: 100%; max-inline-size: 100px; writing-mode: vertical-rl; } </style> </head> <body> <div > <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p> </div> </body> </html> Print Page Previous Next Advertisements ”;

CSS – Positioning

CSS – Positioning ”; Previous Next CSS Positioning helps to manipulate position of any element in a web page. In this tutorial we will learn position property and values associated with it. Table of Contents What is CSS Position? Static Positioned Element Relative Positioned Elements Absolutely Positioned Elements Position Fixed Element Sticky Positioned Element Positioning Text in an Image Position Related Properties   What is CSS Position? In CSS position property is used to create floating elements, floating sidebar, and other interactive features by adjusting position of elements in webpage. Along with position property, other properties like top, bottom, right, and left are used to control its exact position on the page. They specify the offsets of an element from its edges. We will see examples for those in this tutorial. Syntax Following are possible values for css position. position: static | relative | absolute | fixed | sticky; Static Positioned Element When you use the position: static property, the element will be positioned normally in the document flow. The left, right, top, bottom, and z-index properties will not affect the element. This is the default value for position property. Example In this example we defined two static positioned div elements and one relative positioned element. See the difference. <!DOCTYPE html> <html lang=”en”> <head> <style> .container { padding: 20px; border: 1px solid #ccc; } .static-element { position: static; background-color: lightblue; padding: 10px; margin: 10px 0; } .non-static-element { position: relative; top: 20px; background-color: lightgreen; padding: 10px; } </style> </head> <body> <div class=”container”> <div class=”static-element”> This is a static element (default position). </div> <div class=”non-static-element”> This element is not static and is moved 20px down. </div> <div class=”static-element”> This is another static element (default position). </div> </div> </body> </html> Relative Positioned Elements CSS position: relative property positions the elements relative to their original position in the page. You can use the left, right, top, and bottom properties to move the element around, but it will still take up space in the document flow. Example In this example we defined one static positioned div element and one relative positioned element. See the difference. <!DOCTYPE html> <html lang=”en”> <head> <style> *{ padding: 15px; } .container { border: 1px solid #ccc; } .static-element { position: static; background-color: lightblue; } .relative-element { position: relative; top: 20px; left: 30px; background-color: lightgreen; } .normal-flow { background-color: lightcoral; margin: 10px 0; } </style> </head> <body> <div class=”container”> <div class=”static-element”> This is a static element (default position). </div> <div class=”relative-element”> This element is relatively positioned 20px down and 30px right. </div> <div class=”normal-flow”> This element is in the normal document flow, after the relative element. </div> </div> </body> </html> Absolutely Positioned Elements An element with position: absolute is taken out of the document flow and positioned relative to its nearest positioned ancestor (if any). If there is no positioned ancestor, then the element is positioned relative to the viewport. You can use top, right, bottom, and left properties to specify the position of the element relative to its containing block. Example This example show use of position absolute <!DOCTYPE html> <html lang=”en”> <head> <style> *{ padding: 15px; } .container { /* This makes container positioned ancestor */ position: relative; width: 70%; height: 200px; border: 1px solid #ccc; } .static-element { position: static; background-color: lightblue; padding: 10px; margin: 10px 0; } .absolute-element { position: absolute; /* 50px from top of nearest positioned ancestor */ top: 50px; /* 30px from left of nearest positioned ancestor */ left: 30px; background-color: lightgreen; padding: 10px; } </style> </head> <body> <div class=”container”> <div class=”static-element”> This is a static element (default position). </div> <div class=”absolute-element”> This element is absolutely positioned 30px from top and 50px from left. </div> </div> </body> </html> Position Fixed Element In CSS position: fixed property is used to make element stay in the same place on the screen even when the user scrolls. You can then use the left, right, top, and bottom properties to position the element where you want it. Example In this example you can see that paragraph element remain there when you scroll down. <html> <head> <style> div { width: 100%; height: 500px; background-color: lightgrey; overflow: auto; padding: 15px; } .fixed-position { position: fixed; top: 50%; left: 20%; padding: 5px; background-color: white; } </style> </head> <body> <div> <p>You can Scroll down…</p> <p class=”fixed-position”> Tutorialspoint CSS Position Fixed </p> <p> White screen will remain at 50% height from top </p> </div> </body> </html> Sticky Positioned Element In CSS position: sticky property is used to make any element stay at the top of container even when the user scrolls. You can then use the left, right, top, and bottom properties to position the element where you want it. The position: sticky property is a combination of the position: relative and position: fixed properties Example In this example you can see that when you scroll, fixed move to top <html> <head> <style> div { width: 100%; height: 500px; background-color: lightgrey; overflow: auto; padding: 15px; } .sticky-position { position: sticky; top: 50%; left: 20%; padding: 5px; background-color: white; } </style> </head> <body> <div> <p>You can Scroll down…</p> <p class=”sticky-position”> TutorialsPoint CSS Position Fixed </p> <p> White screen will stick at top of screen when you scroll down. </p> </div> </body> </html> Positioning Text in an Image In following example, you can use the position: absolute property to position text in different directions inside an image. The text elements are positioned at the top left, top right,

CSS – Accent Color

CSS – accent-color Property ”; Previous Next CSS accent-color property determines the accent color that can be applied to user-interface controls such as radio button, checkboxes, buttons etc. This property gives the flexibility to assign color of user”s choice to the user-interface control. Syntax accent-color: auto | color | initial | inherit; Value Description auto The browser selects the accent color. Default value. color It specifies the color to be used. Different formats (rgb, hex, color-name, etc) can be used. initial This sets the property to its initial value inherit This inherits the property from the parent element Examples of CSS Accent Color Property Below examples will explain the accent-color property with different values. Setting Default Color To allow the browser to give the color to the user-interface controls, the auto value can be used. This is shown in the example below. Example <!DOCTYPE html> <html> <head> <style> input { accent-color: auto; } </style> </head> <body> <h2>CSS accent-color property</h2> <div> <input type=”checkbox” id=”check” checked> <label for=”check”>accent-color: auto</label> </div> <div> <input type=”radio” id=”clicked” checked> <label for=”clicked”>accent-color:auto</label> </div> <div> <input type=”range” id=”pull”> <label for=”pull”>accent-color:auto</label> </div> </body> </html> Customizing Color To apply color of our choice to the user-interface controls, we can specify the color in different formats. This is shown in the example below. Three different formats have been used – color name, color rgb value and color hexadecimal value. Example <!DOCTYPE html> <html> <head> <style> input[type=radio] { accent-color: #ffa500; } input[type=range] { accent-color: rgb(55, 255, 0); } progress { accent-color: red; } </style> </head> <body> <h2>CSS accent-color property</h2> <h3>accent-color for radio buttons</h3> <input type=”radio” id=”radio1″ name=”gender” checked> <label for=”radio1″>Male</label></br> <input type=”radio” id=”radio2″ name=”gender”> <label for=”radio2″>Female</label> <h3>accent-color for a range</h3> <label for=”ran”>Range</label></br> <input type=”range” id=”ran” name=”range_val” min=”0″ max=”5″> <h3>accent-color for a progress</h3> <label for=”prog”>Progress</label></br> <progress id=”prog” name=”prog_val” value=”60″ max=”100″>60%</progress> </body> </html> Supported Browsers Element accent-color 93.0 93.0 92.0 15.4 79.0 css_properties_reference.htm Print Page Previous Next Advertisements ”;

CSS – Loaders

CSS – Loaders ”; Previous Next CSS loaders are animation effects that are used to indicate the loading process of a webpage. They are implemented using CSS and can be applied to various elements on a webpage, such as a spinner or a loading progress. CSS loaders are commonly used to improve user experience by visually indicating that content is being loaded or processed. Sample of CSS Loaders Here you can see what is a CSS loader, you may have seen these kind of loading animation on different websites.   Table of Contents How to Create a CSS Loader? Basic CSS Loaders Example Create Pulsing Dots Loader Different Types of Spinning Loaders CSS Loaders Using Gradient   How to Create a CSS Loader? To create a loader in CSS, follow the below mentioned steps steps. Create the HTML Structure: Define a outer div container element to hold loader content and a inner div container for loader. Style the Loader Container: Set up the width and height for loader container. Use flex layout to center loader elements properly inside the container. Style the Loader Element: Set up height and width for loader element also. Then set up border-top property as per width and color of loader you want. Also use border-radius value as 50% to ensure a circular loader. Add Animation to the Loader: Use CSS animation to create the loading effect. With this you can add rotation effect, scaling, or any other transformations. Define Keyframes for Animation: Specify the @keyframes rules for your animation, detailing how the loader should move or change over time. You may use various color combinations, shape, patterns and animation tricks for the loader. Play around with CSS properties to create your loader. You need to add the -webkit- prefix in your code for the browsers that do not support the animation and transform properties. Basic CSS Loaders Example Following example demonstrates creating a loader using CSS as discussed in the previous section: Example <!DOCTYPE html> <html> <head> <style> .container { display: flex; justify-content: space-around; align-items: center; height: 150px; background-color: #e0f7e9; margin: 0; } .loader { border: 8px solid #e0f7e9; border-top: 8px solid #34a853; border-radius: 50%; width: 60px; height: 60px; animation: innerFrame-spin 2s ease infinite; } @keyframes innerFrame-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } </style> </head> <body> <div class=”container”> <div class=”loader”> </div> </div> </body> </html> Create Pulsing Dots Loader The pulsing dots loader is commonly used in windows operating system while booting the system. We made this using six div elements inside loader each set with different animation delay using pseudo-class :nth-child. Example <!DOCTYPE html> <html> <head> <style> .container { display: flex; justify-content: space-around; align-items: center; height: 150px; background-color: #e0f7e9; margin: 0; } .PulsingDotsLoader { display: flex; justify-content: space-around; align-items: center; width: 60px; height: 60px; } .PulsingDotsLoader div { width: 12px; height: 12px; background-color: #34a853; border-radius: 50%; animation: PulsingDotsLoader-animation 1.2s ease infinite; } .PulsingDotsLoader div:nth-child(1) { animation-delay: -0.6s; } .PulsingDotsLoader div:nth-child(2) { animation-delay: -0.5s; } .PulsingDotsLoader div:nth-child(3) { animation-delay: -0.4s; } .PulsingDotsLoader div:nth-child(4) { animation-delay: -0.3s; } .PulsingDotsLoader div:nth-child(5) { animation-delay: -0.2s; } .PulsingDotsLoader div:nth-child(6) { animation-delay: -0.1s; } @keyframes PulsingDotsLoader-animation { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(0.5); opacity: 0.3; } } </style> </head> <body> <div class=”container”> <div class=”PulsingDotsLoader”> <div> </div> <div> </div> <div> </div> <div> </div> <div> </div> <div> </div> </div> </div> </body> </html> Different Types of Spinning Loaders This example shows loaders with multiple spinners. First loader have two spinners, because we defined properties border-top and border-bottom. For second loader we defined border-right along with previously defined top and bottom values, this make three spinner loader. And for third loader we defined four different values for border property, which makes a four spinner loader. Example <!DOCTYPE html> <html> <head> <style> body { display: flex; justify-content: space-around; align-items: center; height: 200px; background-color: #f0f0f0; } .loader { border: 16px solid #f3f3f3; /* Light grey */ border-top: 16px solid blue; border-bottom: 16px solid blue; border-radius: 50%; width: 70px; height: 70px; animation: spin 2s linear infinite; } .second{ border-right: 16px solid blue; } .third{ border-top: 16px solid #ADD8E6; /* Light Blue */ border-right: 16px solid #87CEEB; /* Sky Blue */ border-bottom: 16px solid #1E90FF; /* Dodger Blue */ border-left: 16px solid #4169E1; /* Royal Blue */ } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } </style> </head> <body> <div class=”loader”> </div> <div class=”loader second”> </div> <div class=”loader third”> </div> </body> </html> CSS Loaders Using Gradient CSS gradients can be used to design custom colors for loader elements by creating a smooth transition between two or more colors. Example <html> <head> <style> .loader-test { width: 50px; height: 50px; padding: 10px; aspect-ratio: 1; border-radius: 50%; margin: 20px; background: linear-gradient(10deg,#ccc,red); mask: conic-gradient(#0000,#000), linear-gradient(#000 0 0) content-box; -webkit-mask-composite: source-out; mask-composite: subtract; animation: load 1s linear infinite; } @keyframes load { to{ transform: rotate(1turn) } } </style> </head> <body> <div class=”loader-test”> </div> </body> </html> Print Page Previous Next Advertisements ”;