有2个div,sub1,sub2同一个父div希望 当2个子div的宽度之和大于 父div的时候sub1左对齐,sub2在下面一行右对齐 当2个子div宽度之和小于 父div时,sub1左对齐,sub2紧挨着sub1,如下图
` <html> <head> <title>option chain</title> <meta charset="utf-8" /> <style> * { padding: 0; margin: 0; box-sizing: border-box; } .container { width: 50vh; background-color: yellow; } .outer { max-width: max-content; display: flex; height: 200px; flex-wrap: wrap; } .left, .right { width: 100px; height: 100px; } .left { background-color: red; } .right { background-color: green; margin-left: auto; } </style> </head> <body> <div class="container"> <div class="outer"> <div class="left">left</div> <div class="right">right</div> </div> </div> </body> </html> `这样试试
`
`
这样试试