How to use grid area to create grid layout
grid area is an important part of the grid. It helps us to create layouts easily while writing less code. Grid is used to create a 2d layout with the help of…
As there is now a standard CSS selector for previous siblings provided by CSS or css3. But we can use some tricks to select the previous siblings.
You can target or select the previous siblings by using has:() and immediate siblings’ selectors.
For example, I want to select 2nd li to color red, for this We can use the logic, to select the child which has an immediate sibling with the class name “.a3”
<style>
ul li:has(+ .a3) {
color: red;
}
</style>
<ul>
<li class="a1">a1</li>
<li class="a2">a2</li>
<li class="a3">a3</li>
<li class="a4">a4</li>
</ul>
Same as the above example we can use all other css selectors with has:() to select different previous or other sibling elements in HTML.
the following example is to select all previous siblings of the node which has class a3.
<style>
ul li:has(~ .a3) {
color: red;
}
</style>
<ul>
<li class="a1">a1</li>
<li class="a2">a2</li>
<li class="a3">a3</li>
<li class="a4">a4</li>
</ul>
Ashish Yadav is a passionate Software Engineer and technology enthusiast having 3 years of experience in web development with a deep interest in the ever-evolving world of technology.
With a background in computer science and extensive experience in software development, Ashish brings a unique perspective to his writing in the tech blogosphere & love to learn and work on technologies
grid area is an important part of the grid. It helps us to create layouts easily while writing less code. Grid is used to create a 2d layout with the help of…
Hello guys in this article we are going to see how to create moving background animation in CSS for the website. So here we are going to use @keyframe animation and translate…
System design is the process of defining systems and architectures to satisfy specific requirements. It includes the process of building architecture, components, or interfaces to satisfy the specific requirement which translates requirements…
Hello coders, in the blog we will learn how to reload a page in the React JS application Unlike the traditional web development practices where a simple page refresh could suffice, ReactJS,…
in this article, we will learn how to add an image in HTML. the syntax of adding an image in HTML is the same whether it reacts or another technology. <img/> is…