Bảng php thay thế màu hàng
Tôi sẽ chỉ cho bạn một ví dụ về bảng có các hàng xen kẽ cùng với một số mã hoạt động mà bạn có thể sao chép Show Nếu bạn cần nó, tôi cũng có thông tin về cách xây dựng một bảng với các cột xen kẽ Hỗ trợ trình duyệt cho Bộ chọn con thứ NTất cả các trình duyệt hiện đại đều hỗ trợ bộ chọn con thứ n nhưng nó không được hỗ trợ trong Internet Explorer 8 và các phiên bản bên dưới. Với ý nghĩ đó, tôi đã thêm một khai báo css bổ sung để trong phiên bản IE cũ hơn này, tất cả các hàng của bảng sẽ có màu nền mặc định. Điều này chỉ đề phòng trường hợp bạn bị chủ nhân hiện tại của mình nguyền rủa là hỗ trợ các trình duyệt cổ xưa Điều này cho phép bảng vẫn dễ đọc và hoạt động trực quan nhưng nó không sao chép chính xác hiệu ứng màu hàng xen kẽ có trong các trình duyệt hiện đại. Nếu điều này cực kỳ quan trọng đối với bạn thì bạn phải viết một số để đạt được hiệu quả này Ví dụ về bảng CSS với các hàng xen kẽVăn bản Văn bản Văn bản Văn bản Văn bản Văn bản Văn bản Văn bản Văn bảnMã CSS cho bảngĐể tạo bảng trên, bạn phải sử dụng tr. bộ chọn con thứ n(lẻ) để xác định tất cả các hàng lẻ trong một bảng và tr. bộ chọn thứ n (thậm chí) để xác định tất cả các hàng chẵn của bảng Bạn có thể sao chép toàn bộ mã CSS và HTML đang hoạt động cho ví dụ về bảng từ hộp bên dưới TextTextText TextTextText TextTextText TextTextText Các hàng trong bảng xen kẽ chỉ với CSSDù sao đi nữa, bây giờ khá đơn giản để tạo một bảng với các hàng màu xen kẽ chỉ bằng cách sử dụng CSS Hỗ trợ hiện đại tốt cho tất cả các trình duyệt ngoại trừ IE8 trở xuống hiện chiếm chưa đến 1% thị trường và vì vậy bạn có thể dễ dàng cung cấp cho chúng một giải pháp thay thế có thể đọc được bằng mắt Xin chào, tôi là người mới học PHP ở trường và tôi có một nhiệm vụ là tạo một bảng cửu chương mà tôi đã thực hiện với mã bên dưới. Thực sự đánh giá cao bất kỳ sự trợ giúp nào. chào mừng rất tiếc
Yêu cầu bài tập Các hàng thay thế sẽ được tô màu bằng cách sử dụng tên thuộc tính html Trong đó số là đối số đại diện cho mẫu cho các phần tử phù hợp. Nó có thể là số lẻ, số chẵn hoặc ký hiệu hàm.
element:nth-child(even)
element:nth-child(odd) ví dụ 1. Nó đặt màu để xen kẽ các hàng chẵn trong một bảng. html 56 57 58 59 60 57 62____159 60element:nth-child(even)2____23 element:nth-child(even)4 element:nth-child(even)5 element:nth-child(even)2____157____28 59element:nth-child(odd)0 element:nth-child(odd)1 element:nth-child(even)4 element:nth-child(odd)3 element:nth-child(even)4 element:nth-child(odd)5 element:nth-child(odd)0 element:nth-child(odd)7 element:nth-child(odd)8 element:nth-child(odd)0 560element:nth-child(even)4 562element:nth-child(even)4____1564 element:nth-child(odd)0 element:nth-child(odd)7 element:nth-child(odd)8 element:nth-child(odd)0 569element:nth-child(even)4 571element:nth-child(odd)0 element:nth-child(odd)7 element:nth-child(even)2____1575____28 59 575 62 59 581 57 583 59element:nth-child(even)2____157____1587 59element:nth-child(odd)0____157____1591 59element:nth-child(even)4 57____1595 596 595 59element:nth-child(even)4 57____1595 602 595 59element:nth-child(even)4 57____1595 608 595 59element:nth-child(odd)0____1575 591 59element:nth-child(odd)8 element:nth-child(odd)0____157____1591 59element:nth-child(even)4 57____1622 623 622 59element:nth-child(even)4 57____1622 629 622 59element:nth-child(even)4 57____1622element:nth-child(even)05 622 59element:nth-child(odd)0____1575 591 59element:nth-child(odd)8 element:nth-child(odd)0____157____1591 59element:nth-child(even)4 57____1622element:nth-child(even)20 622 59element:nth-child(even)4 57____1622element:nth-child(even)26 622 59element:nth-child(even)4 57____1622element:nth-child(even)32 622 59element:nth-child(odd)0____1575 591 59element:nth-child(odd)8 element:nth-child(odd)0____157____1591 59element:nth-child(even)4 57____1622element:nth-child(even)47 622 59element:nth-child(even)4 57____1622element:nth-child(even)53 622 59element:nth-child(even)4 57____1622element:nth-child(even)59 622 59element:nth-child(odd)0____1575 591 59element:nth-child(odd)8 element:nth-child(odd)0____157____1591 59element:nth-child(even)4 57____1622element:nth-child(even)74 622 59element:nth-child(even)4 57____1622element:nth-child(even)80 622 59element:nth-child(even)4 57____1622element:nth-child(even)86 622 59element:nth-child(odd)0____1575 591 59element:nth-child(odd)8 element:nth-child(odd)0____157____1591 59element:nth-child(even)4 57____1622element:nth-child(odd)01 622 59element:nth-child(even)4 57____1622element:nth-child(even)80 622 59element:nth-child(even)4 57____1622element:nth-child(even)86 622 59element:nth-child(odd)0____1575 591 59element:nth-child(even)2____1575 587 59 575 583 59 581 575 58 59đầu ra. ví dụ 2. Nó đặt màu để xen kẽ các hàng lẻ trong một bảng. html 56 57 58 59 60 57 62____159element:nth-child(even)2____157____341 59element:nth-child(odd)0____344 element:nth-child(even)2____1575____341 59 60element:nth-child(even)2____157____28 59element:nth-child(odd)0 element:nth-child(odd)1 element:nth-child(even)4 element:nth-child(odd)3 element:nth-child(even)4 element:nth-child(odd)5 element:nth-child(odd)0 element:nth-child(odd)7 element:nth-child(odd)8 element:nth-child(odd)0 560element:nth-child(even)4 562element:nth-child(even)4____1564 element:nth-child(odd)0 element:nth-child(odd)7 element:nth-child(odd)8 element:nth-child(odd)0____373 element:nth-child(even)4 571element:nth-child(odd)0 element:nth-child(odd)7 element:nth-child(even)2____1575____28 59 575 62 59 581 57 583 59element:nth-child(even)2____157____1587 59element:nth-child(odd)0____157____1591 59element:nth-child(even)4 57____1595 596 595 59element:nth-child(even)4 57____1595 602 595 59element:nth-child(even)4 57____1595 608 595 59element:nth-child(odd)0____1575 591 59element:nth-child(odd)8 element:nth-child(odd)0____157____1591 59element:nth-child(even)4 57____1622 623 622 59element:nth-child(even)4 57____1622 629 622 59element:nth-child(even)4 57____1622 5639 622 59element:nth-child(odd)0____1575 591 59element:nth-child(odd)8 element:nth-child(odd)0____157____1591 59element:nth-child(even)4 57____1622element:nth-child(even)20 622 59element:nth-child(even)4 57____1622element:nth-child(even)26 622 59element:nth-child(even)4 57____1622 5666 622 59element:nth-child(odd)0____1575 591 59element:nth-child(odd)8 element:nth-child(odd)0____157____1591 59element:nth-child(even)4 57____1622element:nth-child(even)47 622 59element:nth-child(even)4 57____1622element:nth-child(even)53 622 59element:nth-child(even)4 57____1622 5693 622 59element:nth-child(odd)0____1575 591 59element:nth-child(odd)8 element:nth-child(odd)0____157____1591 59element:nth-child(even)4 57____1622element:nth-child(even)74 622 59element:nth-child(even)4 57____1622element:nth-child(even)80 622 59element:nth-child(even)4 57____1622 5720 622 59element:nth-child(odd)0____1575 591 59element:nth-child(odd)8 element:nth-child(odd)0____157____1591 59element:nth-child(even)4 57____1622element:nth-child(odd)01 622 59element:nth-child(even)4 57____1622element:nth-child(even)80 622 59element:nth-child(even)4 57____1622 5720 622 59element:nth-child(odd)0____1575 591 59element:nth-child(even)2____1575 587 59 575 583 5760 581 57 58 59đầu ra. Trình duyệt được hỗ trợ
CSS là nền tảng của các trang web, được sử dụng để phát triển trang web bằng cách tạo kiểu trang web và ứng dụng web. Bạn có thể học CSS từ đầu bằng cách làm theo Hướng dẫn CSS và Ví dụ về CSS này |