| <!DOCTYPE html> |
| <!-- |
| | If "width" is not "auto" and "border-left-width" + "padding-left" + "width" + |
| | "padding-right" + "border-right-width" (plus any of "margin-left" or |
| | "margin-right" that are not "auto") is larger than the width of |
| | the containing block, then any "auto" values for "margin-left" or |
| | "margin-right" are treated as zero. |
| | https://www.w3.org/TR/CSS21/visudet.html#blockwidth |
| --> |
| <html> |
| <head> |
| <style> |
| .containing-block { |
| background-color: #2196f3; |
| padding: 10px 0; |
| margin-bottom: 10px; |
| width: 500px; |
| } |
| .block { |
| /* TODO: Add borders when supported. */ |
| background-color: #3f51b5; |
| display: block; |
| height: 5px; |
| padding: 0 100px; |
| } |
| .non-auto-width-and-auto-margin-left { |
| margin-left: auto; |
| width: 150px; |
| margin-right: 200px; |
| } |
| .non-auto-width-and-auto-margin-right { |
| margin-left: 200px; |
| width: 150px; |
| margin-right: auto; |
| } |
| .non-auto-width-and-auto-margin-left-and-right { |
| margin-left: auto; |
| width: 350px; |
| margin-right: auto; |
| } |
| </style> |
| </head> |
| <body> |
| <div class="containing-block"> |
| <div class="non-auto-width-and-auto-margin-left block"></div> |
| </div> |
| <div class="containing-block"> |
| <div class="non-auto-width-and-auto-margin-right block"></div> |
| </div> |
| <div class="containing-block"> |
| <div class="non-auto-width-and-auto-margin-left-and-right block"></div> |
| </div> |
| </body> |
| </html> |