I recently had the task of placing two images in a band on a webpage and ensuring they were responsive to different screen sizes. Image 'a' represented a circular logo, while image 'b' was a rectangular logo. The red band served as the container for these images. Despite their slightly different widths, I needed to maintain proportional spacing between 'a' and 'b'.
To achieve this, I manually adjusted the CSS properties using media queries to accommodate various screen sizes. This involved tweaking values based on visual feedback at different breakpoints:
<html>
<head>
<title>Welcome</title>
<meta name="description" content="T">
<meta name="keywords" content="">
<meta name="author" content="">
<meta http-equiv="cleartype" content="on">
<!-- Responsive and mobile friendly stuff -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0">
<style type="text/css">
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
html,body {
color:#ffffff;
margin:0px;
padding:0px;
background: url('images/bg-1366.jpg') no-repeat center center fixed;
-webkit-background-size: cover; /* For WebKit*/
-moz-background-size: cover; /* Mozilla*/
-o-background-size: cover; /* Opera*/
background-size: cover; /* Generic*/
}
#band{
position: relative;
top:27.5%;
height:30%;
width:100%;
max-width: 100%;
border:3px solid #ffffff;
border-right-style:none;
border-left-style:none;
margin:0px;
align:center;
padding:0px;
background-color: #000000;
-webkit-background-size: cover; /* For WebKit*/
-moz-background-size: cover; /* Mozilla*/
-o-background-size: cover; /* Opera*/
background-size: cover; /* Generic*/
}
#holistic {
float:right;
max-width: 80%;
max-height: 80%;
}
#spa {
float:left;
max-width: 90%;
max-height: 90%;
}
#off {
float:left;
max-width: 1%;
max-height: 1%;
}
</style>
<link rel="stylesheet" href="css/col.css" media="all">
<link rel="stylesheet" href="css/3acols.css" media="all">
<link rel="stylesheet" href="css/media.css" media="all">
</head>
<body>
<div id="band">
<div id="wrapper">
<div class="section group">
<div class="col span_1_of_2">
<img id="holistic" src="Ehlogo.png">
</div>
<div class="col coloff span_3_of_2">
<img id="off" src="images/off.png">
</div>
<div class="col span_1_of_2">
<img id="spa" src="ESlogo.png">
</div>
</div>
</div>
</div>
</body>
</html>
@charset "utf-8";
@media only screen and (min-width : 320px) and (max-width : 480px) {
.col{
text-align:center;
}
#holistic {
float: none;
max-width: 95%;
max-height: 95%;
}
#spa {
float:right;
max-width: 95%;
max-height: 95%;
margin-top:7.5%;
margin-right:10%;
}
#band {
top:12.5%;
height:30%;
}
}
@media only screen and (min-width : 480px) and (max-width : 640px) and (max-height : 960px){
.col{
text-align:center;
width:640px;
max-width: 100%;
max-height: 100%;
}
#holistic {
float: none;
max-width: 85%;
max-height: 85%;
}
#spa {
float:right;
max-width: 85%;
max-height: 85%;
margin-top:7.5%;
margin-right:10%;
}
#band {
top:12.5%;
height:30%;
}
}
@media only screen and (max-width : 480px) and (max-height : 800px){
.col{
text-align:center;
}
#holistic {
float: none;
max-width: 95%;
max-height: 95%;
}
#spa {
float:none;
max-width: 95%;
max-height: 95%;
margin-right:10%;
}
}
@media only screen and (min-width : 640px) and (max-width : 768px) and (max-height : 1280px){
.col{
text-align:center;
width:768px;
max-width: 100%;
max-height: 100%;
}
#holistic {
float: none;
max-width: 100%;
max-height: 100%;
}
#spa {
float:none;
max-width: 100%;
max-height: 100%;
margin-top:3.5%;
margin-right:3%;
}
#band {
top:12.5%;
height:25%;
}
}
@media only screen and (min-width: 1024px) and (max-width: 1280px) {
body{
background: url('images/bg-1280.jpg') no-repeat center center fixed;
}
#holistic {
position:relative;
top:-5px;
left:10px;
max-width: 90%;
max-height: 90%;
}
.coloff {
width:75px;
}
#spa {
float:right;
margin-top:2%;
margin-right:15%;
max-width: 85%;
max-height: 85%;
}
}
@media only screen and (min-width: 1250px) and (max-width: 1366px) and (min-height: 1024px) {
body{
background: url('images/bg-1280.jpg') no-repeat center center fixed;
}
#holistic {
max-width: 90%;
max-height: 90%;
}
.coloff {
width:75px;
}
#spa {
float:right;
margin-top:2%;
margin-right:15%;
max-width: 85%;
max-height: 85%;
}
#band {
top:25%;
height:32.5%;
}
}
@media only screen and (min-width: 1280px) and (max-width: 1366px) and (max-height: 799px){
body{
background: url('images/bg-1366.jpg') no-repeat center center fixed;
}
#holistic {
position:relative;
top:-16px;
max-width: 100%;
max-height: 100%;
}
#spa {
max-width: 90%;
max-height: 90%;
}
.coloff {
width:165px;
}
#band {
top:25%;
height:32.5%;
}
}
@media only screen and (min-width: 1200px) and (max-width: 1279px) and (max-height: 799px){
body{
background: url('images/bg-1366.jpg') no-repeat center center fixed;
}
#holistic {
max-width: 95%;
max-height: 90%;
}
#spa {
float:left;
max-width: 85%;
max-height: 85%;
}
.coloff {
width:175px;
}
#band {
top:25%;
height:32.5%;
}
}
@media only screen and (min-width: 1580px) and (max-width: 1920px){
body{
background: url('images/bg-1366.jpg') no-repeat center center fixed;
}
#holistic {
max-width: 90%;
max-height: 90%;
}
#spa {
float:left;
max-width: 90%;
max-height: 90%;
}
.coloff {
width:180px;
}
#band {
top:25%;
height:28.5%;
}
}
@media only screen and (min-width: 1920px) and (max-width: 2400px){
body{
background: url('images/bg-1366.jpg') no-repeat center center fixed;
}
#holistic {
position:relative;
top:-10px;
max-width: 90%;
max-height: 90%;
}
#spa {
margin-top:0.5%;
float:left;
max-width: 86%;
max-height: 86%;
}
.coloff {
width:200px;
}
#band {
top:25%;
height:30%;
}
}
/* SECTIONS ============================================================================= */
.section {
clear: both;
padding: 0px;
margin: 0px;
}
/* GROUPING ============================================================================= */
.group:before,
.group:after {
content:"";
display:table;
}
.group:after {
clear:both;
}
.group {
zoom:1; /* For IE 6/7 (trigger hasLayout) */
}
/* GRID COLUMN SETUP ==================================================================== */
.col {
display: block;
float:left;
margin: 1% 0 1% 1.6%;
}
.col:first-child { margin-left: 0; } /* all browsers except IE6 and lower */
/* REMOVE MARGINS AS ALL GO FULL WIDTH AT 480 PIXELS */
@media only screen and (max-width: 480px) {
.col {
margin: 1% 0 1% 0%;
}
}
/* GRID OF TWO ============================================================================= */
.span_2_of_2 {
width: 100%;
}
.span_3_of_2 {
width: 10%;
}
.span_1_of_2 {
width: 40.2%;
}
/* GO FULL WIDTH AT LESS THAN 480 PIXELS */
@media only screen and (max-width: 480px) {
.span_2_of_2 {
width: 100%;
}
.span_1_of_2 {
width: 100%;
}
}
However, this process proved to be time-consuming and cumbersome. Constantly adjusting percentages, saving files, refreshing browsers, and repeating the cycle became frustrating. I'm now seeking a more efficient method that eliminates guesswork by utilizing mathematics, frameworks, or algorithmic workflows. My approach so far has been trial-and-error, but I'm eager to find a better solution when working with percentages and media queries. The current process took longer than it should have.