Margin-top:auto and margin-bottom: auto not working |
Margin-top:auto and margin-bottom: auto not working |
Anjali Agarwal |
Jun 3 2020, 04:20 PM
Post
#1
|
Group: Members Posts: 3 Joined: 2-June 20 Member No.: 27,371 |
Why do margin-top:auto and margin-bottom: auto not work ?
|
CharlesEF |
Jun 3 2020, 05:28 PM
Post
#2
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
In what way? You need to provide better details or post some code.
|
Anjali Agarwal |
Jun 3 2020, 06:22 PM
Post
#3
|
Group: Members Posts: 3 Joined: 2-June 20 Member No.: 27,371 |
Following is the HTML code:
CODE <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="selectors.css"> </head> <body> <table> <tr> <td></td> <td></td> <td></td> </tr> </table> </body> </html> And following is the corresponding CSS code: CODE table{ margin-top: auto; margin-right: auto; margin-left: auto; margin-bottom: auto; } td{ width: 100px; height: 100px; border: 1px solid black; } So, the table is being horizontally aligned to the centre. However, it is not vertically aligned to the centre of the screen. |
pandy |
Jun 3 2020, 09:07 PM
Post
#4
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,730 Joined: 9-August 06 Member No.: 6 |
Auto margins only work for horizontal centering, not vertical.
|
Lo-Fi Version | Time is now: 25th April 2024 - 07:07 AM |