Solved

Questions regarding responsive site

Posted on 2016-07-28
6
85 Views
Last Modified: 2016-07-29
Hello;

I want to redesign a site for responsive and have 2 questions:

1-What is the standard size (min-max) for mobile,tablet,and desktop?please write the @media query for each one,my mean is only determine min and max for each device that cover also the
landscape
and
portrait
for mobile.

2-For a website with medium size  (php+mysql) that we want be responsive is it better that for each device we create one css file so 3 css files for website or one css file is ok that we put all 3 @media queries in that?

Thanks
0
Comment
Question by:MOSTAGHASSI
  • 3
  • 3
6 Comments
 
LVL 5

Expert Comment

by:Eric C
Comment Utility
Consider using/learning Bootstrap or Foundation. These responsive frameworks come with all of the media quieries/break points. Because they've been around for a while and are (very) popular, they seem to have adopted a 'standard'.

Here are the breakpoints that Bootstrap uses:
< 768   extra small
>= 768  small
>= 992 medium
>= 1200 large

http://getbootstrap.com/css/  shows the media queries.
And yes, you can put them all into one style sheet.

You can of course change these if you have a specific application.
0
 

Author Comment

by:MOSTAGHASSI
Comment Utility
Thanks,yes i know about Bootstrap or Foundation but i prefer to have my own design and use from some components of Bootstrap or Foundation like 'navigation'.

I want put breakpoints in  media query for 3 devices(mobile-tablet-desktop) in css file,please write the correct media query for these 3 devices.

For example for mobile (this is an example ,please writ the right and common amount in pixel :
@media ( max-width:580px){
}
0
 
LVL 5

Expert Comment

by:Eric C
Comment Utility
There are two schools of thought when it comes to responsive design
   - mobile-first (recommended)
   - desktop-first

Here are some breakpoints you can start with, using the mobile-first approach:


/*==========  Mobile First Method  ==========*/

/* Custom, example, smallest minimum breakpoint */ 
@media only screen and (min-width : 320px) {
    
}

/* Extra Small Devices, Phones */ 
@media only screen and (min-width : 480px) {
    
}

/* Small Devices, Tablets */
@media only screen and (min-width : 768px) {
    
}

/* Medium Devices, Desktops */
@media only screen and (min-width : 992px) {
    
}

/* Large Devices, Wide Screens */
@media only screen and (min-width : 1200px) {
    
}

Open in new window

0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:MOSTAGHASSI
Comment Utility
Yesterday i had a question in this regard that "must we design first for mobile or desktop?" but because nobody answer it i thought that it is a potty question and then i deleted that Q!!.

But it is important as you said,so i have some question regarding your codes:

-The order of @media{} in css file is important for  mobile-first (recommended) or desktop-first?

-Is it possible that we combine the codes so we have one @media{} for each device?
Because i think in my case it is no different between 320px and 480px(for mobile) ,but like that site be good in these ranges,so putting @media{max-width=480px}  for mobile cover all size below also? or we must set separately for 320px and 480px?
0
 
LVL 5

Accepted Solution

by:
Eric C earned 500 total points
Comment Utility
the order of the breakpoints is important, as is the designator (min-width) ... you're cascading through the style sheet.

A desktop-first approach is coded the opposite way (so to speak). In comparison to the previous code block, here it is again, but for desktop-first:

/*==========  Non-Mobile First Method  ==========*/

/* Large Devices, Wide Screens */
@media only screen and (max-width : 1200px) {

}

/* Medium Devices, Desktops */
@media only screen and (max-width : 992px) {

}

/* Small Devices, Tablets */
@media only screen and (max-width : 768px) {

}

/* Extra Small Devices, Phones */ 
@media only screen and (max-width : 480px) {

}

/* Custom */ 
@media only screen and (max-width : 320px) {
        
}

Open in new window


See the difference?

Whether or not you adapt the mobile-first approach should be dependent on the website or web application you are building. For example, if you are writing a website for internal use at an accounting firm and you know 90% of the time it will be viewed on a large screen, then you might want to design a separate mobile app (another story altogether!) or a mobile version of the site (I am not a fan of this), or just put emphasis on the desktop experience and maybe strip down the mobile experience. In this case, maybe the desktop-first approach is best.

I don't know of a way to "combine" the code into one. (The entire purpose of media queries is so that you can change your styles on the fly, according to the screen size that the device falls under. For example, on a small screen you might want to style small, in-line links as buttons, so it's easier to press with your finger). But the code block I gave you is just an example, If you don't want one of those breakpoints, just remove it. The trick is to ensure that every screen size (in pixels) will fall into ONE of the media queries.

So for example, if you don't need special styling between 320 and 767 pixels, just remove the query at 480px. There's no rule that says you MUST use different styling at specific sizes.
0
 

Author Closing Comment

by:MOSTAGHASSI
Comment Utility
Thank you very much.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Popup window in I.E. 8 35
jQuery or CSS 9 37
reset email that plugins send alerts to 1 22
CSS grid style change 2 13
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now