📜  W3.CSS 表格

📅  最后修改于: 2021-08-31 07:27:56             🧑  作者: Mango

W3.CSS 提供了一系列可用于对表格应用各种样式的类,例如更改标题外观、使行条纹化、添加或删除边框、使行可悬停等。 W3.CSS 还提供了用于使表响应。

简单表: .w3-table 类用于创建简单的 W3.CSS 表。此类名称与

标记一起使用以创建表。

句法:

Table Contents...

例子:

HTML



  
    
    
        


    
    
    
                             

           GeeksForGeeks         

    
                
        
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
Sr. No.NameCityAge
1AjayPatna20
2RahulChandigarh17
3ParushKolkata22
    


HTML



    
    GeeksForGeeks
  
    
    
        


    
    
    
                             

            GeeksForGeeks         

    
                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Sr. No.NameCityAge
1AjayPatna20
2RahulChandigarh17
3ParushKolkata22
    


HTML



    
    GeeksForGeeks
  
    
    
        


    
    
    
                             

GeeksForGeeks

    
                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Sr. No.NameCityAge
1AjayPatna20
2RahulChandigarh17
3ParushKolkata22
    


HTML



  
    
    
        

  

    
    
    
                             

            GeeksForGeeks         

    
                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Sr. No.NameCityAge
1AjayPatna20
2RahulChandigarh17
3ParushKolkata22
    


HTML



    
    GeeksForGeeks
  
    
    

  

    
    
    
                             

GeeksForGeeks

    
                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Sr. No.NameCityAge
1AjayPatna20
2RahulChandigarh17
3ParushKolkata22
    


HTML



  
    
    

  

    
    
    
                             

GeeksForGeeks

    
                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Sr. No.NameCityAge
1AjayPatna20
2RahulChandigarh17
3ParushKolkata22
    


HTML



  
    
    

  

  
    
    
    
                             

GeeksForGeeks

    
                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Sr. No.NameCityAge
1AjayPatna20
2RahulChandigarh17
3ParushKolkata22
    


输出:

条纹行: .w3-striped 类用于创建交替的深色和浅色行。使用

标记内的 table、w3-table 和 w3-striped 类的组合来创建条带化表。

句法:

Table Contents...

例子:

HTML




    
    GeeksForGeeks
  
    
    
        


    
    
    
                             

            GeeksForGeeks         

    
                
        
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
Sr. No.NameCityAge
1AjayPatna20
2RahulChandigarh17
3ParushKolkata22
    

输出:

有边框的表格: .w3-border 用于在表格中添加边框。边框仅出现在桌子周围,而不出现在桌子中。看到这个效果在 table 标签中使用 .w3-border 和 .w3-table 。

句法:

 Table Contents... 

例子:

HTML




    
    GeeksForGeeks
  
    
    
        


    
    
    
                             

GeeksForGeeks

    
                
        
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
Sr. No.NameCityAge
1AjayPatna20
2RahulChandigarh17
3ParushKolkata22
    

输出:

如果我们想要一个完全有边框的表格,我们必须在表格标签内使用 .w3-bordered 类以及 .w3-border 和 w3-table 。

例子:

HTML




  
    
    
        

  

    
    
    
                             

            GeeksForGeeks         

    
                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Sr. No.NameCityAge
1AjayPatna20
2RahulChandigarh17
3ParushKolkata22
    

输出:

Hoverable Table: .w3-hoverable 类用于在表格行上添加悬停效果(当鼠标移过时将背景颜色更改为灰色)。使用

标记内的 w3-table 和 w3-hoverable 类的组合来创建悬停行表。

句法:

Table Contents...

例子:

HTML




    
    GeeksForGeeks
  
    
    

  

    
    
    
                             

GeeksForGeeks

    
                
        
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
Sr. No.NameCityAge
1AjayPatna20
2RahulChandigarh17
3ParushKolkata22
    

输出:

居中内容表: .w3-centric 类用于将表的所有内容置于中心。在

标签中使用 w3-table 和 w3-centric 类的组合来创建这种效果。

句法:

Table Contents...

例子:

HTML




  
    
    

  

    
    
    
                             

GeeksForGeeks

    
                
        
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
Sr. No.NameCityAge
1AjayPatna20
2RahulChandigarh17
3ParushKolkata22
    

输出:

现在,如果你想在一个表上选择所有上述效果,那么你可以使用 w3-table-all 类。该类用于选择表格的所有属性,即border、striped、table、…你必须使用这个类和table标签才能看到效果。

例子:

HTML




  
    
    

  

  
    
    
    
                             

GeeksForGeeks

    
                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Sr. No.NameCityAge
1AjayPatna20
2RahulChandigarh17
3ParushKolkata22
    

输出: