Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Css And Javascript Combined For Dynamic Layout, use of different CSS files at same site
rvovk
post Aug 5 2005, 08:06 PM
Post #1


Super Member
*********

Group: Members
Posts: 378
Joined: 13-October 04
From: Slovenia
Member No.: 1,731



This tutorial is meant for people that are dealing with problems while coding their site at 100% of width. Important notice: Some people has JavaScript disabled, so they will not be able to load CSS file (take this in account when creating your website).

How this script works. In the HEAD of your HTML document will apply this command, so variable.js file will be load at start:

CODE
<script type="text/javascript" src="variable.js"></script>


In browser JavaScript file variable.js is loaded. This Javascript file consist of this parameters, copy this code and name it variable.js

CODE
// JavaScript Document
if (screen.width < 1024) {
document.write('<link rel=stylesheet type="text/css" href="layout800.css">');
}
if (screen.width >= 1024) {
document.write('<link rel=stylesheet type="text/css" href="layout1024.css">');
}
if (screen.width >= 1280) {
document.write('<link rel=stylesheet type="text/css" href="layout1280.css">');
}
if (screen.width >= 1600) {
document.write('<link rel=stylesheet type="text/css" href="layout600.css">');
}


As we see this file has parameters for screen width, browser sees which resolution are you using and according to that proper layout CSS file is choosen.

layout800.css >>for resolution equal or smaller then 800px of width
layout1024.css >>for resolution equal or bigger then 1024px of width
layout1280.css >>for resolution equal or bigger then 1280px of width
layout1600.css >>for resolution equal or bigger then 1600px of width

Now you must write layout CSS files for every resolution where you can define bigger or smaller fonts, width and heights of columns and so, depending on resolution. Everything, html files, CSS files and javaScript file are installed in same directory on your server, or choosing your relative paths, if you defined any.

Working site that was made with this tutorial for dynamic CSS is: http://rvovk.computinghost.com/godba1/
This is their new site, where I used fixed width: http://rvovk.trap17.com/godba/

Enjoy this tutorial, suggestions welcomed.
Go to the top of the page
 
+Quote Post
mayank
post Aug 6 2005, 04:57 AM
Post #2


Mankie
*********

Group: Members
Posts: 761
Joined: 22-July 05
From: New Delhi, India
Member No.: 9,746



well thanks for this nice tutorial and i would like to mention that your site is also really great....especially i loved your menu system...that is really good.
i loved the photographs as well...i was not able to read what was written there as i only understand english and think that is having a diff. language.
hope to see some more photographs!
Go to the top of the page
 
+Quote Post
electriic ink
post Aug 6 2005, 05:10 AM
Post #3


Incest is a game the whole family can play.
Group Icon

Group: [MODERATOR]
Posts: 1,205
Joined: 11-February 05
From: Heaven
Member No.: 3,709



QUOTE(rvovk)
Important notice: Some people has JavaScript disabled, so they will not be able to load CSS file (take this in account when creating your website).


These people you still need to provide for, so here's the code which you should add after the </script> tag to cater for people with javascript-disabled browsers:

HTML
<noscript>
<link href="layout1024.css" rel="stylesheet" type="text/css">
</noscript>


The 1024x768 screen setting is gonna be made the default when the next version of windows comes out so I would choose that to be the default for people who have javascript disabled but you can change that.

People who write in xhtml should put a forward slash before the closing bracket, shouldn't they?
Go to the top of the page
 
+Quote Post
rvovk
post Aug 6 2005, 09:02 AM
Post #4


Super Member
*********

Group: Members
Posts: 378
Joined: 13-October 04
From: Slovenia
Member No.: 1,731



Mayank, yes I know, it would be nice to have this site in English, cause it is really good. I am working on this site for one year or little more now. Even though I don't get payed for it I love working on this project. Website building is hobby for me smile.gif On this site you have also MP3 section, this is about Brassband from Crnomelj, Slovenia, the nicest area in SLovenia were I lived for 5 years.
Cmatcmextra, thanx for making my code even better. But I believe that people are still using Windows 98 and XP is worldwide, so I guess 800px width should be standard in future. You will never be able to make universal width for everyone, but 8oopx isn't bad at all, I like this width most on 1280*1024 monitors.
Go to the top of the page
 
+Quote Post
Tyssen
post Aug 6 2005, 01:04 PM
Post #5



***********

Group: Members
Posts: 1,161
Joined: 9-May 05
From: Brisbane, QLD
Member No.: 6,818



If your site is in PHP or ASP, you wouldn't have to worry about JS being turned off. wink.gif
But really, that's why I do nearly all my sites for a maximum width of 800px - its too much additional work otherwise.
Go to the top of the page
 
+Quote Post
rvovk
post Aug 6 2005, 01:46 PM
Post #6


Super Member
*********

Group: Members
Posts: 378
Joined: 13-October 04
From: Slovenia
Member No.: 1,731



Howcome is that, Tyssen, not being worried about JS being turned off?
Go to the top of the page
 
+Quote Post
Saint_Michael
post Aug 6 2005, 03:26 PM
Post #7


$p4m 0n j00 $h4m3 m3 0nc3 $p4m 0n m3 $h4m3 m3 7\/\/1c3
*********************

Group: [HOSTED]
Posts: 6,305
Joined: 21-September 04
From: 9r33|\| 399$ 4|\|D 5P4/\/\
Member No.: 1,218
T17 GFX Crew



well js is another source of chewing into bw and also it slows the load up time as well.
Go to the top of the page
 
+Quote Post
Tyssen
post Aug 7 2005, 06:00 AM
Post #8



***********

Group: Members
Posts: 1,161
Joined: 9-May 05
From: Brisbane, QLD
Member No.: 6,818



QUOTE(rvovk @ Aug 6 2005, 11:46 PM)
Howcome is that, Tyssen, not being worried about JS being turned off?

What I meant was that you'd do the scripting in ASP or PHP and then it would still be served whether JS was on or not.
Go to the top of the page
 
+Quote Post
Adamrosso
post Aug 7 2005, 08:49 PM
Post #9


Advanced Member
*******

Group: Members
Posts: 128
Joined: 6-August 05
Member No.: 10,402



Yes your website is really nice. Your talented with CSS. Anywho, this tutorial is great. I needed this, as i did not know how to expand my layouts to be 100%. I tried tables but that failed too =(. Anywho, thanks for this great tutorial =)