I am trying to center a table (horizantly) inside div tag using <div align=“center”>. But the table always is left aligned. This happens only in firefox. Internet explorer centers the table very well. How to center the table in firefox.
Ah, vertical centering is another kettle of fish. You need to be clearer on what your circumstances are. Normally the div would just wrap around the table. The easiest way to vertically center a table in a div is to have the same padding on the top and bottom of the container div. Is that what you mean? CSS does not have much support for vertical centering, except with images, table cells and maybe a few other elements.
If that’s not what you mean, explain a bit more. If you mean vertically centering the table and div in the browser window, it’s a bit tricky.
Here is what I have. There is a table inside div tag. Within the table are two submit buttons. I wan’t to position the buttons in the center of div horizantly as well as vertically. I think that if I center the table in div, the buttons will automatically be centered. But I don’t how to center table vertically in div.
Centering the table vertically in the div does not make sense. The div will be the same height as the table. It sounds like you want to vertically center the submit buttons inside the table. You could try
The div is positioned at the bottom. “h:panelGrid” is server side component that generates the html table. “h:commandButton” is also server side component that generates html submit or reset buttons. I want to position the two buttons represented by “h:commandButton” at the center of the div horizantly and vertically.
The footer is fixed at the bottom of the page. Currently I am using “margin-top:12px;” to position the buttons at the middle of the footer vertically. This doesn’t seem to be a good technique, as the size of footer my change in future.
Hello. Are you sure that this works in Internet explorer? I have a very similar problem and your fix worked in firefox but then went and did the opposite to IE8!
Hello. Are you sure that this works in Internet explorer? I have a very similar problem and your fix worked in firefox but then went and did the opposite to IE8!
Do you have a valid doctype? If not ie8 will behave more like ie5 and loses the ability to understand all but the most basic of css In quirks mode auto centering is not understood by IE and it would need text-align:center on a parent instead.