Auto margin in CSS |
Auto margin in CSS |
Shervan |
Sep 1 2023, 10:34 AM
Post
#1
|
Group: Members Posts: 2 Joined: 5-August 23 Member No.: 29,003 |
Hello,
When I set margin-left: auto;, why the image push to the right-hand side? CODE <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="css/style.css" /> </head> <body> <div class="imgClass"> <img src="images/flower.jfif"/> </div> </body> </html> CODE .imgClass { display: block; width: 200px; margin-left: auto; } |
Christian J |
Sep 2 2023, 06:15 PM
Post
#2
|
. Group: WDG Moderators Posts: 9,665 Joined: 10-August 06 Member No.: 7 |
Most of them, it seems. Just from a quick glance:
QUOTE 10.3.1 Inline, non-replaced elements The 'width' property does not apply. A computed value of 'auto' for 'margin-left' or 'margin-right' becomes a used value of '0'. 10.3.2 Inline, replaced elements A computed value of 'auto' for 'margin-left' or 'margin-right' becomes a used value of '0'. 10.3.5 Floating, non-replaced elements If 'margin-left', or 'margin-right' are computed as 'auto', their used value is '0'. 10.3.6 Floating, replaced elements If 'margin-left' or 'margin-right' are computed as 'auto', their used value is '0'. 10.3.9 'Inline-block', non-replaced elements in normal flow ... A computed value of 'auto' for 'margin-left' or 'margin-right' becomes a used value of '0'. Maybe W3C could show it in a table. |
Lo-Fi Version | Time is now: 18th May 2024 - 11:21 AM |