Wednesday, 15 April 2015

html - force width from parent element -


I have a main menu, # navi . This is the different width of the objects should be the same width of the sub-menu, because their parents have created a JSben to display it:

Submenu for a very long time Her parents the menu should not be more detailed.

Here HTML is:

  & lt; Ul id = "navi" & gt; & Lt; Li class = "menu 1" & gt; Menu & lt; / Li & gt; & Lt; Li class = "menu 2" & gt; A long menu & lt; Ul class = "children" & gt; & Lt; Li & gt; Submenu for a very long time & lt; / Li & gt; & Lt; Li & gt; Submenu & lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Li & gt; & Lt; Li class = "menu 3" & gt; Menu item & lt; / Li & gt; & Lt; / Ul & gt;  

and CSS

  ol, ul {list-style: none; Padding: 0; } # Nova & gt; Li {Padding: 0 10px; } Li {Float: left; } Ul.children {background: gold; } #nawa li ul li {float: none;  

Problem:

  • Parents can limit the element of children without fixing the parameters with the CSS width parameters.
  • Solution

    • For the purpose of measurement, the original width is
    • to the hair width To determine.

    jQuery:

    $ ('Children's Lee'). CSS ('width', 0); $ ('Child took'). CSS ('width', $ ('. Menu2'). Width ());

    Solution Here:


No comments:

Post a Comment