Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Responsive web design by using css or javascript?

I am going to make a website that is using responsive design. I read some information about css media query. What I wanna do is that the layout of my webpage should looks difference by using different devices (like PC, tablets or smartphones).

If I use media query to determine the device by using the width of the screen (in pixel), I always worry about if there will be a new device using a extremely high ppi screen. That device may threat as tablet or something like PC?

Another solution that is using the user agent to determine the device category by using userAgent. There's also a problem is that if the device not interpret the javascript fine then the page maybe broken.

Any great solution that can solve my worries above? Or Which solution is better?

Or I misunderstand the method of using media query?

Thank you.

like image 854
benleung Avatar asked Aug 23 '13 04:08

benleung


People also ask

Can we make responsive website using JavaScript?

So in order to create good mobile responsive sites, without using frameworks like Bootstrap and assuming you have good understanding of HTML, you should at the very least learn: Media queries. Using css to layout the page. Manipulating the DOM with Javascript.

Can CSS be responsive?

Modern CSS layout methods are inherently responsive, and, since the publication of Gillenwater's book and Marcotte's article, we have a multitude of features built into the web platform to make designing responsive sites easier.

Which language is best for Responsive Website?

CSS and HTML The foundation of responsive design is the combination of HTML and CSS, two languages that control the content and layout of a page in any given web browser.

What is responsive website in JavaScript?

Responsive Web Design is about using HTML and CSS to automatically resize, hide, shrink, or enlarge, a website, to make it look good on all devices (desktops, tablets, and phones):


2 Answers

CSS is the way to go, and you can always provide fallback for browsers that don't support media queries using a js plugin like css3mediaqueries.js, but relying on JS solely to make your website responsive is a risk because you can't tell for sure if the user will have Javascript enabled, and when it's not enabled it's not going to be responsive anymore.

Also, it's considered best practice now to use em values for media queries instead of pixels to make sure your website always scales right. More on this topic in this article.

Another tip is that you determine the media query values according to your content's best break points instead of device dimensions, that way you also make sure your content will always look right no matter how many new devices are made.

Hope that helped :)

like image 125
Sara Sou Avatar answered Oct 02 '22 16:10

Sara Sou


id' personally use CSS and set min-width and max-width. Most responsive designs now days use CSS. This way if there is a new device on the market it will just adjust according to it's screen size.

@media screen and (max-width:480px) { }
@media screen and (min-width:481px) { ) etc... etccc....
like image 31
vzeke Avatar answered Oct 02 '22 15:10

vzeke