Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
请你看看这里的哈佛医学院网站 http://hms.harvard.edu/
导航下拉菜单的最后一项具有子菜单未显示在其固定 div 之外。即:调整最后一项的子菜单位置,使其不会浮出。
如何在纯CSS中做到这一点?
希望你明白我在说什么。谢谢
在该特定网站上,它是通过手动定位最后一个元素来完成的。
所有其他子菜单都{ position: absolute; left: 0; }只有最后一个left: -91px。您可以将一个类附加到最后一个菜单项(或使用:last-child但在较旧的 IE-s 中不起作用)并将其移动到左侧以适合主内容框。
{ position: absolute; left: 0; }
left: -91px
:last-child