Is there a way to automatically resize the header image proportionally to fit the container when the screen size is reduced using media queries?
Current CSS Code:
@media only screen and (max-width: 660px) {
table.container { width: 480px !important; }
td.headline { padding: 5px 0px 0px 30px !important}
td.headline h1 { font-size: 28px !important}
}
@media only screen and (max-width: 510px) {
table.container { width: 320px !important; }
td.headline { padding: 5px 0px 0px 30px !important; }
td.headline h1 { font-size: 22px !important; text-align: center; }
}
I have attempted different methods, such as inline styling and image replacement for smaller screens, but haven't achieved the desired result.
To get a better understanding, please refer to two screenshots of the newsletter:
Image 1 Normal Full-sized render Image 2 Render at 480px width
For those interested in diving into the code, here is the complete HTML structure:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Reha-Com-Tech Newsletter</title>
<style type="text/css">
@media only screen and (max-width: 660px) {
table.container { width: 480px !important; }
td.headline { padding: 5px 0px 0px 30px !important}
td.headline h1 { font-size: 28px !important}
}
@media only screen and (max-width: 510px) {
table.container { width: 320px !important; }
td.headline { padding: 5px 0px 0px 30px !important; }
td.headline h1 { font-size: 22px !important; text-align: center; }
}
</style>
</head>
<body bgcolor="#f5be3d">
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#f5be3d">
<tr>
<td>
<table class="container" width="1000" align="center" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" class="header" bgcolor="#ffffff" style="padding: 0px 0px 0px 0px"; border-left: 1px solid #dbc064; border-right: 1px solid #dbc064; border-top: 1px solid #dbc064;>
<a href="http://www.reha-com-tech.de/">
<img id="banner" src="images/header_large.jpg" alt="Reha-Com-Tech" style="max-width:100%; height: auto;" width="100%" height="auto"></a>
</td>
</tr>
... [trimmed for brevity] ...
</body>