
Originally Posted by
wkennyspain
It's a pity your reply did not offer the OP a better alternative
Responsive web pages should be coded using
em and
% instead of
px units.
CSS modifications for various screen widths are simply handled with
@media queries.
This is not rocket science, it is a basic coding skill for a webpage developer.
Here is an example...
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0">
<title>untitled document</title>
<!--<link rel="stylesheet" href="screen.css" media="screen">-->
<style media="screen">
body {
background-color:#f0f0f0;
font: 1em/1.62em verdana, arial, helvetica, sans-serif;
}
#gallery {
padding: 0.625em;
margin: 0;
border: 0.06em solid #999;
border-radius: 1em;
background-color: #fed;
overflow: hidden;
list-style-type: none;
}
#gallery li {
float: left;
width: 24%; /* 4 columns ~ 100%/4 - 1% margin value */
margin: 0.5%;
padding: 0.625em;
border: 0.06em solid #999;
border-radius: 0.75em;
box-sizing: border-box;
background-color: #fff;
box-shadow: 0.375em 0.375em 0.375em #999;
overflow: hidden;
}
#gallery img {
display: block;
width: 100%;
height: auto;
border: 0.06em solid #000;
border-radius: 0.625em;
box-sizing: border-box;
}
#gallery span {
display: block;
margin-top: 0.625em;
border: 0.0625em solid #000;
border-radius: 0.625em;
background-color: #ccc;
line-height: 2;
text-align: center;
}
@media screen and (max-width: 63.75em) {
#gallery li {
width: 32.333%; /* 3 columns ~ 100%/3 - 1% margin value */
}
}
@media screen and (max-width: 42.5em) {
#gallery li {
width: 49%; /* 2 columns ~ 100%/2 - 1% margin value */
}
}
@media screen and (max-width: 21.25em) {
#gallery li {
width: 99%; /* 1 columns ~ 100%/1 - 1% margin value */
}
}
</style>
</head>
<body>
<ul id="gallery">
<li><img src="http://lorempixel.com/g/300/486/people/7" width="300" height="486" alt=""><span>description</span></li>
<li><img src="http://lorempixel.com/g/300/486/people/6" width="300" height="486" alt=""><span>description</span></li>
<li><img src="http://lorempixel.com/g/300/486/people/5" width="300" height="486" alt=""><span>description</span></li>
<li><img src="http://lorempixel.com/g/300/486/people/9" width="300" height="486" alt=""><span>description</span></li>
<li><img src="https://via.placeholder.com/300x486" width="300" height="486" alt=""><span>description</span></li>
<li><img src="https://via.placeholder.com/300x486" width="300" height="486" alt=""><span>description</span></li>
<li><img src="https://via.placeholder.com/300x486" width="300" height="486" alt=""><span>description</span></li>
<li><img src="https://via.placeholder.com/300x486" width="300" height="486" alt=""><span>description</span></li>
<li><img src="https://via.placeholder.com/300x486" width="300" height="486" alt=""><span>description</span></li>
<li><img src="https://via.placeholder.com/300x486" width="300" height="486" alt=""><span>description</span></li>
<li><img src="https://via.placeholder.com/300x486" width="300" height="486" alt=""><span>description</span></li>
<li><img src="https://via.placeholder.com/300x486" width="300" height="486" alt=""><span>description</span></li>
</ul>
</body>
</html>
coothead
Bookmarks