简体   繁体   English

Bootstrap 4 .sticky-top 更改为 thead

[英]Bootstrap 4 .sticky-top changes to thead

since a few days .sticky-top class does not work anymore on thead tags.因为几天后 .sticky-top 类不再适用于 thead 标签。 Last Week it just worked perfectly, now I came back and tried few things on my App and it stopped working.上周它运行得很好,现在我回来并在我的应用程序上尝试了一些东西,但它停止了工作。 Anyone got an idea why?有人知道为什么吗?

<thead class="sticky-top>
 ...
<thead>

That just worked perfectly.那只是完美地工作。 Now I cannot use it anymore.现在我不能再使用它了。 I tested it with just divs and for divs its still working, but I get an electron-dom error that I cannot spawn a div as a child of an table and i cannot spawn thead/th as child of a div.我只用 div 对其进行了测试,对于 div,它仍然可以工作,但是我收到一个电子 dom 错误,即我无法将 div 生成为表的子项,也无法将 thead/th 生成为 div 的子项。

Cheers, Puschek干杯,普舍克

For everyone that is interessted in this problem:对于对这个问题感兴趣的每个人:

Somehow you cannot sticky-top directly on thead (I just wonder why it worked 1 week ago...) so you have to stick the elements to your <thead> .不知何故,你不能直接粘在顶部(我只是想知道为什么它在 1 周前有效......)所以你必须将元素粘在你的<thead> So just give every single <th> the .sticky-top class and it works without any problems.所以只要给每个<th> .sticky-top类,它就可以毫无问题地工作。

Greetings问候

I found out that .sticky-top does not work together with .table-responsive , in case you added that.我发现.sticky-top不能与.table-responsive一起使用,以防您添加它。

Here is a compromise solution 是一个折衷的解决方案

Position an element at the top of the viewport, from edge to edge, but only after you scroll past it.将元素从边缘到边缘放置在视口的顶部,但只能在滚动经过它之后。 The .sticky-top utility uses CSS's position: sticky , which isn't fully supported in all browsers. .sticky-top实用程序使用 CSS 的position: sticky ,并非所有浏览器都完全支持它。

Microsoft Edge and IE11 will render position: sticky as position: relative . Microsoft Edge 和 IE11 将呈现position: stickyposition: relative As such, we wrap the styles in a @supports query, limiting the stickiness to only browsers that properly can render it.因此,我们将样式包装在@supports查询中,将粘性限制为仅能正确呈现它的浏览器。

<div class="sticky-top">...</div>

Learn more about it了解更多

https://getbootstrap.com/docs/4.0/utilities/position/#sticky-top https://getbootstrap.com/docs/4.0/utilities/position/#sticky-top

cheers i had the same issue欢呼我有同样的问题

check: Few stuff to corrected检查:需要纠正的东西很少

  1. make sure tag or the div that wrap your navigation is direct child of body tag (this important)!确保标签或包裹导航的 div 是 body 标签的直接子元素(这很重要)!
  2. make sure the direct parent;确保直接父母; (body) has no overflow property on it The rest is normal if you are using bootsrap 4 :-add sticky-top as usual or you can use separate javascript tooo will work !! (body) 没有溢出属性 如果您使用 bootsrap 4,其余部分是正常的:-像往常一样添加sticky-top 或者您可以使用单独的 javascript 也可以!

http://blog.cloud66.com/position-sticky-problem/ . http://blog.cloud66.com/position-sticky-problem/

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

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