Making a UL wider than it's parent LI

為{幸葍}努か 提交于 2019-12-21 23:17:21

问题


I have a nav bar with dropdown menus, I would like the dropdown menus to stretch to whatever width necessary for the content inside it, but they will only go as wide as their parent element

I've read quite a bit on this, and most people suggest setting position:absolute on the dropdown menus. I've already done this and it doesn't effect it

My jsFiddle is here: http://jsfiddle.net/Rqgh6/

Does anyone know how I can get it the dropdowns to go wider than their parent element?


回答1:


You can simply add white-space:nowrap; to the <a> elements:

.menu ul a {font-size:12px;padding:0 10px;line-height:22px;text-align:left; white-space:nowrap;}

Updated jsFiddle.



来源:https://stackoverflow.com/questions/7175128/making-a-ul-wider-than-its-parent-li

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