Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Questions regarding responsive site

Posted on 2016-07-28
6
Medium Priority
?
101 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
ID: 41734571
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
ID: 41734751
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
ID: 41734822
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:MOSTAGHASSI
ID: 41734921
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 2000 total points
ID: 41734966
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
ID: 41735056
Thank you very much.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Suggested Courses

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