John Davidson

javascript - I have two same cIass name and one style is possible to apply style for first div class?

0 comments
Message:


I have Two div like :


<div class="circle">
<div class="circle">

and I have a style:


.circle{
width="100";
height="200";
}

In this case I the css apply to first div only is this possible?



My Answer:
Yes, it is possible to apply the style to only the first div with the class "circle" using the :first-child selector in CSS. You can modify your CSS code like this:

.circle:first-child {
width: 100px;
height: 200px;
}

This will apply the specified width and height only to the first div with the class "circle".

Rate this post

5 of 5 based on 4724 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us