ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## dispaly属性 把盒子变的有弹性一共需要几步? ~~~ display:flex; ~~~ 例子: ~~~ <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style> *{ margin: 0; padding: 0; } .flex-container { display: flex; padding: 30px; background-color: purple; } .flex-item:nth-child(1) { background-color: red; } .flex-item:nth-child(2) { background-color: yellow; } </style> </head> <body> <div class="flex-container"> <div class="flex-item">A</div> <div class="flex-item">B</div> </div> <span>跟你挤一挤</span> </body> </html> ~~~ > display:inline-flex,父容器会自适应宽,不会占据一整行