📜  如何制作带有粘性表头的Bootstrap表?

📅  最后修改于: 2021-10-31 05:34:39             🧑  作者: Mango

可用于正确对齐/记录数据的表格,但有时会发生表格中的数据太长,因此为了正确读取数据,在遍历表格时应始终提供与各个列相关的标题。在这种情况下,需要使用粘性表格头来使表格更具信息性和准确性,这可以使用 CSS 属性来实现,即头行元素的位置和顶部

句法:

  • 在 CSS 文件中:
  • 在 HTML 文件中:

以下示例说明了该方法:
示例 1:顶部的表格,有很长的列列表和固定的标题。



  

    
    
    
    Document
    
    
    
    
    

  

    
        

GeeksforGeeks

        Sticky header in table                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
CourseStart DateFeesType
CAT1st AugFreeOnline
GATE5th JulyFreeOnline
DSA1st July2499Online
Java Backend28th March10999Offline
SDE1st Sept299Online
SUDO Placement20th SeptFreeOnline
                          

输出:

示例 2带有文本的标题,后跟带有粘性标题的表格。



  

    
    
    
    Document
    
    
    
    
    

  

    
        
            
                
                
                
                
            
        
        
            
                
                
                
                
            
            
                
                
                
                
            
            
                
                
                
                
            
            
                
                
                
                
            
            
                
                
                
                
            
            
                
                
                
                
            
        
    
CourseStart DateFeesType
CAT1st AugFreeOnline
GATE5th JulyFreeOnline
DSA1st July2499Online
Java Backend28th March10999Offline
SDE1st Sept299Online
SUDO Placement20th SeptFreeOnline
                                 

输出:

CSS 是网页的基础,用于通过样式化网站和 Web 应用程序进行网页开发。您可以按照此 CSS 教程和 CSS 示例从头开始学习 CSS。