17 May, 2008, 09:16:55 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: We Return!
 

Pages: [1]   Go Down
  Print  
Author Topic: CSS with HTML and JS  (Read 5904 times)
0 Members and 1 Guest are viewing this topic.
Canada
I like to eat some food, preferbly

some 3.14! Because pie is good!

GFX Staff

Platinum Contribution
*
Legendary Member

Karma: 18
Offline Offline

Gender: Male
Posts: 1070
853477.31 Secksi Coins

View Inventory
Send Money to Zapper

View Profile
« on: 15 January, 2007, 06:31:15 PM »
"Some are born great, some achieve greatness, and some have greatness thrust upon ’em" - William Shakespeare

When using CSS it would be good to know some basic Javascript and HTML, as some things you can not do with CSS but easily with JS or HTML.

One thing, always end your style tags before the html or javascript!


First off, with HTML you can easily link to a .css file...
<LINK REL=stylesheet HREF="http://slaytanist.co.uk/zapper/Solar/Solar_Eclipse.css" TYPE="text/css">
Replace the red with a link to a .css file, many upload locations like ripway will allow you have any ending you choose, so just make a new file and have the extension as .css



Always remember to have <script></script> around any javascript code!


2 important things for javascript,
First the location CSS. This is if you want CSS to appear on a certain page, and you can't edit every page seperately or you want one css file for all pages. This is good for things like forums.

if ( location.search.indexOf('act=calendar')!=-1) {
document.write("!!!!")}
Replace the red with what you want to appear on a certain page, the blue becomes the extra URL, so "http://z13.invisionfree.com/SomeForum/index.php?showforum=46" would have "showforum=46" for it to be only on that page, and any page that has that extra URL in it so if it was:
"http://z13.invisionfree.com/SomeForum/index.php?showforum=46&Delete" then it would also have the effect on it.

The green will reverse the effect, while in "-" the effect will be to that page only, while in "+" the effect will be to every other page except that page!

When using for CSS, you'll want to use style tags and put the css inside, like so:
if ( location.search.indexOf('act=Search&f=')!=-1) {
document.write("<style>.tableborder { border:0px solid #000000;background-color:#000000; }</style>")}

Always remember to have <script></script> around any javascript code!


2nd javascript is the browser(version and type), this can be combined with the above javascript trick, as I will display at the end.
Credit for this towards godman123/SyKo of the IF pussycore lamers.

The code initially:
var browser_type=navigator.appName
var browser_version=parseInt(navigator.appVersion)
if (browser_type=="Microsoft Internet Explorer"&&browser_version>=4) {document.write("Browser only stuff")}</script>

Initially lets look at the line that says "if (browser_type=="Microsoft Internet Explorer"&&browser_version> =4)"

The red is the browser name that the coding will only affect, Fire Fox, Safari, etc.
The blue is the version number being affected,
while if the green is there and faces > then blue and any version greater than blue will be affected.
If the green is < then blue and any version lower than blue will be affected. If the green is not there then only the blue will be affected, no other versions.

Inside the "document.write("!!!!") " is essentially the same as the same as the location JS. Just put your style tags and then put your CSS inside.

var browser_type=navigator.appName
var browser_version=parseInt(navigator.appVersion)
if (browser_type=="Microsoft Internet Explorer"&&browser_version>=4) {document.write("<style>.darkrow3  a:active { text-decoration: none; color: #727EA2; border:1px solid #464646; }</style>")}


Getting more complicated, you can do this with certain pages and browser type at the same time by combining the codes...

Inside the "document.write("!!!!") " you just put the JS from before so:

var browser_type=navigator.appName
var browser_version=parseInt(navigator.appVersion)
if (browser_type=="Microsoft Internet Explorer"&&browser_version>=4) {document.write("if ( location.search.indexOf('act=site')!=-1 ){document.write("<style>.maintitle { background-color: #151515; }</style>")}")}

Now in IE version 4 or above and on act=site of your website or forum your class "maintitle" will have a background coloured #151515...


Want an extensive example:
Quote
var browser_type=navigator.appName
var browser_version=parseInt(navigator.appVersion)
if (browser_type=="Microsoft Internet Explorer"&&browser_version>=4) {document.write("<style>div.darkrow3 a:link, div.darkrow3  a:visited, div.darkrow3  a:active { text-decoration: none; color: #727EA2; border:1px solid #464646; border-bottom:1px solid #151515; border-right:1px solid #151515; padding:4px;} .dlight { background-color: #282828; border:1px solid #151515!important; background: url(http://img63.imageshack.us/img63/3237/dlightpx4.png);}</style>")
if ( location.search.indexOf('act=site')!=+1 ){document.write("<style>.maintitle { background-color: #151515; background-position: center; vertical-align:middle; font-weight:bold; color: #CCCCCC; padding:5px 0px 9px 30px; background-image: url(http://img123.imageshack.us/img123/7531/maintitler2dv7.png); }</style>")}
if ( location.search.indexOf('act=Login&CODE=')!=-1) {
document.write("<style> ..maintitle {border-bottom:1px solid #464646; background-color: #151515; background-position: center; vertical-align:middle; font-weight:bold; color: #CCCCCC; padding:5px 0px 9px 30px; background-image: url(http://img207.imageshack.us/img207/9450/maintitlerik6.png); </style>")}}</script>
Logged

~!Zapper





MY ID CARD
This resource was found useful by 5 out of 5 members. Rate it: [applaud] [smite]
Coding Team

Silver Contribution
*
Legendary Member

Karma: 19
Offline Offline

Posts: 1223
57168.48 Secksi Coins

View Inventory
Send Money to CodeMaster

View Profile WWW
« Reply #1 on: 21 January, 2007, 09:27:42 PM »

Very useful tut Smiley
Logged

slayer766United States
Long live TCZ

TCZ r0x my s0x

Administrator

Platinum Contribution
*
Conqueror

Karma: 56
Offline Offline

Gender: Male
Posts: 4419
415595.08 Secksi Coins

View Inventory
Send Money to slayer766

View Profile
« Reply #2 on: 04 February, 2007, 03:41:04 PM »
"We know what we are, but know not what we may become." - William Shakespeare

Wow, very nice Zap. Wink
Logged

Live for nothing or die for something






PanzerNew Zealand
Linux!

Administrator

Silver Contribution
*
Legendary Member

Karma: 30
Offline Offline

Gender: Male
Posts: 1293
1761143.96 Secksi Coins

View Inventory
Send Money to Panzer

View Profile
« Reply #3 on: 04 February, 2007, 05:39:15 PM »

Woah, great Smiley
Logged

Review God

Hi there!!

Ex-Staff

Silver Contribution
*
Elite Member

Karma: 8
Offline Offline

Gender: Male
Posts: 180
2780.00 Secksi Coins

View Inventory
Send Money to Nuke

View Profile
« Reply #4 on: 24 February, 2007, 03:32:30 AM »

*applauds* Great tutorial.
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  
Sponsored Links:

HTML Tutorials
Data Recovery
Powered by MySQL
Powered by PHP
Powered by SMF 1.1.1 | SMF © 2005, Simple Machines LLC
TinyPortal v0.8.6 © Bloc
The rest copyright TCZ you pillocking twat!
Valid XHTML 1.0!
Valid CSS!
Places we'd like you to visit.