Bảng css màu nền cột đầu tiên

Tôi đang cố gắng làm cho cột đầu tiên có cùng màu và các hàng 1 và 2 có màu khác. Tuy nhiên, như bạn có thể thấy trong bảng ở url được cung cấp, ô của cột 1 ở hàng thứ hai không giống với màu của cột 1. CSS tôi sử dụng như dưới đây

Ngoài các hàng, bạn cũng có thể chia bảng thành các cột. Trang này xem xét các khả năng và sự không tương thích của trình duyệt không thể tránh khỏi

những cột nào

Bất kỳ bảng nào cũng được chia thành các hàng (). Ngoài ra, bạn có thể chỉ định các cột của bảng bằng thẻ

HTML




	First TD of first TR
	Second TD of first TR
	Third TD of first TR
	Fourth TD of first TR


	First TD of second TR
	Second TD of second TR
	Third TD of second TR
	Fourth TD of second TR


Thẻ đầu tiên hiện tạo một cột kéo dài các ô đầu tiên của tất cả các hàng. Thẻ thứ hai tạo một cột kéo dài ô thứ hai và thứ ba của tất cả các hàng. Ô thứ tư trong mỗi hàng không phải là một phần của bất kỳ cột nào

Những hạn chế

Thật không may, các cột trong bảng khá khó sử dụng, bởi vì nếu bạn sử dụng chúng, về cơ bản, bạn có một bảng được chia nhỏ theo hai cách. theo hàng và theo cột. Nguyên tắc chung là bất kỳ kiểu nào được xác định trên hàng sẽ ghi đè bất kỳ kiểu nào được xác định trên cột

Thứ hai, W3C chỉ định rằng chỉ có thể sử dụng một vài khai báo trên các cột. border,










	First TD of first TR
	Second TD of first TR
	Third TD of first TR
	Fourth TD of first TR


	First TD of second TR
	Second TD of second TR
	Third TD of second TR
	Fourth TD of second TR



In order to keep the cells readable I also want a white text colour. This, unfortunately, does not work. Most browsers don't obey the color: #ffffff because W3C doesn't allow a color declaration on columns.

Explorer Windows is the exception: it does allow the colour. I tend to side with Microsoft on this one; I don't understand why you can't use all normal styles on columns.

Rows and cells overrule columns

Remember the general rule: any style on a row or cell overrules a column style. Therefore the background-colors of the and are applied and the ones on the columns are ignored.

First TD of first TR
[.. etc ...]
 // second TR
0,









	First TD of first TR
	Second TD of first TR
	Third TD of first TR
	Fourth TD of first TR


	First TD of second TR
	Second TD of second TR
	Third TD of second TR
	Fourth TD of second TR



In order to keep the cells readable I also want a white text colour. This, unfortunately, does not work. Most browsers don't obey the color: #ffffff because W3C doesn't allow a color declaration on columns.

Explorer Windows is the exception: it does allow the colour. I tend to side with Microsoft on this one; I don't understand why you can't use all normal styles on columns.

Rows and cells overrule columns

Remember the general rule: any style on a row or cell overrules a column style. Therefore the background-colors of the and are applied and the ones on the columns are ignored.

First TD of first TR
[.. etc ...]
 // second TR
1 và









	First TD of first TR
	Second TD of first TR
	Third TD of first TR
	Fourth TD of first TR


	First TD of second TR
	Second TD of second TR
	Third TD of second TR
	Fourth TD of second TR



In order to keep the cells readable I also want a white text colour. This, unfortunately, does not work. Most browsers don't obey the color: #ffffff because W3C doesn't allow a color declaration on columns.

Explorer Windows is the exception: it does allow the colour. I tend to side with Microsoft on this one; I don't understand why you can't use all normal styles on columns.

Rows and cells overrule columns

Remember the general rule: any style on a row or cell overrules a column style. Therefore the background-colors of the and are applied and the ones on the columns are ignored.

First TD of first TR
[.. etc ...]
 // second TR
2. Ngoại lệ. IE7 trở xuống cho phép tất cả các khai báo

Thứ ba, có một số nhầm lẫn liệu các kiểu cột được áp dụng cho toàn bộ cột hay cho từng cá nhân chứa trong đó. Khai báo đường viền dường như được áp dụng cho toàn bộ cột, nhưng chiều rộng được áp dụng cho các ô riêng lẻ

màu nền và màu

Hãy bắt đầu với một số điều cơ bản. Tôi muốn mọi ô đầu tiên có màu nền xanh lam và mọi ô thứ hai và thứ ba có màu xanh lục










	First TD of first TR
	Second TD of first TR
	Third TD of first TR
	Fourth TD of first TR


	First TD of second TR
	Second TD of second TR
	Third TD of second TR
	Fourth TD of second TR



In order to keep the cells readable I also want a white text colour. This, unfortunately, does not work. Most browsers don't obey the color: #ffffff because W3C doesn't allow a color declaration on columns.

Explorer Windows is the exception: it does allow the colour. I tend to side with Microsoft on this one; I don't understand why you can't use all normal styles on columns.

Rows and cells overrule columns

Remember the general rule: any style on a row or cell overrules a column style. Therefore the background-colors of the and are applied and the ones on the columns are ignored.

First TD of first TR
[.. etc ...]
 // second TR

biên giới

Hãy áp dụng một border cho cột thứ hai. Đây là một tuyên bố được phép, nhưng nó không hoạt động ngay lập tức







không biên giới. Đó là hành vi đúng đắn. khai báo border trên một cột chỉ hợp lệ nếu toàn bộ bảng có










	First TD of first TR
	Second TD of first TR
	Third TD of first TR
	Fourth TD of first TR


	First TD of second TR
	Second TD of second TR
	Third TD of second TR
	Fourth TD of second TR



In order to keep the cells readable I also want a white text colour. This, unfortunately, does not work. Most browsers don't obey the color: #ffffff because W3C doesn't allow a color declaration on columns.

Explorer Windows is the exception: it does allow the colour. I tend to side with Microsoft on this one; I don't understand why you can't use all normal styles on columns.

Rows and cells overrule columns

Remember the general rule: any style on a row or cell overrules a column style. Therefore the background-colors of the and are applied and the ones on the columns are ignored.

First TD of first TR
[.. etc ...]
 // second TR
1








	First TD of first TR
	Second TD of first TR
	Third TD of first TR
	Fourth TD of first TR


	First TD of second TR
	Second TD of second TR
	Third TD of second TR
	Fourth TD of second TR



Once the border-collapse has been added, the border works. Unfortunately the browsers disagree on the exact scope of the border. The WebKit browsers do this:

Bảng css màu nền cột đầu tiên

The other browsers add a middle border:

Bảng css màu nền cột đầu tiên

width

On columns width means min-width, which is in keeping with width definitions on table elements in general. More oddly, a width declaration counts for every column that's spanned by the tag. Therefore the area of the second tag has a total width of 10em + cellspacing.


(Tôi đã xóa các văn bản bình thường để đảm bảo mọi ô đều có chiều rộng xác định thay vì bị kéo dài lên. )

Tôi sử dụng thủ thuật này trong tất cả các bảng tương thích của mình, nơi tôi xác định độ rộng TD qua các cột. Chiều rộng chính xác phụ thuộc vào col span. Tôi làm điều này để sáu cột IE có tổng số bằng với hai cột Firefox hoặc ba cột Chrome/Yandex

hiển thị. sụp đổ

Thông thường,










	First TD of first TR
	Second TD of first TR
	Third TD of first TR
	Fourth TD of first TR


	First TD of second TR
	Second TD of second TR
	Third TD of second TR
	Fourth TD of second TR



In order to keep the cells readable I also want a white text colour. This, unfortunately, does not work. Most browsers don't obey the color: #ffffff because W3C doesn't allow a color declaration on columns.

Explorer Windows is the exception: it does allow the colour. I tend to side with Microsoft on this one; I don't understand why you can't use all normal styles on columns.

Rows and cells overrule columns

Remember the general rule: any style on a row or cell overrules a column style. Therefore the background-colors of the and are applied and the ones on the columns are ignored.

First TD of first TR
[.. etc ...]
 // second TR
2 nhận ba giá trị

  1. 
    
    
    
    
    
    
    
    
    	First TD of first TR
    	Second TD of first TR
    	Third TD of first TR
    	Fourth TD of first TR
    
    
    	First TD of second TR
    	Second TD of second TR
    	Third TD of second TR
    	Fourth TD of second TR
    
    
    
    

    In order to keep the cells readable I also want a white text colour. This, unfortunately, does not work. Most browsers don't obey the color: #ffffff because W3C doesn't allow a color declaration on columns.

    Explorer Windows is the exception: it does allow the colour. I tend to side with Microsoft on this one; I don't understand why you can't use all normal styles on columns.

    Rows and cells overrule columns

    Remember the general rule: any style on a row or cell overrules a column style. Therefore the background-colors of the and are applied and the ones on the columns are ignored.

    First TD of first TR
    [.. etc ...]
     // second TR
    
    3. yếu tố có thể nhìn thấy. Đây là mặc định
  2. 
    
    
    
    
    
    
    
    
    	First TD of first TR
    	Second TD of first TR
    	Third TD of first TR
    	Fourth TD of first TR
    
    
    	First TD of second TR
    	Second TD of second TR
    	Third TD of second TR
    	Fourth TD of second TR
    
    
    
    

    In order to keep the cells readable I also want a white text colour. This, unfortunately, does not work. Most browsers don't obey the color: #ffffff because W3C doesn't allow a color declaration on columns.

    Explorer Windows is the exception: it does allow the colour. I tend to side with Microsoft on this one; I don't understand why you can't use all normal styles on columns.

    Rows and cells overrule columns

    Remember the general rule: any style on a row or cell overrules a column style. Therefore the background-colors of the and are applied and the ones on the columns are ignored.

    First TD of first TR
    [.. etc ...]
     // second TR
    
    4. phần tử bị ẩn, nhưng không gian nó chiếm vẫn trống
  3. 
    
    
    
    
    
    
    
    
    	First TD of first TR
    	Second TD of first TR
    	Third TD of first TR
    	Fourth TD of first TR
    
    
    	First TD of second TR
    	Second TD of second TR
    	Third TD of second TR
    	Fourth TD of second TR
    
    
    
    

    In order to keep the cells readable I also want a white text colour. This, unfortunately, does not work. Most browsers don't obey the color: #ffffff because W3C doesn't allow a color declaration on columns.

    Explorer Windows is the exception: it does allow the colour. I tend to side with Microsoft on this one; I don't understand why you can't use all normal styles on columns.

    Rows and cells overrule columns

    Remember the general rule: any style on a row or cell overrules a column style. Therefore the background-colors of the and are applied and the ones on the columns are ignored.

    First TD of first TR
    [.. etc ...]
     // second TR
    
    5. phần tử bị ẩn và không gian nó chiếm cũng bị xóa

Tuy nhiên, thông số kỹ thuật nêu rõ rằng trong trường hợp cột chỉ có










	First TD of first TR
	Second TD of first TR
	Third TD of first TR
	Fourth TD of first TR


	First TD of second TR
	Second TD of second TR
	Third TD of second TR
	Fourth TD of second TR



In order to keep the cells readable I also want a white text colour. This, unfortunately, does not work. Most browsers don't obey the color: #ffffff because W3C doesn't allow a color declaration on columns.

Explorer Windows is the exception: it does allow the colour. I tend to side with Microsoft on this one; I don't understand why you can't use all normal styles on columns.

Rows and cells overrule columns

Remember the general rule: any style on a row or cell overrules a column style. Therefore the background-colors of the and are applied and the ones on the columns are ignored.

First TD of first TR
[.. etc ...]
 // second TR
5 là giá trị hợp lệ

Chúng ta có thể đặt màu nền chỉ cho một ô trong bảng không?

Trong HTML, màu nền của bảng được xác định bằng Cascading Style Sheets (CSS). Cụ thể, bạn sử dụng thuộc tính màu nền để xác định màu nền. Bạn có thể áp dụng thuộc tính này cho toàn bộ bảng, một hàng hoặc một ô .

Chúng ta có thể đặt màu nền cho cột trong HTML không?

Hoàn thành khóa học HTML/CSS 2022 . HTML5 không hỗ trợ thuộc tính bgcolor của thẻ nên kiểu CSS được sử dụng để thêm màu nền. Thuộc tính bgcolor không được dùng trong HTML5. use the style attribute, with the CSS property background-color inside the body tag of the HTML document. HTML5 do not support the tag bgcolor attribute, so the CSS style is used to add background color. The bgcolor attribute deprecated in HTML5.

Làm cách nào bạn có thể chỉ định màu nền trong bảng?

Thêm hoặc thay đổi nền của bảng .
Nhấp vào một ô trong bảng
Đi tới Công cụ bảng > Thiết kế, sau đó trong nhóm Kiểu bảng, bấm vào mũi tên bên cạnh Tô bóng, rồi trỏ đến Nền bảng
Bấm vào màu bạn muốn hoặc để chọn không có màu nào, hãy bấm vào Không tô