How to use text as background using CSS?

Abhishek
Updated on 15-Mar-2026 18:05:37

2K+ Views

Text as background creates interesting visual effects where text appears behind other content. This technique uses CSS positioning and z-index to layer text elements, making them appear as decorative background elements rather than primary content. Syntax /* Method 1: Absolute positioning */ .background-text { position: absolute; z-index: -1; } /* Method 2: Pseudo elements */ .element::before { content: "Background Text"; position: absolute; z-index: -1; } Method 1: Using Absolute Positioned Elements This method ... Read More

First occurrence of True number in Python

Pradeep Elance
Updated on 15-Mar-2026 18:05:25

644 Views

In this article, we will find the first occurrence of a non-zero (True) number in a given list. In Python, zero evaluates to False while non-zero numbers evaluate to True, making this a common programming task. Using enumerate() with next() The enumerate() function provides both index and value, while next() returns the first matching element ? Example numbers = [0, 0, 13, 4, 17] # Given list print("Given list:", numbers) # Using enumerate to get index of first non-zero number result = next((i for i, j in enumerate(numbers) if j), None) # ... Read More

How to use font-feature-settings property in CSS?

Abhishek
Updated on 15-Mar-2026 18:05:15

353 Views

The font-feature-settings property is used to control advanced typographic features in OpenType fonts. Advanced typographic features like swashes, small caps, and ligatures can be controlled using this CSS property. Syntax selector { font-feature-settings: "feature-tag" value; } Possible Values ValueDescription normalDefault value, uses the font's default settings "feature-tag"Four-character OpenType feature tag in quotes 1 or onEnables the specified feature 0 or offDisables the specified feature Common Feature Tags "smcp" − Small capitals "swsh" − Swashes "liga" − Common ligatures "dlig" − Discretionary ligatures "kern" − Kerning ... Read More

First Non-Empty String in list in Python

Pradeep Elance
Updated on 15-Mar-2026 18:05:06

903 Views

Given a list of strings, we need to find the first non-empty element. The challenge is that there may be one, two, or many empty strings at the beginning of the list, and we need to dynamically find the first non-empty string. Using next() The next() function moves to the next element that satisfies a condition. We can use it with a generator expression to find the first non-empty string ? Example string_list = ['', 'top', 'pot', 'hot', ' ', 'shot'] # Given list print("Given list:", string_list) # Using next() with generator expression ... Read More

How to use font-variant-settings property in CSS?

Abhishek
Updated on 15-Mar-2026 18:04:58

103 Views

The CSS font-variant-settings property provides low-level control over OpenType font features, allowing you to enable or disable specific typographic features like ligatures, small capitals, and number styles. This property gives you fine-grained control over font rendering. Syntax selector { font-variant-settings: "feature" value; } Possible Values ValueDescription normalDefault value, equivalent to no feature settings "feature" valueOpenType feature tag with on (1) or off (0) value inheritInherits from parent element initialSets to default value Example 1: Enabling Small Capitals The following example demonstrates using the "smcp" feature to ... Read More

Finding relative order of elements in list in Python

Pradeep Elance
Updated on 15-Mar-2026 18:04:48

591 Views

We are given a list whose elements are integers. We are required to find the relative order, which means finding the rank (position) each element would have if the list were sorted in ascending order. Using sorted() and index() We first sort the entire list and then find the index of each element in the sorted list ? Example numbers = [78, 14, 0, 11] # printing original list print("Given list is:") print(numbers) # using sorted() and index() result = [sorted(numbers).index(i) for i in numbers] # printing result print("List with relative ordering ... Read More

How to set the size of specific flex-item using CSS?

Abhishek
Updated on 15-Mar-2026 18:04:38

312 Views

In CSS, we can control the size of specific flex items using various flex properties. The CSS flexbox is used to create responsive layouts that adapt to different screen sizes by adjusting item dimensions and positioning. Syntax selector { flex-grow: number; flex-shrink: number; flex-basis: length | percentage | auto; flex: flex-grow flex-shrink flex-basis; } Key Flex Properties PropertyDescription flex-growControls how much a flex item should grow relative to other items flex-shrinkControls how much a flex item should ... Read More

Find whether all tuple have same length in Python

Pradeep Elance
Updated on 15-Mar-2026 18:04:32

344 Views

In this article, we will learn different methods to check if all tuples in a given list have the same length. This is useful when validating data structures or ensuring consistency in tuple collections. Using Manual Iteration with len() We can iterate through each tuple and compare its length to a reference value. If any tuple has a different length, we know they are not all the same ? schedule = [('Mon', '2 pm', 'Physics'), ('Tue', '11 am', 'Maths')] # Print the original list print("Given list of tuples:") print(schedule) # Check if all tuples ... Read More

How to set the order of flexible items using CSS?

Abhishek
Updated on 15-Mar-2026 18:04:16

267 Views

The CSS order property allows you to change the visual order of flex items without altering their position in the HTML source. This property only works on elements that are children of a flex container (an element with display: flex or display: inline-flex). NOTE − The order property only works with flex items inside a flex container. Syntax selector { order: integer; } Possible Values ValueDescription integerAny integer value (positive, negative, or zero). Default is 0. Items are arranged in ascending order of their order values. ... Read More

Find top K frequent elements from a list of tuples in Python

Pradeep Elance
Updated on 15-Mar-2026 18:04:12

326 Views

We have a list of tuples and need to find the top K elements with highest values. For example, if K is 3, we need to find the three tuples with the largest second values. Using defaultdict and sorted This approach uses defaultdict to group elements and then sorts them by value to get the top K elements. Example import collections from operator import itemgetter from itertools import chain # Input list initialization listA = [[('Mon', 126)], [('Tue', 768)], [('Wed', 512)], [('Thu', 13)], [('Fri', 341)]] # Set K K = 3 # ... Read More

Advertisements