Làm cách nào để sử dụng css với đứa con đầu tiên?

The following article provides an outline for CSS first child of class. It is defined as a selector for HTML that selects the parent’s first-child element [has Relationship between parent and sibling content] which is used in CSS. It Simply targets the first element inside another element and is a pseudo-class means it falls under structural and position- based classes. The Selectors plays a vital role in CSS as they determine the styles to elements on the HTML code. The first targets only one element whereas first-child targets more than one but with one parent. Here the should be assigned for Internet Explorer browser version.

Cú pháp của CSS con đầu tiên của lớp

Đưa ra dưới đây là cú pháp

Bắt đầu khóa học phát triển phần mềm miễn phí của bạn

Phát triển web, ngôn ngữ lập trình, kiểm thử phần mềm và những thứ khác

Gói phát triển phần mềm tất cả trong một[hơn 600 khóa học, hơn 50 dự án]

Giá
Xem khóa học

600+ Khóa học trực tuyến. hơn 50 dự án. Hơn 3000 giờ. Giấy chứng nhận có thể kiểm chứng. Truy cập Trọn đời
4. 6 [82.404 xếp hạng]

Element: first-child {
//css declarations with style properties;
}
  • yếu tố đối số. Nó là cái đầu tiên của cha mẹ
  • css. Thuộc tính tạo kiểu áp dụng cho con đầu tiên

Mã số

hi welcome to the website.

Open Home Page

Bây giờ, áp dụng Kiểu CSS cho Đoạn văn mà chúng ta phải sử dụng bộ chọn con đầu tiên

. check p: first-child
{
// CSS font style;
}

To pick a specific Dom element it is super to add a new class to do it inside a stylesheet which clears an HTML Code better. To do so Child selectors are been used which uses either descendants or child selectors. To this first child or last-child selectors are been added. Its a part of CSS2. So if there is a heading element above the

element then this no longer selects the paragraph.

CSS con đầu tiên của lớp với các ví dụ là gì

Lớp con đầu lòng này có thể được xâu chuỗi với các phần tử như. trước và. sau

Ghi chú. Nó được hỗ trợ trong hầu hết các trình duyệt như Chrome, Internet Explorer, Android

Ví dụ 1

Is with a Paragraph tag

.

Here we apply the first-child selector to the Paragraph. The first

statements will be styled and the following

tag content is not styled. Creating a mark-up code and CSS file externally.

Mã số

đứa trẻ. css

p:first-child {
color: yellow;
background-color: green;
padding: 2px;
}

đứa trẻ. html





Europe is considered to be a second smallest continent in the world and has total land of greenish sectors.

One among then is Switzerland.

This topic is all about the European Country

No selection

The above mark-up shows that inside the

tag the child elements are

and

. If suppose if we made a change to first

tag to another element the selector first-child couldn’t take any child.

đầu ra

Ví dụ #2

With the row tag .

Suppose for the following HTML the selector will apply styles to the Row tag which is the first child of the element. In our case, it is Grocery and Address which is styled by the CSS. The rest of the is not selected because it is not the first child of the element.

Mã số

đứa trẻ. css

tr:first-child {
color: red;
background-color: Powderblue;
font-family: courier;
padding: 3px;
border : 2px solid pink;
}
h2:
color : orange;
}

đứa trẻ. html






 Grocery Shop
 Address 
Big Basket Hyderabad, chennai
D-Mart Grocery Items Coimbatore
Walmart - Shopping HAll Mumbai

đầu ra

Ví dụ #3

Thuộc tính lớp

Ở đây, tên lớp được gán là 'Ngân hàng' được gọi bằng một đoạn văn

Mã số

danh sách. html





p.Bank {
background-color: yellow;
color: green;
}



BNP Paribas

Its an Biggest major Bank in France that serves retail and Depositor services.

Bank Of America

Its a U.S Bank that provides Services for all the clients with the high Size.

Bank Of China Ltd

Its an China bank which has the largest deposit in the world.

đầu ra

Ví dụ #4

Triển khai trong phần tử danh sách

Trong đoạn mã dưới đây. con đầu lòng được nhắm mục tiêu đến các mục danh sách không có thứ tự

Mã số

danh sách. html

________số 8

đầu ra

Ví dụ #5

Trong phần trình diễn bên dưới lớp giả. phần tử con đầu tiên được thực hiện với phần tử tr, th, td xác định phần tử con đầu tiên của tr là Sno, Nhân viên, chỉ định…. và cho tên phần tử td tương ứng

Mã số

người làm công. html






Sno
Employee
Designation
Service
Salary
2 Mary Queraine Senior Manager 10-12 80000
6 Catherine Jay Team Leader 5-6 50000

người làm công. css

hi welcome to the website.

Open Home Page

0

đầu ra

Ví dụ #6

Triển khai bằng JavaScript

Đoạn mã sau hiển thị kết quả khi chúng ta viết. con đầu lòng trong Java Script chỉ chọn con đầu tiên để định kiểu nội dung

Mã số

fff. js

hi welcome to the website.

Open Home Page

1

đầu ra

Sự kết luận

Do đó, trong bài viết này, chúng ta đã thấy cách sử dụng bộ chọn CSS. đứa con đầu lòng với bản demo và cú pháp gọn gàng. Với bộ chọn này, chúng tôi có thể xây dựng các trang web thành công đôi khi có thể gặp khó khăn. Và cuối cùng, nó phác thảo các nguyên tắc cơ bản và trình bày cách phần tử này được triển khai trong các phần tử HTML, điều này rất có lợi cho sự phát triển giao diện người dùng

Bài viết được đề xuất

Đây là hướng dẫn về CSS con đầu tiên của lớp. Ở đây chúng tôi thảo luận về phần giới thiệu và CSS con đầu tiên của lớp với các ví dụ là gì. Bạn cũng có thể xem các bài viết sau để tìm hiểu thêm –

Chủ Đề