Answer the question
In order to leave comments, you need to log in
Horizontal menu with dynamic item count in Drupal 7?
Hello!
For the second week I have been struggling with one menu, the items of which should have the same width and fill the entire width of the div container (in my case, the container id=highlighted). The number of menu items is planned to change from time to time, ie. the solution should involve changing the width of each item depending on the number of those items.
So far the solution is:
HTML: ul, unnamed list, standard Drupal
CSS template:
#highlighted {<br/>
width: 100%; /* знаю, что block-level элемент сам занимает 100% ширины и высоты родительского, но так надо :-) */ <br/>
}<br/>
.content ul.menu {<br/>
width: 875px;<br/>
margin: 0 auto;<br/>
padding: 0;<br/>
height: 1.5625em;<br/>
line-height: 1.5625em; <br/>
}<br/>
.content ul.menu li {<br/>
margin: 0;<br/>
padding: 0;<br/>
list-style: none;<br/>
float: left;<br/>
z-index: 150;<br/>
}<br/>
.content ul.menu li a {<br/>
display: block;<br/>
margin: 0;<br/>
padding: 0;<br/>
text-align: center;<br/>
font-size: 0.75em;<br/>
}<br/>
Answer the question
In order to leave comments, you need to log in
The most primitive way is a table.
More advanced - css display property and table-row, table-cell values.
Not without tambourines (individual styles for IE and JS fix for Opera - but I also had a drop-down menu screwed on, for which this JS fix was required), but in general, without JS, on one CSS, without reference to CMS and to current widths .
chikuyonok.ru/2011/04/inline-vertical-align/
See comment from Tkachenko Artem. THAT is, everything is rendered in spans with an inline / inline block as display, the last span is 100% wide and everything is aligned with justify.
There you will have to sweat for blocks, inline blocks and just inlines. In addition, if the total width of the items is greater than the width of the container, the "extra" items will move to the next line.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question