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

📅  最后修改于: 2021-05-25 17:50:08             🧑  作者: Mango

可以用于正确对齐/记录数据的表,但是有时会发生表中的数据太长的情况,因此为了正确读取数据,遍历表时应始终保持对应于各列的标题。在这种情况下,需要使用粘性表头来使表更加信息准确,这可以使用CSS属性来实现,即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
                                 

输出: