Showing posts with label Responsive. Show all posts
Showing posts with label Responsive. Show all posts

Tuesday, 19 July 2016

Inducing Responsiveness To Your Images Via CSS



In this modern age world, there are a lot of techniques for building responsive images. However, the techniques are not same due to variations in browser support and complexities. One can make use of the srcset attribute, but it is a complex way of implementing responsive images as it demands several images, markups and the new HTML attributes (not well supported outside modern browsers).

There are lot of people that go for HTML to WordPress conversion so as to make intuitive websites for their business on all kinds of devices irrespective of the size and its orientation. However, in this article, we will simply work on height and width of CSS, which will further make it independent from the browsers property and thus will work on all browser and CSS. However, it will require a fluid design layout for your website. The concept behind this is to use CSS to make images a percentage length unit or any relative unit for making their width re-sizeable and give auto value to the height property.

img {
width: 100%;
height: auto;
}


What's a Responsive image ?

In order to know about a responsive image, we can take an example.

Div acts as a container of an <img> element.


HTML

<div class="container">
<img src="image01.jpg" width="960" height="640" />
</div>


The container has margins on the left and right as the container has 96% width property. The max width is of 960px so that the layout do not appears too wide on a bigger screen.

The container contains a <img> element of 100% width, so that its width so as to make the width equal to its container irrespective of the viewport's size, thus this makes this responsive. Further, set the height to auto so that the image scales in proportion to the screen.


CSS

div.container {
width: 96%;
max-width: 960px;
margin: 0 auto; /* to center the container */
}
img {
width: 100%;
height: auto;
}


The <img> element is always responsive even if we assign a fixed height and width to HTML attribute as shown in the markup (i.e. width="640", height="960"). This technique is best suited for content which has a fixed set of dimension via HTML.


Putting Responsive images in columns

In order to display more images on a small screen, we try to scooch in images in a columns. We often get to see websites which display galleries in a thumbnail on a grid style.

In order to make images responsive in columns, we only need to lessen the width property of the CSS and assign a display property value to the <img > elements.

We further have a couple of layout schemes namely: A two-columns layout and three-column image layout for images.


Two- column layout for responsive images

To get a two-column responsive layout, you need to set the width property of the CSS to 48% or nearly half of the container. Though, you might be thinking why not to 50%. The reason being that images have margins so we need to keep room for them as well.


HTML

<div class="container">
<img src="image01.jpg" width="860" height="540" />
<img src="image02.jpg" width="860" height="540" />
</div>


CSS

img {
width: 48%;
display: inline-block;
}


Three-column layout for responsive images

You need to use the very same concept in order to get a three-column layout for responsive images, all you need to do is to set the width of the container to 32%.


HTML

<div class="container">
<img src="img01.jpg" width="860" height="540" />
<img src="img02.jpg" width="860" height="540" />
<img src="img03.jpg" width="860" height="540" />
</div>

CSS

.three-columns {
width: 32%;
display: inline-block;
}


Adding Conditional breakpoints

Adding conditional breakpoints for responsive images is a good practice, and thus when the images grow smaller, the columns can merge themselves.

This can be done via media queries.

In code snippet used below, we will make images display in single column in smaller device such as smartphone, two columns on slightly bigger devices on phablets or tablets and four columns on much bigger screen such as a laptop or desktop.


HTML

<div class="container">
<img src="img01.jpg" width="860" height="540" />
<img src="img02.jpg" width="860" height="540" />
<img src="img03.jpg" width="860" height="540" />
<img src="img04.jpg" width="860" height="540" />
</div>

CSS

/* For Devices of small size (e.g. smartphones) */
img {
max-width: 100%;
display: inline-block;
}
/* For Devices of medium size (e.g. tablets) */
@media (min-width: 420px) {
img {
max-width: 48%;
}
}
/* For Devices of large size (e.g. desktops) */
@media (min-width: 760px) {
img {
max-width: 24%;
}
}


Responsive images with full width

In order to get responsive images that always remain 100% of the device size, you need to just change the container's width to 100% and simply remove it's max-width property which is 960 px by default.


.container {
width: 100%;
}
img {
width: 100%;
}


These methods were no doubt simple and easy methods to cater mobile device users, but it's pitfall is that it will always deliver images of full size irrespective of the device used by the user. The smaller devices won't be able to take the advantage of high-resolution images which are served in full dimensions, and most of the devices won't be able to open the images even.

Further, if you would wish to improve the performance of your web app by serving your images after reading the conditions ( i.e. a low resolution and a smaller images displayed on small mobile devices and likewise with other devices.), you need to program with the srcset, pictures and sizes elements.

Thursday, 1 October 2015

Things to Consider When Making a Responsive WordPress Site

At present, the majority of users' own devices with an Internet connection. In fact, people today access the web using mobile devices (like tablets and Smartphones) more compared to desktop computers. With time, the need for these smart-devices is only going to increase, because of the ability they render to browse the web and perform virtually almost any task using lightweight devices that can be used on the fly.

While it's true that Smartphones make it easy for us to access the web content without having to stick to a computer desk, but one problem that you might encounter is that the text may be too small to read on small displays. One great way to make your site adjust and adapt to almost any device screen size and resolution is to create a responsive layout. Perhaps, you may choose to install and activate a WordPress responsive theme to achieve such an objective.

But, using a pre-built theme will enable you to present yourself as a unique brand. Moreover, there is no guarantee that the theme will be truly responsive. And thus, a more viable alternative is to opt for PSD to responsive WordPress conversion service. There are many great web development companies that help turn your design files to a responsive WordPress theme format.

The best thing about opting for PSD to a responsive WP theme is that it will not only help in making your site responsive, but will also help you establish a unique online identity. Of course, converting your own design into a theme will give you the benefit of offering a different online experience to users compared to your competitors. The biggest advantage of the conversion is that, you will get better control over your converted site. This means, you can easily make the changes to the design elements to make them perfectly suit your requirements.


In order to come up with a successful responsive WP site make sure to take into considerations below listed key points:

Know Your Target Audience Preferences

Designing a responsive layout for some of the major devices and platforms that your audience uses will help you provide better user experience. But, to accomplish such a need, you will first need to know the preferences (i.e. the mobile device) of your users. One excellent way to know exactly about the devices that your audience use to access your site is to install the Google Analytics tool.

Communicate Your Exact Needs to Your Service Provider


It is imperative to communicate what all you expect from your converted WP theme to your service provider. This will help them better understand your requirements and accordingly develop a solution that match up to your expectations.

Test Your Design on Real Devices

Once your service provider had finished converting your design files into a WP theme, make sure to test it on real devices to get assured that it will scale or contract depending on your users' device. This will save you from spending huge chunks of money – that you might otherwise have to spend in case you find out that your design is not truly responsive at a later stage.

Conclusion

Hope that this article will help you understand some of the key considerations that can help you in creating a winning responsive WordPress site.