简体   繁体   English

固定的CSS标头位置消除了间距

[英]CSS Header Position Fixed Removes Spacing

I'll start by saying, I'm not great with CSS, so this may be simple. 首先,我对CSS不太满意,所以这可能很简单。 I have a table with a header which I'd like to be fixed when scrolling. 我有一个带有标题的表,在滚动时希望将其固定。 When I add position:fixed to the CSS, it is fixed when scrolling, but loses it's spacing format. 当我将position:fixed添加到CSS时,它在滚动时已修复,但丢失了其间距格式。

Before 'position:fixed' : 在'position:fixed'之前: 在此处输入图片说明

This is after 'position:fixed': 这是在“ position:fixed”之后: 在此处输入图片说明

 .consumer-service-table-header-style { background-color: #d3d3d3; width: 100%; position: fixed; } 
 <thead class="consumer-service-table-header-style"> <tr> <td align="left"> <label style="font-weight: bold;">Pull Date</label> </td> <td align="left"> <label style="font-weight: bold;">Rate</label> </td> <td align="left"> <label style="font-weight: bold;">Service SubCat</label> </td> <td align="left"> <label style="font-weight: bold;">ClientServiceIdMin</label> </td> <td align="left"> <label style="font-weight: bold;">ClientServiceIdMax</label> </td> <td align="left"> <label style="font-weight: bold;">Provider Name</label></td> <td align="left"> <label style="font-weight: bold;">RatePullId</label> </td> <td align="left"> <label style="font-weight: bold;">DDS #</label> </td> </tr> </thead> 

adding display: table; 添加display: table; to your class should keep it all nicely spaced! 到您的班级应该将它们保持良好的间隔!

As far as I understand you're having a div around your table with a specified width. 据我了解,您的桌子周围有一个指定宽度的div When you change position: fixed; 当您改变position: fixed; to position fixed *important; position fixed *important; and add display:table; 添加display:table; to the class .consumer-service-table-header-style , you should get the desired result. 到类.consumer-service-table-header-style ,您应该得到所需的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM