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.

Css help

Featured Replies

Ive been trying for ages to get a menu (800px) to center inside a div 100% wide but have had no luck, i usually have no problems centering in css.

 

Any suggestions?

margin: 0 auto;

 

Hard to tell without seeing code, are there any padding or margins effecting it?

  • Author

Ive tried margin: 0 auto; and many combination's of the margins and padding but it doesn't have any effect.

try wrapping in another div and put "margin:0 auto;" on that, smth like:

 

<body>
<div id="hundred_wide">
  <div id="menu_wrapper">
		<!-- your menu here, probably a list ? --> <ul>...</ul>
  </div>
</div>
</body>

how about insert tag

body {

margin: 0px auto; padding: 0px;

}

 

and tag align="center" in the div that contain ul menu like below:-

 

<div id="navmenu" align="center">

<ul>

<li>menu1</li>

<li>menu2</li>

</ul>

</div>

 

I hope it will help u ^ ^

is left: 50%; margin-left: -(half-width); out of style now?

That would only work if you always knew the final width of the element you were centering :good:

 

...and tag align="center" in the div that contain ul menu like below:-

 

<div id="navmenu" align="center">

<ul>

<li>menu1</li>

<li>menu2</li>

</ul>

</div>

This should definitely not be needed. The presentation should be kept in the CSS really, presentational markup like that is not recommended.

 

EDIT:

 

Just looked at the code at the link you have given, and it is not possible to center the navigation in that all the links are centered on the line. The best you could do is center the wrapper around the tabs, but that might end up looking even stranger. Perhaps if you link to a live example with a more detailed description of what you wish to achieve, we might give better help. :)

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.