How to create a css targeting smartphones [closed] - css

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Its been a while since the difference between PCs and Smartphones screens resolution becomes quite close. So i think distinguishing between the 2 using
#media max-width isn't quiet precise.
Am i wrong or is there any other way to do it better?
Edit:
After i asked the question, I got an idea, i thought using the centimeters(cm) unit instead of pixels is the easiest way to distinguish between a small and big screens. but unfortunately the metric system isn't well supported it seems, it works flawlessly with my PC, but my mobile phone think that his width is more than 10cm even 20cm long.
I'm currently using #media orientation to distinguish between PC and Tablet&Mobile. my main concern is the mobile as it's width is so small on portrait orientation for wasting space on page margins, so this is enough for me now.

Remember you can use multiple tests in one query as well as AND/NOT/OR functionality in media queries
#media only screen and (-webkit-min-device-pixel-ratio: 2) and (max-device-width: 480px) {}
I've found testing for pixel-ratio > 1 and/or resolution (dpi) combined with device width useful in catching a lot of mobile devices.

It seems there is no best practice currently and it is recommended to use multiple tricks to detect whether or not the user is using a mobile browser.
Heres a similar question with recommended tricks
Detect if a browser in a mobile device (iOS/Android phone/tablet) is used

Related

What are the disadvantages of vh and vw units? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I am pretty new to front-end development. I wonder what are the disadvantages of vh and vw? I have been always using them because they can adjust the font size based on the screen size. However, I didn't see many people use them as much as I do and saw online that most people prefer to use em. So, it is okay to keep always using vh and vw? What are their disadvantages?
Thank you very much!
The disadvantage is the same as the advantage: it is relative to the screen dimensions.
This is something you probably don't want for a font, since "absolute" units like px and cm already are relative to the perceived size*, which accounts for how distant the observer is from the screen. For example: If a user is using a mobile phone to navigate a web page, you would want the font size to remain constant whether it has a big screen or a small screen.
So I would recommend using an absolute unit like px to set the font size, border thicknesses, etc...
* According to the spec. In practice, the size of px is often synchronized with the OS settings.

Responsive Design, Css Breakpoints [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I'm making a site and I'm making it responsive, i would like to know if it's better to use breakpoints at real devices size as in this image or setting breakpoints on each "breakpoint" in which the design doesn't work.
breakpoints at real screen sizes are unpractical as its nearly impossible to cover all sizes/ devices.. also you have to keep in mind that the browser size is not necessarily the actual screen size.. i would just set the breakpoints to make the design work.
You could have 4 to 5 breakpoints. The ones that I usually use and work well are for:
Extra small devices(Phones) (<768px)
Small devices(Tablets) (≥768px)
Medium devices(Desktops) (≥992px)
Large devices(Desktops) (≥1200px)
Since real device sizes vary, it's nearly impossible to cover all devices.

Is there a standard for sizing a web page with CSS [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm only just now learning anything about CSS through my ASP.net class and I'm wondering if there is a standard for making web sites fit all resolutions.
My textbook simply states "This way, the site fits nicely on screens with a size of 1024 x 768 pixels, a common screen size for many of today’s computers, without being squeezed between the Windows borders. Systems with bigger screens
simply center the site in the available space." -Beginning ASP.NET 4.5 in C# and VB by Imar Spaanjaars
Though I feel this works, I also feel like it's not the standard practice when using CSS.
Any information would be great, as I'm very new to CSS, ASP.Net, and HTML in general.
There are such things as standard page sizes, such as 800x600, 1024x768, and 1280x1024, and different camps have their opinions; but more recent design theories are focusing on responsive design because of the myriad different sizes of screens.
You should design with a few sizes in mind but then make sure the designs look good on as many devices as possible. If you don't have dozens of different screen sizes to work with, the services like the link below can help you check your site using different virtual screen sizes:
http://quirktools.com/screenfly/
For general use case, you can use percentage to adapt your content to the screen size. For example,
<style>
div {
width: 80%;
margin: 80px auto;
padding: 25px;
background-color: #ccc;
}
</style>
<div>Hi!</div>
will display a div which will adapt itself depending of the size of the screen (try resize your window) because of the width: 80%;.
If you want to change CSS rules depending of the size of the screen (technic called "responsive design") then you should use the #media query keywords. See MDN

How many screen sizes should be handled typically for a responsive website? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am new to responsive web designing and CSS3 media queries. I am designing a website that will be accessed through browser on all kind of devices like cell phones, tabs, desktop.
I am using CSS3 media queries and in the process of creating css for my website. I want the font-size, the width of the div should vary as per device's screen width
How many screen sizes should be handled typically if I want my website to look fine on all type of devices. Is there a standard for it?
Please advise.
While you resize your browser window, it should simply look good on every possible size (resize your browser window and make sure you drag it through all the sizes for yourself: smallest to largest for your monitor.)
Then test this as well for different browsers.
You can find a handy tool for this on www.quirktools.com/screenfly.
But remember it's a tool. It should look good on all sizes. No matter how you drag it.
Well, there are a lot of free responsive templates on the web that already do that, but if you want to build your own design from scratch, you should start with a full version of your site for desktop browsers, then add css styles for most common devices/sizes.
Keep in mind that there are a lot of different resolutions a tablet or smartphone could have. 1080p, 720p, 800x600 etc. and a lot in-between.
Just do a quick search for a reference of responsive design device resolution.

css media-query for tablets [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Now-a-days tablets with 1024x768 are rare. Is it still okay to write media query for 1024x768? do those retina tablets upscale the rendered website in order take advantage of the media queries. twitter bootstrap still goes the old way. what is the real meaning in doing so?
By default, high resolution tablets/phones will assume around 1024px (it will vary; in my tests a retina iPad defaults to 980px on a page with no body content). Mobile browser zoom the page layout in and out (this is different from user interaction) as necessary. You do not need to create special media queries for 2048 x 1536 retina resolutions. HTML pages can tell mobile browser how to handle layout with the meta viewport tag. See https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag
Mention the minimum dpi there to specify specific css for those high resolution displays
#media
(-webkit-min-device-pixel-ratio: 2),
(min-resolution: 1024px) {
/* Retina-specific stuff here */
}
// "Retina" being "2x":

Resources