10/24/2015

HTML: How to do Responsive Web Design in 1 Minute

The Basics of What You'll Need for Responsive Web Design

You know HTML.
You know CSS.
You don't know Responsive design.

It's easy to understand.

Use CSS to Define Different Screen Styles

Start with a default style, then go from widest to narrowest


Responsive designs are usually based on width of the browser, or the width of the device's "screen." A cell phone has two screen widths -- the portrait view and the landscape view. A desktop browser could have any dimensions, right? So, your responsive design will react to a few approximate guesses at which dimensions a user's screen might be -- HD, laptop, tablet, cellphone.

First, you'll make a default style sheet.
  • Create a CSS3 style sheet just like you normally would.

Then, at the bottom of the CSS, you will define specific styles for different screen sizes. These styles could be either new, additional definitions, or they could override the default definitions.

So, the logic goes something like this:
  1. Default style definitions (for all screen sizes)
  2. Very wide styles (between x and y pixels)
  3. Medium width styles (between y-1 and z)
  4. Narrow width styles (anything smaller than z-1)
The code will be structured like this:
<style>
/* 1. SPECIFY DEFAULT STYLE HERE */
/* FOLLOWED BY DESCENDING WIDTHS OF 
   SCREEN SIZE STYLES, LIKE THIS: */
@media screen and (max-width: x) and (min-width: y) {
  /* 2. SPECIFY WIDE STYLES HERE */
}
@media screen and (max-width: y-1) and (min-width: z) {
  /* 3. SPECIFY MEDIUM STYLES HERE */
}
@media screen and (max-width: z-1) {
  /* 4. SPECIFY NARROW STYLES HERE */
}
</style>

-----

That's it.

Now you mix-n-match CSS styles to make elements realign themselves, disappear or become visible, change font sizes and colors, etc.

-----

This working example of code changes the color and size of the headline when the screen width changes.

See the working example.

<style>
/* DEFAULT (ALL SCREEN SIZES) */
h1 { 
color: green;
font-size: 2em; 
}
    
 /* SCREEN WIDTH BETWEEN 767 AND 600 PIXELS */
@media screen and (max-width: 767px) and (min-width: 600px) {
h1 {
 color:blue; 
 font-size: 1.75em;
}
}

 /* SCREEN WIDTH BETWEEN 599 AND 480 PIXELS */

@media screen and (max-width: 599px) and (min-width: 480px) {
h1 {
 color:orange;
 font-size: 1.5em;
}
}

 /* ANY SCREEN WIDTH BELOW 480 PIXELS */

@media screen and (max-width: 479px) {
h1 {
 color:red;
 font-size: 1.25em; 
}
}
</style>


23 comments :

  1. This information that you have given in your article, is quite useful and it's given me a piece of good knowledge on Web Design. Thanks for giving this information. Ecommerce Website Design Company USA

    ReplyDelete
  2. I am happy to find this post very useful for me, as it contains a lot of information. I always prefer to read the quality content and this thing I found in your post. Thanks for sharing it. Website Design Point Cook

    ReplyDelete
  3. You shared an impressive and informative blog here about web designing. I like your blog. Thanks for sharing. Miami web design

    ReplyDelete
  4. keep sharing your information regularly for my future reference. This content creates new hope and inspiration within me. Thanks for sharing an article like this. The information which you have provided is better than another blog. Website development company in Canada visit our website.

    ReplyDelete
  5. This content creates new hope and inspiration for everyone. keep sharing your information regularly for my future reference. Thanks for sharing an article like this responsive website design services in UK for more info visit at insignalmedia.com

    ReplyDelete
  6. You write this post very carefully I think, which is easily understandable to me. Not only this, but another post is also good. As a newbie, this info is really helpful for me. Thanks to you. As we provide Professional Web Design Services Ireland then visit our website at Developit.ie

    ReplyDelete
  7. I am continually searching for some free stuffs over the web.I ought to thank you for posting this blog because the subject is especially looked by everyone. Get the best info about Local Web Design Company in Chicago then visit our website at allevi8marketing.com

    ReplyDelete
  8. Appealing, post. I just unearthed Your weblog and needed to state that I have loved perusing your blog entries. All things considered, I will without a doubt buy in to your feed, and I trust you will compose again soon! website design vancouver wa

    ReplyDelete
  9. I got information from your article which I will be sharing with my friends who will need this information. I will suggest reading this article because it will really help those who need this information. Thanks for the information which you have shared here. web design services in UK

    ReplyDelete
  10. continue sharing your data routinely for my future reference. This substance makes new desire and inspiration inside me. Thankful for sharing this article here. Web Developer Malaysia

    ReplyDelete
  11. Thanks for sharing this article here about the Best IT Support Services. Your article is very informative and I will share it with my other friends as the information is really very useful. Keep sharing your excellent work.Best IT Support Services Auckland

    ReplyDelete
  12. Thanks for sharing the best information and suggestions, it is very nice and very useful to us. I appreciate the work that you have shared in this post. Keep sharing these types of articles here. small business phone service

    ReplyDelete
  13. Thanks for posting such informative article in this post about it services . I got some great knowledge from this post.https://www.telxcomputers.com/ Keep it up.

    ReplyDelete
  14. Thanks for sharing the best information and suggestions, it is very nice and very useful to us. I appreciate the work that you have shared in this post. Keep sharing these types of articles here. DLS Internet Services

    ReplyDelete
  15. I am very thankful to you for sharing this necessary knowledge. This information is very helpful for everyone. So please always share this kind of information. Thanks. microsoft support houston tx

    ReplyDelete
  16. This is really such an explanatory post you have shared here about web designing. I got some useful knowledge from this post.online b2b travel platform development. Thanks for sharing it.

    ReplyDelete
  17. I generally check this kind of article and I found your article which is related to my interest. Genuinely, it is good and instructive information about network solution.It Support Houston. Thanks for sharing an amazing article here.

    ReplyDelete
  18. I admire this article for the well-researched content and excellent wording. Read more info about it support company in houston. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much.

    ReplyDelete
  19. Excellent post. I really enjoy reading and also appreciate your work.Host your website in Free USA This concept is a good way to enhance knowledge. Keep sharing this kind of articles, Thank you.

    ReplyDelete
  20. I generally check this kind of article and I found your article which is related to my interest.it outsourcing Genuinely it is good and instructive information. Thankful to you for sharing an article like this.

    ReplyDelete
  21. I will share it with my other friends as the information is really very useful. web design dubai. Keep sharing your excellent work.

    ReplyDelete
  22. Interesting to read your post about the responsive web design. I can't wait to see your next post. Good luck for upcoming updates.
    website design company

    ReplyDelete
  23. Thanks for sharing tips for designing the responsive website..
    I am web designer and can understand the value of these trends for me… your tips will really help me to make effective website design…

    Law firm website design by split reef

    ReplyDelete