Welcome Guest!
Please login
If you do not have an account yet on The Web Squeeze forums, please Register! It’s FREE and there are many benefits:
- Receive Fast Advice
- Learn Programming Languages
- Get Professional Website Reviews
- Quick Troubleshooting Assistance
|
|
Detect Screen Resolution
This is a discussion on Detect Screen Resolution, within the Web Design in General section. This forum and the thread "Detect Screen Resolution" are both part of the Designing Your Website category.
![]() ![]() |
Sep 25 2008, 06:23 AM
Post
#1
|
|
|
Fresh Squeezed ![]() ![]() Posts: 28 Joined: 14-February 08 |
Hi everyone! I have another good question... Is there a way to detect the users screen resolution and load a different stylesheet according to each? The reason is that I'm working on a website, and if I make it work on an 800x600 screen, it looks awful on bigger screen resolutions, and vice versa. The main problem being the width of my columns (content and sidebar). If I make them small enough for the smaller res, then there is too much whitespace on the bigger res. If I make them pretty on the bigger res, my sidebar gets pushed below the content div. Any ideas are welcome!
|
|
|
Sep 25 2008, 06:37 AM
Post
#2
|
|
|
Rapid Squeezer ![]() Posts: 308 Joined: 15-February 08 From: Finland |
CODE <script type="text/javascript"> document.write(screen.width + 'x' + screen.height); </script> Then just load different css based on that selection. -------------------- |
|
|
Sep 25 2008, 06:52 AM
Post
#3
|
|
|
Squeeze Machine ![]() Posts: 682 Joined: 15-February 08 From: UK |
Variation among screen resolutions has been a web design problem for a long time. There are various well-established solutions:
The simplest solution is to choose a minimum supported resolution and stick to it. This is makes design somewhat easier, because you know the size of your "canvas". Nowadays designers are moving towards 1024*768 as a minimum supported resolution. Instead, you can use a liquid layout where the widths are specified in percentages (%) rather than pixels (px). Liquid layouts will stretch to any screen width. They have two serious disadvantages, however: you lose control of design proportions, and on large windows the text lines become very long (and hence hard to read). My preferred solution is to use an elastic and flexible layout: elastic because the entire layout scales with the font size, and flexible because it compresses when the window is too narrow. See my badminton website, for example. First, try changing the text size; notice how the layout maintains proportions. Next, try reducing your browser window below 1024px, and notice how the main content area compresses to accommodate this. The disadvantage of elastic layouts is that they are harder to code; you need a stronger understanding of CSS. They tend to require a little more markup too (which is hardly an issue). I don't recommend using javascript to detect screen resolution. If you were going to do that, you would need to detect the viewport dimensions instead: don't forget that the user may not be using the entire screen space for his browser window! This is especially common on large screens. And what happens if he changes the window size? Are you going to swap around the stylesheets? This is getting messy. In general, you should avoid using javascript to fix layout issues, because it slows down your website (see Yahoo's performance rule 25). Javascript layout solutions are extremely hacky. I use javascript to fix Internet Explorer's lack of support for {display: table}, but otherwise I would avoid fixing site layout with JS. I do use javascript to fix small-scale layout issues, such as generating extra markup for multiple background images on a "pull-out" box; but this is nowhere near as hacky as using it to fix your entire layout. With javascript, a light touch is generally best. Avoid using javascript to do stuff that CSS does more efficiently; CSS is good for layout, and javascript is not. And don't forget that your pages should degrade gracefully when javascript is unavailable. If you do decide to use a javascript method, ensure that it does not continuously evaluate (or your website will slow to a crawl). By using multiple stylesheets for different resolutions, you also greatly complicate your design and release process. It's much simpler just to choose a width (I use ems, but you could use px) and centre this on the page. Providing the whitespace is balanced on the page, it's no problem. |
|
|
Sep 25 2008, 03:33 PM
Post
#4
|
|
|
Fresh Squeezed ![]() ![]() Posts: 28 Joined: 14-February 08 |
Thanks guys! I suppose it may be easier if I just play around with my CSS and try to get it right. I would post the link for you to see, but I haven't done everything that needs to be done security-wise yet
|
|
|
If you found The Web Squeeze to be helpful, please donate so we can keep this site FREE, FRESH, and fortified with Web Design & Development info!
![]() ![]() |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
Similar Topics
| Topic Title | Replies | Topic Starter | Views | Last Action | |||
|---|---|---|---|---|---|---|---|
![]() |
14 | Linda | 634 | 27th February 2008 - 06:41 AM Last post by: Linda |
|||
![]() |
11 | jamesicus | 478 | 5th May 2008 - 12:14 PM Last post by: MikeHopley |
|||
![]() |
2 | Justify | 205 | 11th July 2008 - 08:51 PM Last post by: Mark Poppen |
|||
![]() |
12 | Linda | 423 | 30th September 2008 - 10:14 AM Last post by: Simon |
|||
![]() |
9 | Linda | 380 | 16th October 2008 - 07:36 PM Last post by: karinne |
|||






Sep 25 2008, 06:23 AM








