• Page 1 of 1
  • 1
Forum moderator: bigblog  
uCoz Community » For Webmasters » Custom Solutions » Create a multi-style website with JavaScript and CSS
Create a multi-style website with JavaScript and CSS
darkion
Posts: 32
Reputation: 1

Message # 1 | 2:19 PM

Hi! In this tutorial, I'm going to show you how to create two different styles to your website; or you can say, how to change some parts of it.
You can see demo by clicking on this link, before you continue reading .

http://multistyletut.ucoz.com/


Now, before you start, you have to make sure that you have main style file [ Usually named "style.css"] and a modified copy of it [ Alternative to "style.css" ]

If you are using a default uCoz template, then your main "style.css" is named "my.css" and located as "/_st/my.css", you have to download it and rename it to any name you want [Example "orange.css" ], then upload it again to the main root of your website after making some changes on it [For examle : background image, logo color, ...etc]

Do the same thing if you weren't using a default template.

==========================

Step 1:


Now you have at least two css files, define which is the main and which is alternate one, by doning the following :

Go to your Control Panel -> Design -> Quick substitution of template parts -> switch to "Multi-Line" replacement.





In "Find" field, enter :

Code
</head>


In "Replace With" field, enter :

Code
<link rel="alternate stylesheet" type="text/css" media="screen" title="YOUR ALTERNATE STYLESHEET NAME" href="YOUR ALTERNATE STYLESHEET LINK" />
</head>


==========================


Step 2:


You have now main style and alternate one, now, you have to use a third-party JavaScript* to change the stylesheet. Do so by doing the following:

Go to your Control Panel -> Design -> Quick substitution of template parts -> switch to "Multi-Line" replacement.

In "Find" field, enter :

Code
</head>


In "Replace With" field, enter :

Code
<script src="http://darkionsblog.com/js/styleswitch.js" type="text/javascript">
</head>


you can download the script from the link above, and customize it for your own use.

==========================


Step 3:


Now, by doing the same, change "body" tag state to load the style from cookies, by doing the same steps :

Go to your Control Panel -> Design -> Quick substitution of template parts -> switch to "Multi-Line" replacement.

In "Find" field, enter :

Code
<body>


In "Replace With" field, enter :

Code
<body onload="set_style_from_cookie()" >


==========================


Step 4:


Now, you just have to use the following Hyperlink to apply a style . You can attach it to an image as I did in the demo site.

Code
<a href="javascript:chooseStyle('YOUR STYLE TITLE', 30)"> Click to change style </a>


30 defines how many days to keep your website's cookies, you can change it to any number.

To set back the default style, use the following link:

Code
<a href="jvascipt:chooseStyle('none, 30)"> Click to change the style to the main one</a>


"none" refers to the main style.

==========================

You can make as much as you want of alternate styles.

Use any text editing application to edit your styles. [Notepad++ , Dreamwaver , ...etc]


COPYRIGHT :


* Style Sheet Switcher script is made byDynamic Drive .

That's it biggrin
Check Demo : http://multistyletut.ucoz.com/

Attachments: 9703501.jpg (44.7 Kb) · 2078679.jpg (36.1 Kb)

Post edited by darkion - Tuesday, 2012-02-28, 5:16 PM
carloscompu
Posts: 246
Reputation: 1

Message # 2 | 3:02 AM
Can I make two difrent css code for my comment box I have the video module that the background is Black and I have the normal modules as comunities that the background is white

I want a style sheet comment box grey for video module and a blue one for the comunity
PixelKhaos
Posts: 636
Reputation: 26

Message # 3 | 8:52 AM
carloscompu, that is possible, yes. Simply put each version of the css in seperate .css files.
Just follow the tutorial above to apply those two styles.

Proud uCoz user since 2006
Freelance designer - http://pixelkhaos.com
PixelKhaos on twitter - @PixelKhaos

I can help you develop your site for a small fee.
carloscompu
Posts: 246
Reputation: 1

Message # 4 | 7:25 AM
Is This correct ,Cause i figured out a nother way to build the blocks without using 2 css sheets
But I want to know if it wont cause no prob or malfuntions in other parts of my website

I created three difrent blocks for three difrent ares of the website

Quote
/* Entries Style */
.eBlock { border-top-left-radius: 7px;
border-top-right-radius: 5px;
border-bottom-right-radius: 6px;
border-bottom-left-radius: 8px;
border:3px solid #75D6FF;background:#FFFFFF;}
.eBlock1 { box-shadow: 10px 10px 5px #888;padding-left:20px; border-top-left-radius: 25px;
border-top-right-radius: 25px;
border-bottom-right-radius: 25px;
border-bottom-left-radius: 25px;
border:;background: -moz-linear-gradient(top, #fff, #00A3EF);
background: -webkit-linear-gradient(top, #fff, #00A3EF);
background: -o-linear-gradient(top, #fff,#00A3EF);
background: linear-gradient(top, #fff, #00A3EF)}
.eBlock2 { box-shadow: 10px 10px 5px #888;padding-left:20px;padding-right:20px; border-top-left-radius: 25px;
border-top-right-radius: 25px;
border-bottom-right-radius: 25px;
border-bottom-left-radius: 25px;
border:3px solid #8ADCFF;}
PixelKhaos
Posts: 636
Reputation: 26

Message # 5 | 11:06 AM
carloscompu, if you use names for the classes and id's in the CSS that are not used by anything else, it should be fine.
So, you are using different CSS classes for the same part of the site, but depending on which page it is another class?

If this is the case, you should be fine, just go ahead.

Proud uCoz user since 2006
Freelance designer - http://pixelkhaos.com
PixelKhaos on twitter - @PixelKhaos

I can help you develop your site for a small fee.
carloscompu
Posts: 246
Reputation: 1

Message # 6 | 1:08 AM
Im sorry to be anoying with thing that i might already know

But does css sheet have a limit?

Added (2012-12-16, 7:08 PM)
---------------------------------------------
And will this kind of coding work with comments or will I have to upload a new css sheet?

uCoz Community » For Webmasters » Custom Solutions » Create a multi-style website with JavaScript and CSS
  • Page 1 of 1
  • 1
Search: