mediaquery : How to detect touch device? [duplicate] - css

This question already has answers here:
Media query to detect if device is touchscreen
(13 answers)
Closed 7 years ago.
I need to apply some alternative :hover for touch devices. Is there any solution in CSS to detect touch device ?
Is there any Media Query option to detect touch device ?

There isn't a media query to detect touch devices. You would need to use something like Modernizer.

Related

#media only screen and #media screen query which is the better choice [duplicate]

This question already has answers here:
What is the difference between "screen" and "only screen" in media queries?
(6 answers)
Closed 1 year ago.
Thanks for the help in advance.I am writing some media queries while searching i saw two syntax of it
like #media only screen and (max-width:767px) and #media screen and (max-width:767px).Can anyone tell the difference between two and among these two which is the better one to use
You definitely no longer need to use only. It has been used in the past to prevent old browsers to apply the rule to the entire screen. Basically in the past some browsers were ignoring the breakpoint and applying the rule to the entire screen even if stated. In your case (max-width:767px).

How to create a css targeting smartphones [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 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

iPhone X full screen issue [duplicate]

This question already has answers here:
Seeing black bars at the top and bottom of the iPhone X Simulator
(11 answers)
Closed 5 years ago.
Today I've installed Xcode 9 and build my app for iPhone x. but the upper and bottom area showing black like the scenarios we met couple of years ago for iPhone 5 when screen switched to 3.5 to 4.
How simply we can fix this problem?
You should use a safe area.
For apps with custom layouts, supporting iPhone X should also be
relatively easy, especially if your app uses Auto Layout and adheres
to safe area and margin layout guides.
Read more: https://developer.apple.com/ios/human-interface-guidelines/overview/iphone-x/
I am also same issue. I used safe area Layout also. But above solution not support for me . I got solution from below link.
https://www.bignerdranch.com/blog/get-your-apps-ready-for-iphone-x/
This below point helped for me to resolve that solution.
Ensure your app uses a Launch Screen storyboard (not Launch images).

How to select image from gallery or camera in android? [duplicate]

This question already has answers here:
android pick images from gallery
(19 answers)
Closed 5 years ago.
I want to know how to select image from camera or gallery programmatically, where image is picked by user in android?
If you are simply using an Android phone or a tablet just get into the gallery long press on the desired photo you need and voila!!! Your picture is selected!!

How to target 1024x768 resolution through media queries? [duplicate]

This question already has answers here:
CSS media queries for screen sizes
(3 answers)
Closed 8 years ago.
I want to test a website on a plasma screen. This screen is 55 inches wide, but has a resolution of 1024x768. So for testing purposes, I changed my laptop's resolution from 1600x936 to 1024x768, and the site that was being tested displayed the same results.
I want to be able to target this 1024x768 screen resolution (not the device width or max, or min-width) via media queries.
Can someone please help me with this? Again, my laptop is 17 inches widescreen, and the default display is 1600x960. I want to test a website for responsive design for 1024x768 resolution. Need an appropriate media query for that.
I think this might be what you want: http://www.broken-links.com/2012/07/13/using-media-queries-to-test-device-resolution/
Edit:
I don't believe this is a duplicate, as it deals with the need to target the resolution and specifically NOT the device size.
Anyhow, click on the link above for a full analysis of this problem, but basically, I'll paraphrase here.
You can use the devicePixelRatio property to find out the DPR of your current device; unfortunately it’s not supported in Firefox for some reason, but it’s in all other major browsers:
console.log(window.devicePixelRatio);
Once you have your DPR (I’m going to use 1.5 as an arbitrary number throughout this article) you can start using it in your media query logic.
#media (-webkit-min-device-pixel-ratio: 1.5) {}
All of this being the case, the minimum number of media features you need to test for device resolution across the major browsers is two:
#media (min-resolution: 144dpi), (-webkit-min-device-pixel-ratio: 1.5) {}

Resources