One way to handle the layout of tables and images dynamically based on screen width is to use two media queries. When the screen width is larger than 500px, the image can be floated left of the table. On screens smaller than 500px, the image can be positioned above the table.
This code snippet assumes that there is a jpg image named "image.jpg" in the same directory as your HTML file. You will need to update the src attribute of the image tag with the actual path to your image.
@media screen and(min - width: 500 px) {
th,
td {
font - size: 16 px;
}
img {
margin - right: 25 px;
float: left;
}
}
@media screen and(max - width: 499 px) {
th,
td {
font - size: 10 px;
}
img {
display: block;
margin - bottom: 40 px;
}
}
table {
margin-bottom: 30px;
width: 100%;
border-collapse: collapse;
}
th,
td {
border: 2px solid #ccc;
padding: 6px;
text-align: left;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Table</title>
</head>
<body>
<!-- Image for screens 500px and larger -->
<img src="image.jpg"
alt="Description of your image">
<table>
<thead>
<tr>
<th>Heading1</th>
<th>Heading2</th>
</tr>
</thead>
<tbody>
<tr>
<td>TableData1</td>
<td>TableData2</td>
</tr>
</tbody>
</table>
</body>
</html>