![]() | 1 fancymf OP |
![]() | 2 Yanlongli 105 天前 width: max-content; text-align-last: justify; |
3 liyinhe 105 天前 A 的文本设置 width:fit-content;text-align: left;试一下,不能解决别骂 |
![]() | 4 Yanlongli 105 天前 ![]() @Yanlongli 啊理解错了,那就这样 <style> .test { width: 200px; borer: red 1px solid; display: flex; justify-content: flex-end; } .test2 { border: yellow 1px solid; width: max-content; } </style> <div class="test"> <div class="test2"> <p>啊朋友你好</p> <p>啊朋友再见吧再见</p> <p>啊朋友</p> </div> </div> |
5 zbinlin 105 天前 你要在 B 里再用一个 div 包裹住那些文本段。 |
![]() | 6 iMiata 105 天前 <style> .root-container { width: 100%; height: 400px; border: dashed 1px #ccc; text-align: center; } .half-container { width: 40%; height: 100%; display: inline-block; vertical-align: top; border: dashed 1px #f00; } #B.half-container { text-align: right; } #B .inner-container { width: fit-content; margin-left: auto; margin-right: 0; text-align: left; border: dashed 1px #00f; } </style> <div class="root-container"> <div class="half-container" id="A"></div> <div class="half-container" id="B"> <div class="inner-container"> <p>1234</p> <p>1234567890</p> <p>qwertyuiopasdfghjklzxcvbnm</p> <p>1234</p> <p>1234567890</p> </div> </div> </div> |