PDA

View Full Version : mouseover effect


farley89hd
12-13-2006, 10:38 AM
is it possible to do a mouseover where the button flips?

I mean I want it to flip like in a game show, when they say "show me the answer"
the questions flip horizontally and the answer is there.

I believe I would have to have two images. the "question" and the "answer", but how would I achieve that flip.

TIA

erisco
12-13-2006, 12:27 PM
With javascript... or you could do a hover class with CSS, although to see the answer it would require the user to have their mouse hovered over some element for the whole duration that they want to see the other image.

coothead
12-13-2006, 03:32 PM
Hi there farley89hd,

have a look at this example that uses onclick rather than onmouseover...

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
#info {
font-size:16px;
text-align:center;
margin-top:40px;
}
#q {
width:150px;
height:30px;
line-height:30px;
border:2px solid #999;
text-align:center;
overflow:hidden;
margin:20px auto;
}
.qc {
background-color:#333;
color:#ccc;
}
.ac {
background-color:#ccc;
color:#333;
}
</style>

<script type="text/javascript">

var qs=new Array();
qs[0]='question 1';
qs[1]='question 2';
qs[2]='question 3';
qs[3]='question 4';

var as=new Array();
as[0]='answer 1';
as[1]='answer 2';
as[2]='answer 3';
as[3]='answer 4';

var c=29;
var k=1;
var n=0;
test=0;
var obj;
var speed=25;
var delay=2000;

window.onload=function() {
obj=document.getElementById('q');
obj.onclick=function() {
showAnswer();
}
}
function showAnswer() {

if(k==30){
k=1;
c=29;
if(n==qs.length-1) {
n=0;
}
else{
n++;
test=0;
clearTimeout(show);

setTimeout('obj.className=\'qc\';obj.firstChild.nodeValue=qs[n]',delay);
return;
}
}
if(c==0){
test=1;
k++;
obj.className='ac';
obj.style.height=k+'px';
obj.firstChild.nodeValue=as[n];
}
else{
if(test==0){
c--;
obj.style.height=c+'px';
}
}
show=setTimeout('showAnswer()',speed)
}

</script>

</head>
<body>

<h1 id="info">Click question to get an answer, there is then a predetermined delay before the next question.</h1>

<div id="q" class="qc">question 1</div>

</body>
</html>

farley89hd
12-13-2006, 04:36 PM
thanks coothead, i am saving that one should it ever be needed.

I don't think I can apply it, see I want it to flip and then hyper link to the site.

I was thinking of using it for buttons on my navagation bar.

coothead
12-13-2006, 04:55 PM
Hi there farley89hd,

correct me if I am mistaken but I thought that you wanted...

Questions and answers :supereek:
If you want links, then that is no problem, if we know exactly the way that it is required to work within this 'flipping' framework. ;)

npsari
10-07-2008, 05:26 PM
You can add an image behind the link
So, when the mouse comes over the link, the image shows

Here is the code
http://www.zortin.com/generators/link_image/

:cool: