CSS tips, Web Design

Responsive Web design Tips : #1 SCALING IMAGES

0 197

Responsive Web Design is an approach in which a designer intends to provide an optimal viewing experience.
Before knowing about the concept of scaling images, let’s have a look on “Responsive Web Design”.

Nowadays people want to get access to the Internet data from any place using a wide range of portable devices- desktops, laptops, tablets etc.
And quite often we have to struggle with a site’s content when trying to fit it our browser windows. Many times, we have to zoom in or out all the time and even see some content blocks broken. All this makes web surfing a real torture!

Smart web developers and site owners have faced necessity to create designs for different resolutions and devices. They want their sites to be compatible with BlackBerry smartphones , iPhones , iPads , netbooks etc. This is a short overall concept of responsive design which is in great request today.


Scaling Images is one of the important and useful techniques for creating responsive web design. Scaling images is used to develop responsive layouts. The images are scaled according to the browser width to keep proportion in relation to the rest of the page content.


Adding the CSS max-width property to the image element, and giving the property a percentage value, is the easiest way for scaling images.

After that the browser determines the image’s width as a proportion of the width of its enclosing element, and also it automatically adjusts the image’s height to keep the correct aspect ratio of the image.

CSS has long had the ability to instruct browsers to size images by percentages, rather than absolute units or intrinsic size. The percentage is interpreted based upon the size of the containing element, rather than as a percentage of the intrinsic size of the image. Accordingly, an image 100px wide with a percentage size of 50% may be rendered many different sizes, depending upon the size of its container. And, if that element is itself sized with a percentage, it may change depending upon screen resolution and the size of the browser window.

Check out Demo


First, add a photo to the main content area of our responsive layout example, and make it scale according to browser width.

[html]<div id="content">
<div class="inner">

<h1>Responsive Layout</h1>

<img src="photo.jpg" alt="Flowers" class="photo" />

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

<p>Curabitur et leo dui, eu semper tellus. Vivamus aliquam, mi ultrices fringilla varius, augue nisl tincidunt elit, eu tincidunt ante metus ac mauris. Praesent congue blandit nunc, eu facilisis ligula faucibus sit amet. Proin eget turpis nulla. Phasellus mattis nisi a ante aliquet posuere. Vestibulum tortor quam, luctus imperdiet venenatis nec, molestie eu massa. Vivamus nec ipsum viverra augue aliquet bibendum. Morbi ac felis purus, sed vehicula mauris. Integer tempor mollis libero id hendrerit. Fusce sit amet urna quis justo varius pulvinar dapibus sed metus.

<p>Ut vel mauris eu velit fringilla lobortis. Phasellus accumsan sem in nisl luctus gravida. Vestibulum vitae scelerisque eros. Nullam id leo erat, et congue elit. Nunc volutpat justo tempor magna pretium adipiscing. Vivamus eget massa odio. Suspendisse potenti. Aliquam erat volutpat. Proin faucibus leo vel sem lobortis sed hendrerit diam suscipit. Maecenas dignissim, neque sit amet tristique pulvinar, ipsum orci porttitor odio, ac auctor nunc mauris ac nisi. Sed vitae dui et urna mollis elementum et id purus. Suspendisse bibendum quam id lacus condimentum ut pharetra orci mollis. Curabitur et consequat nisi. Suspendisse dictum luctus neque, id tincidunt justo rutrum non. Aenean fringilla quam ac magna ornare vehicula.</p>

Next, add some CSS to float the photo to the right, give it an appropriate margin and border, and set its width to 65% of the container width using the max-width property:

.photo {
float: right;
margin: .4em 0 10px 10px;
border: 10px solid rgba(0,0,0,.1);
max-width: 65%;

Finally, to make the most of the screen real estate on very small devices, let’s remove the photo’s border when the browser width dips to 480 pixels or less:

/* If the viewport width <= 480 pixels … */

@media screen and (max-width: 480px) {

body {
margin: 0;

#header .inner {
padding-top: 5px;
padding-bottom: 5px;

#header .inner, #content, #nav, #sidebar {
margin-bottom: 5px;

#nav ul {
padding: 5px 7px;

.photo {
border: none;

As the browser is resized, notice how the image scales with the width of its container so that it always remains in proportion to the content. With browser windows less than 480 pixels wide, such as mobile phone browsers, the image’s border disappears to make the best use of the available space.

For very narrow browsers on mobile devices, we remove the image border using a media query to save space.

So this is how, the scaling technique works and helps us in developing a responsive Design layout.

CSS provides a simple and easy way by which one can scale images for responsive web design.

In CSS, Min & Max Width property is simply used for creating responsive images.

  • Min & Max Width Property:

Max-width property allows us to set the max width of the element. The purpose of max-width is to prevent the element from extending the boundary.

Max-Width Container
In the example below, the container is specified to display at 800px if possible, but it should not exceed 80% of the boundary width.

.container {
width: 800px;
max-width: 80%;

Min-width is opposite to max-width. It sets the minimum width of an element. In the example form below, min-width is used on the input text field to prevent the input from getting very small when scaling down.


As web technology is now evolving fast, we should learn to adopt responsive techniques as a standard practice. We must also keep evolving in the way we think about its practice, and how we can better responsive design beginning today. The techniques like “Scaling Images” provides a responsive view and therefore must be learnt in order to ensure a great user experience for everyone as we each adopt newer technologies, gadgets and many more.

About the author / 

Leave a reply

Your email address will not be published. Required fields are marked *


Editor’s Pick

  • 200+ Ultimate Collection of Photoshop Plugins

    Photoshop is a powerful image editing software which is very useful for web designers and photographers to create desired effects in the images. But sometimes it’s difficult to perform certain tasks manually in photoshop. Once there was a belief that only designers who have mastered photoshop can create special effects on photographs or images. But…

  • Notable Tips for shooting Awesome Wildlife photographs

    You can remark it as wild-time game, which surely it is. Wild is the community for animals and not ours so it’s there to decide what they will do and what they want to. You can tell them to make some gesture that well-suit your need, or you can’t ask they to align up in…

  • 45+ Surreal Infrared photography Inspirations and Tips

    In Infrared Photography the image sensor used is highly sensitive to infrared wavelengths of light. We all know that white light is composed of several bands of colours known as spectrum and the wavelengths ranging between 750nm to about 1200 nm, falls on infrared (IR) band. The spectrum used is in this technique is termed…

  • 65+ Stunning Macro Photographs with tutorials

    We are often bothered and eluded by the large things like landscape, river views, lakes etc. but we rarely look to the smallest things in our world. Macro photography is one of those medium which makes you feel that even the smallest things have many parts to play in this globe. Macro photography means that…

  • Tips to shoot excellent Panoramic Photographs

    Recently, making out panoramic photos has become much easier as your software stitches them quite beautifully together. Photoshop is quite skillful and master in doing that; it has got a command called Photo Merge that weaves your photos once you hit it. Now, software is mere medium which we use to ease our post works,…