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.

Vertically centring image's

Featured Replies

I'm trying to place an image in the very centre of my page but I cant seem to work out how. I've had a little look online and haven't found anything that could help me.

 

I've used "img.center { display: block; margin-left: auto; margin-right: auto; }" to centre the image horizontally, but I want it to be in the very centre of the page.

 

Can anyone shed any light?

 

Thanks

  • Author

 

When i copied the css it wasn't in the centre, is that example designed for a certain screen size?

 

I changed the "margin-top"to -100px and "margin-left" to -400px and this seems central on my screen now.

 

Would this mean it would only be central on my screen or is that necessary dues to my image dimensions being larger then the example?

 

I'm reasonably new to all of this, so sorry if these questions seem stupid.

When using position: fixed or position: absolute with top: 50% and left: 50% the margin-top should be negative half the image height and the margin-left should be negative half the image 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.