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.

Centre Align an inline-block

Featured Replies

Is there any way to align an inline-block to the center? Usually i use margin-left and margin right set to auto with display type block, but i had to use an inline-block so it would shrink to fit the content in it. However the properties to align it aren't working!

 

Thanks

but i had to use an inline-block so it would shrink to fit the content in it.

 

Perhaps this is why margin:auto isn't working - because it has an elastic width?

Have you tried displaying it within a block container that is set to text-align:center; ?

  • Author

Perhaps this is why margin:auto isn't working - because it has an elastic width?

Have you tried displaying it within a block container that is set to text-align:center; ?

 

Yes it does have fluid width.

 

I cant set it to display:block because then it will take up all the space, i want it to shrink to fit.

 

Is there no way to make it shrink to fit and also align to the centre?

Yes it does have fluid width.

 

I cant set it to display:block because then it will take up all the space, i want it to shrink to fit.

 

Is there no way to make it shrink to fit and also align to the centre?

 

No I meant display it as an inline-block, but display it WITHIN a container that's a block level container that has width:100% or whatever.

  • Author

No I meant display it as an inline-block, but display it WITHIN a container that's a block level container that has width:100% or whatever.

 

Doesnt the body tag count for that already? Or do i have to make a different div?

 

Edit: I tried created a container div but it still didnt work...

 

Edit Edit: I dumped it here http://www.themagicfinger.com/test1/login.aspx

Edited by TheGateKeeper

You need to put text-align:center; on your body tag in the css ;)

  • Author

You need to put text-align:center; on your body tag in the css ;)

 

Thanks bro it works...

 

one last question thou...

 

What is the best thing to do... margin-right/left:auto or use this method?

Take into account that "margin: auto auto;" horizontal centering method works only for the elements with defined width.

Guest
This topic is now closed to further replies.

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.