Solved

horizontal menu items to be of the same width, and fill out the entire width of the parent

Posted on 2016-08-11
7
47 Views
Last Modified: 2016-08-11
As the title really...I need my top-level horizontal menu items to be of the same width, and fill out the entire width of the parent.

My CSS at the moment just left-justifies them.

JSfiddle here
0
Comment
Question by:colinspurs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 10

Expert Comment

by:Paweł
ID: 41752017
since you know how many just use a percentage width try this on your li
http://www.w3schools.com/cssref/css3_pr_flex.asp

nav ul li {
  display:flex;
      width: 16%;
  border: solid;
      float: left;
}
0
 
LVL 3

Author Comment

by:colinspurs
ID: 41752052
Dividing 100 by the number of items is disrupted by the border width, causing overflow; if I reduce to 15%, there is a gap at the end.

Is flex necessary?  All it seems to do is left-justify the text.
0
 
LVL 57

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 41752077
Change the following style as shown
nav ul li {
  border: medium solid;
  float: left;
  width:  16.66666666%;
  box-sizing: border-box;
}

Open in new window

1
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 57

Expert Comment

by:Julian Hansen
ID: 41752080
The border-box style indicates that padding and borders should not expand the container beyond the specified width. This enables you to specify a 16.666666666% width and still have borders.
2
 
LVL 10

Expert Comment

by:Paweł
ID: 41752084
julian is right, not sure why i was thinking flex
0
 
LVL 3

Author Comment

by:colinspurs
ID: 41752203
Thanks both.  I dare say I'll have more questions as I develop this menu.
0
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 41752227
You are welcome.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question