CSS로 반응형 테이블을 생성하기 위한 코드는 다음과 같습니다 -
예시
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> table { border-collapse: collapse; border-spacing: 0; width: 100%; border: 1px solid #ddd; } th, td { text-align: center; padding: 16px; font-weight: bold; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-size: 18px; } th:first-child, td:first-child { text-align: left; } tr:nth-child(even) { background-color: #f2f2f2 } </style> </head> <body> <h1 style="text-align: center;">Comparison Table Example</h1> <table> <tr> <th style="width:50%">Features</th> <th>Basic</th> <th>Pro</th> </tr> <tr> <td>Free</td> <td>Yes</td> <td>No</td> </tr> <tr> <td>Customer Support</td> <td>No</td> <td>Yes</td> </tr> <tr> <td>Validity</td> <td>1 Year</td> <td>Lifetime</td> </tr> <tr> <td>Warranty</td> <td>No</td> <td>5 Years</td> </tr> </table> </body> </html>
출력
위의 코드는 다음과 같은 출력을 생성합니다 -