Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rollover effects style sheet 1

Status
Not open for further replies.

1todd1

Programmer
Jan 19, 2002
17
NZ
I have two files the style sheet "styles.ccs" and the html file (included). The problem is that if I use a tag to call the style sheet inside the html file it works - using the rollover. Yet if I use a class call to the external style sheet, it works yet fails on the rollover event using jscript. Any suggestions much appreciated thanks for your time Todd


the style sheet
input.menuBar{
font-family: Andale Mono;
font-size: 18;
color: rgb(48,100,136);
font-weight: bold;
text-align: left;
background-color:transparent;
border: 0;


the html file - try the rollover event on the second button
<html>

<head>
<style>
.start {
color:#ABCDEF;
text-decoration:underline;
background-color:transparent;
class=&quot;menuBar&quot;;
}
.end {
color:#0000FF;
text-decoration:none;
background-color:transparent;
}

#BttnStyle{
font-family: Andale Mono;
font-size: 18;
color: rgb(48,100,136);
font-weight: bold;
text-align: left;
background-color:transparent;
border: 0;
}


</style>
<script language=&quot;JavaScript&quot;>
</script>
<script ID=&quot;clientEventHandlersJS&quot;
LANGUAGE=&quot;javascript&quot;>
<!--
function highlightButton(s) {
if (&quot;INPUT&quot;==event.srcElement.tagName)
event.srcElement.className=s
}
//-->

</script>

<title>dddddddd</title>
<link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;styles.css&quot; title=&quot;docProperties&quot;>
<meta name=&quot;GENERATOR&quot; content=&quot;Microsoft FrontPage 3.0&quot;>
</head>

<body>

<form method=&quot;POST&quot; action=&quot;ProcessType.asp&quot; NAME=&quot;highlightInstructions&quot;
onMouseover=&quot;highlightButton('start')&quot; onMouseout=&quot;highlightButton('end')&quot;>
<p><input ID=&quot;BttnStyle&quot; TYPE=&quot;submit&quot; VALUE=&quot;instructions&quot;
onClick=&quot;location.href='</form>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p><input class=&quot;menuBar&quot; type=&quot;button&quot; value=&quot;Button&quot; name=&quot;B1&quot; size=&quot;20&quot;
onMouseover=&quot;highlightButton('start')&quot; class=&quot;menuBar&quot; onMouseout=&quot;highlightButton('end')&quot;
class=&quot;menuBar&quot;></p>

<p>&nbsp;</p>

<p>&nbsp;</p>
</body>
</html>
 
When I open that, I get a link just like the first for the input, and when it is mousedover, it becomes a button with changing colors of text for mouseover.

What is desired?

Rick -----------------------------------------------------------
RISTMO Designs
Arab Church
 
There's a couple of mistakes in your CSS, start by fixing those and see if it affects the behaviour. It'll make it easier then to work out the solution to your problem.
Run the CSS through the validator.


É ::
 
RISTMO Thanks for your replies much appreciated.

When I open that, I get a link just like the first for the input, and when it is mousedover, it becomes a button with changing colors of text for mouseover.

That is the delima the first link calls the internal HTML style sheet and works with rollover. The second link calls a CSS style sheet and works but fails (turns into a button) with a mouse rollover. The second link (button) should appear the same as the first (a link). The difference – the second link calls an external CSS and uses class (fails with rollover). The first link works and uses ID and an internal style sheet.
Thanks once again - Todd :(
 
Thanks for your reply Cian
There is something wrong with the style sheet? I would be interested to know what that is, as the external CSS works – hence the second button looks like a link - but fails with the rollover. It is likely there is probably something wrong with the way it is being called from the HTML and the impaction of calling the jscript on the style sheet. Im not sure what it is though. I what both links to work the same – one calls internal HTML style the other an CSS file but fails with the rollover.

Thanks for replaying and sorry for repeating the problem as appears that Im unclear with specifics .

Todd
 
There ya go:

<html>
<head>
<style>
.start {
color:#ABCDEF;
text-decoration:underline;
background-color:transparent;
class=&quot;menuBar&quot;;
}
.end {
color:#0000FF;
text-decoration:none;
background-color:transparent;
}

#BttnStyle{
font-family: Andale Mono;
font-size: 18;
color: rgb(48,100,136);
font-weight: bold;
text-align: left;
background-color:transparent;
border: 0;
}
</style>
<script language=&quot;JavaScript&quot;></script>
<script ID=&quot;clientEventHandlersJS&quot;
LANGUAGE=&quot;javascript&quot;>
<!--
function highlightButton(s) {
if (&quot;INPUT&quot;==event.srcElement.tagName)
event.srcElement.className=s
}
//-->
</script>

<title>dddddddd</title>
<link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;styles.css&quot; title=&quot;docProperties&quot;>
<meta name=&quot;GENERATOR&quot; content=&quot;Microsoft FrontPage 3.0&quot;>
</head>

<body>

<form method=&quot;POST&quot; action=&quot;ProcessType.asp&quot; NAME=&quot;highlightInstructions&quot;
onMouseover=&quot;highlightButton('start')&quot; onMouseout=&quot;highlightButton('end')&quot;>
<p><input ID=&quot;BttnStyle&quot; TYPE=&quot;submit&quot; VALUE=&quot;instructions&quot;
onClick=&quot;location.href='</form>

<p> </p>

<p> </p>

<p><input ID=&quot;BttnStyle&quot; class=&quot;menuBar&quot; type=&quot;button&quot; value=&quot;Button&quot; name=&quot;B1&quot; size=&quot;20&quot;
onMouseover=&quot;highlightButton('start')&quot; onMouseout=&quot;highlightButton('end')&quot;></p>

<p> </p>

<p> </p>
</body>
</html>

The problem was that the id=&quot;BttnStyle&quot; wasn't included in the second button.

Rick
-----------------------------------------------------------
RISTMO Designs
Arab Church
 
Rick Thanks once again for your reply

There seems to be confusion on the interpretation of the question. I realise that an id tag can be used to reference the internal style sheet – this is what is achieved in the first button (working with rollover). I’m trying to have an external CSS which is referenced using the class=&quot;menuBar&quot; – yet doesn’t work with the rollover. Another question - do you know how to reference an external CCS using the ID tag?

Thanks for your reply time and patience. Todd

We will keep banging our heads into the wall to finally break through. :)
 
From your original post there are a few errors in the CSS

External style sheet
input.menuBar{
font-family: Andale Mono;
font-size: 18pt or px;
color: rgb(48,100,136);
font-weight: bold;
text-align: left;
background-color:transparent;
border: 0;
};

Your other css

start {
color:#ABCDEF;
text-decoration:underline;
background-color:transparent;
class=&quot;menuBar&quot;; REMOVE
}
.end {
color:#0000FF;
text-decoration:none;
background-color:transparent;
}

#BttnStyle{
font-family: Andale Mono;
font-size: 18pt or px;
color: rgb(48,100,136);
font-weight: bold;
text-align: left;
background-color:transparent;
border: 0;
}

I'd recommend you put all css into the external style sheets, it will make it easier on you.
There's no difference using the ID in the HTML document or in the external style sheet, usage is the exact same.



É ::
 
Thank everyone for your help and speedy reply

Cyan you hit the nail on the head, and answered my problem. I ended up by correcting the style sheets, although was working with errors. Using an ID Tag to call the external style sheet solved the problem. Yes Cyan, I agree it is good practice to bundle all css into the external style sheet/s (what im endeavouring to do).

Thanks once again everyone Todd

The working output


The style sheet called “styles.css”


#BttnStyle{
font-family: Andale Mono;
font-size: 18px;
color: rgb(48,100,136);
font-weight: bold;
text-align: left;
background-color:transparent;
border: 0;
}


The HTML file

<html>

<head>
<style>
.start {
color:#ABCDEF;
text-decoration:underline;
background-color:transparent;
}

.end {
color:#0000FF;
text-decoration:none;
background-color:transparent;
}



</style>
<script language=&quot;JavaScript&quot;>
</script>
<script ID=&quot;clientEventHandlersJS&quot;
LANGUAGE=&quot;javascript&quot;>
<!--
function highlightButton(s) {
if (&quot;INPUT&quot;==event.srcElement.tagName)
event.srcElement.className=s
}
//-->

</script>

<title>dddddddd</title>
<link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;styles.css&quot; title=&quot;docProperties&quot;>
<meta name=&quot;GENERATOR&quot; content=&quot;Microsoft FrontPage 3.0&quot;>
</head>

<body>

<form method=&quot;POST&quot; action=&quot;ProcessType.asp&quot; NAME=&quot;highlightInstructions&quot;
onMouseover=&quot;highlightButton('start')&quot; onMouseout=&quot;highlightButton('end')&quot;>
<p><input ID=&quot;BttnStyle&quot; TYPE=&quot;submit&quot; VALUE=&quot;instructions&quot;
onClick=&quot;location.href='&lt;</form>

<p><input ID=&quot;BttnStyle&quot; type=&quot;button&quot; value=&quot;Button&quot; name=&quot;B1&quot; size=&quot;20&quot;
onMouseover=&quot;highlightButton('start')&quot; class=&quot;menuBar&quot; onMouseout=&quot;highlightButton('end')&quot;
class=&quot;menuBar&quot;></p>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top