运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,暗/亮
转到 Spaces
<!DOCTYPE html> <html> <head> <style> * { box-sizing: border-box; } .row { margin-left:-5px; margin-right:-5px; } .column { float: left; width: 50%; padding: 5px; } /* Clearfix (clear floats) */ .row::after { content: ""; clear: both; display: table; } table { border-collapse: collapse; border-spacing: 0; width: 100%; border: 1px solid #ddd; } th, td { text-align: left; padding: 16px; } tr:nth-child(even) { background-color: #f2f2f2; } /* Responsive layout - makes the two columns stack on top of each other instead of next to each other on screens that are smaller than 600 px */ @media screen and (max-width: 600px) { .column { width: 100%; } } </style> </head> <body> <h2>Responsive "Side-by-side" Tables</h2> <p>How to create side-by-side images with the CSS float property. On screens that are 600px wide or less, the images will stack on top of each other instead of next to each other.</p> <p>Resize the browser window to see the effect.</p> <div class="row"> <div class="column"> <table> <tr> <th>First Name</th> <th>Last Name</th> <th>Points</th> </tr> <tr> <td>Jill</td> <td>Smith</td> <td>50</td> </tr> <tr> <td>Eve</td> <td>Jackson</td> <td>94</td> </tr> <tr> <td>Adam</td> <td>Johnson</td> <td>67</td> </tr> </table> </div> <div class="column"> <table> <tr> <th>First Name</th> <th>Last Name</th> <th>Points</th> </tr> <tr> <td>Jill</td> <td>Smith</td> <td>50</td> </tr> <tr> <td>Eve</td> <td>Jackson</td> <td>94</td> </tr> <tr> <td>Adam</td> <td>Johnson</td> <td>67</td> </tr> </table> </div> </div> </body> </html>