4
I need to do a.css style for mobile and another for web .
4
I need to do a.css style for mobile and another for web .
3
I don’t know anything that separates totally mobile from desktop, because you have many factors that can influence this, for example, there are still mobile that do not have touch, there is the Aspect ratio of the device where you can not simply say that 800px is mobile or not. everything depends on what you need to do!
If you just want to make a responsive layout you can delimit min or max width via media query. recommend these two readings: Tableless and MDN.
Now, if you want to check the touch issue you can use this code in javascript:
if(('ontouchstart' in window)){ //seu cod. aqui! }
If you can define better what you need I can help you further.
I think in practice what most do is detect on the server side whether the device is mobile, and sends a different page, or a different CSS at least, depending on the type. In PHP I use the class http://mobiledetect.net/
Excellent comment epx! you also have this option Jose, everything depends on what you need, I particularly seek to do these checks in the client-side, but nothing prevents you to do this check on the server as well.
which client-side check you use @Dorivalzanetto ?
It depends a lot of what I need Jose, for example if I need a modification to Landscape/Portrait I use the orientation of the media query, if it is to make a responsive for small screens I use the min-width or max-width as the value of the query, this goes for height too, If it’s touch I use the Js section I sent you above.. As I told you, it all depends on what I need, a look at the references I showed you! What you necessarily need to do?
-1
function isMobile() {
return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER['HTTP_USER_AGENT']);
}
Staff has a script that detects where your application is being accessed follow the link below : http://wbruno.com.br/expressao-regular/detectando-browser-mobile-javascript/
Could you bring some of the link content to the body of your answer? Links constantly break, so responses based only on the link end up being obsolete faster and are removed. However, it is always good to leave the link as a reference :)
Browser other questions tagged java html css html5
You are not signed in. Login or sign up in order to post.
what is being done nowadays is not knowing if the user is watching on the Web or Mobile, but creating styles for the different screen sizes: http://getbootstrap.com/css/#grid-media-queries
– balexandre
It is not necessary to write a file for each version, you can use media queries, take a look at these two articles: Responsive design in practice: from draft to digital and Responsive Design in Practice 2: From Layout to HTML
– Laerte
I know and I use it . I will answer my own question and attach the image for you to see the problem. @balexandre
– Jose Vieira Neto
If you have any other information to add, it helps in understanding the problem, edit your question and add the information there.
– emanuelsn