Google Chrome and nth-last-child

匆匆过客 提交于 2019-12-25 08:53:10

问题


The following CSS works in Firefox, IE9, and the Gnome "Web" browser.

li.col:nth-child(3n+1):nth-last-child(2),
li.col:nth-child(3n+1):nth-last-child(2) + li {width: 47.5%;}

The first line should select the last row's first child and set it to 47.5%. Firefox and Chrome both do this. The second line should select the same element but then move forward one element to the last child in the grid. In Firefox, IE9, and Web it does this but in Google Chrome does not.

Interestingly if you "inspect element" in Google Chrome it causes the second to last list element to revert back to its default width (30% as set by the .col class).

Here's a CodePen I set up for you to easily test: http://codepen.io/anon/pen/dzbci

Any help would be appreciated.


回答1:


Use

 li.col:nth-child(3n+1):nth-last-of-type(2) + li {width: 47.5%;}

http://codepen.io/anon/pen/daqej



来源:https://stackoverflow.com/questions/20436485/google-chrome-and-nth-last-child

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!