Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

auto expanding navigation

Featured Replies

Having difficulties deciding the best way to make the horizontal navigation bar expand to any size window.

 

 

What would be the simplest method ? Expanding_Navigation.jpg

Here is code for a complete page with a flexible width navbar. All the widths are in % adding to 100%. It will work until the window width is so narrow that the link texts won't fit, then a link will drop to a lower line (you could add min-width to solve this).

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd"> 

<html>
<head>
<title>Flexible width navbar</title>
<style type="text/css">
body { margin: 0; }
#menu { width: 100%;  margin: 0; padding: 0; }
#menu li { float: left; width: 20%; padding: 5px 4% 5px 0; 
background-color: skyblue; list-style-type: none; text-align: center; }
#menu li.first { padding-left: 4%; }
</style>
</head>

<body>

<ul id="menu">
<li class="first"><a href="link1.html">Link 1</a></li>
<li><a href="link2.html">Link 2</a></li>
<li><a href="link3.html">Link 3</a></li>
<li><a href="link4.html">Link 4</a></li>
</ul>

</body>
</html>

 

Each li tag has padding to the right only of 4% and the first li tag has a class for left padding 4% so that all spaces between li tags and at the sides are 4%.

 

An alternative is to make the navbar a fixed width to suit your links and then center the navbar in any window width:-

http://www.wickham43.net/dropdownmenus.php See item 4 where the menu is centered in a container in any window width.

  • Author

Thanks for the comprehensive reply. Will give these methods a shot.

 

Dan

 

 

 

 

Here is code for a complete page with a flexible width navbar. All the widths are in % adding to 100%. It will work until the window width is so narrow that the link texts won't fit, then a link will drop to a lower line (you could add min-width to solve this).

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd"> 

<html>
<head>
<title>Flexible width navbar</title>
<style type="text/css">
body { margin: 0; }
ul { width: 100%;  margin: 0; padding: 0; }
#menu li { float: left; width: 20%; padding: 5px 4% 5px 0; 
background-color: skyblue; list-style-type: none; text-align: center; }
#menu li.first { padding-left: 4%; }
</style>
</head>

<body>

<ul id="menu">
<li class="first"><a href="link1.html">Link 1</a></li>
<li><a href="link2.html">Link 2</a></li>
<li><a href="link3.html">Link 3</a></li>
<li><a href="link4.html">Link 4</a></li>
</ul>

</body>
</html>

 

Each li tag has padding to the right only of 4% and the first li tag has a class for left padding 4% so that all spaces between li tags and at the sides are 4%.

 

An alternative is to make the navbar a fixed width to suit your links and then center the navbar in any window width:-

http://www.wickham43.net/dropdownmenus.php See item 4 where the menu is centered in a container in any window width.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.