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.

firefox problem - vertical align with table and vertical-align: middle

Featured Replies

Hello,

 

I come across a problem in firefox when I want vertically align div inside of a full browser width and height div. I used a table for parent and table-cell with vertical-align: middle for a child div method.

 

here is my code

 

CSS

.container {
    display:block;
	position:relative;
    min-width:100%;
    min-height:100%;
	display: table;
}
.intro-div { display: table-cell; vertical-align: middle; text-align:center; }
.fullscreen-img {
    display:block;position:absolute;z-index:-1;
    min-width:100%;
    min-height:100%;
    background:transparent url('../images/introslika.jpg') center center no-repeat;
    background-size:cover;
	-webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
  	background-position: center center;
  	background-repeat: no-repeat;
  	background-attachment: fixed;
}

HTML

 

<div class="container">

    <div class="fullscreen-img"></div>
    <div class="intro-div">
        <span class="introtxt">FRONT END / UI / UX</span><br><br>
        <span class="introtxtsmall">design & development</span><br><br><br><br>
        <span class="introtxttiny">Handcrafted web design made with love and with special care for user experience!</span><br><br><br>
<a href="#" class="btnintro btngreen flatbtn large">See my story</a>
    </div>
</div>

 

 

The point is to have a vertical and horizontal center in every browser and on every device.

I achived that on Chrome and IE to work flowless -

here is my SS

 

2md0v2q.jpg

 

3450cxk.jpg

 

 

But firefox has a bug and does not want to show my code how i want to:

 

bjitcg.jpg

 

i found a post where that bug is explained but that case is not like mine and solution does not work.

 

http://wisercoder.com/firefox-displaytable-cell-and-absolute-positioning/

 

also i tried 6 ways to vertical align and only table method is giving me what i need, and i could not google anything that could help me.

 

Does any one have any solutions to this?

 

TY in advance

Edited by pacovix

I use the same method frequently and it works fine for firefox. The only odd thing I notice in your code is you are declaring display block then display table. The display block should be moved. The only issue i get on FF is some images that are wider than the table break outside it. To fix set: table-layout:fixed for the table.

  • Author

I removed display: block and the result is the same, also i tried with table-layout :fixed,

I cant find anything odd with firebug, dont know what to change.

 

TY for your answer

  • Author

Wynn i cant believe that fixed the problem, I thought it was going to be a difficult programming solution, and I could bet i experimented with height:100% .

 

If i give container a min-height of 100% why isnt that working, min-height will start from 100% and that is what i need?

 

In any case big thanks to @@Wynn and @rbrtsmith for your help :drinks:

Edited by pacovix

set the width from min-width: 100% to width:100% too.

By default when using display table a height or width of 100% will act like a block level element with min-width 100% / min-height 100& I.e. if it's contents grow beyond it's bounds the table will still grow to accommodate - same as a block element will do if it has min-height. If you don't want this behaviour then add table-layout: fixed then it's width should keep within it's bounds.

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.