Heya people!
Just a small problem here.
I am trying to align some text in a div so that there is a main part to it, and it has a sub part attached to it within another div which is attached to a JS action that fades it in and out when a "X" is pressed.
The JS and everything works fine, but when I put the sub part within the div it aligns it a line down, not next to the main part. I would just like to know why it is doing this, as I see no line break tags around.
I fixed the alignment using the "display:inline;" style, but now the JS function has been disabled.
Any suggestions?
Cheers
html
Quote:
<body>
<div id="container">
<div id="cross">
<a href="#" onclick="fade('fadeBlock');" >X</a>
</div>
<div id="left">
<div class="line1">
Helvetica <div id="fadeBlock" class="size1" > at 60pt</div>
</div>
</div>
</div>
</body>
|
css
Quote:
*
{
margin:0;
padding:0;
background-color:#000000;
}
a
{
text-decoration:none;
color:#ffffff;
font-family: Helvetica, Arial, sans serif;
font-size: 30px;
}
#container
{
color:#ffffff;
font-family: Helvetica, Arial, sans serif;
font-weight:900;
}
#cross
{
text-align:right;
padding-right:10px;
}
#left
{
padding-left:50px;
}
.line1
{
font-size:60pt;
width:700px;
}
div#fadeBlock
{
display:inline;
}
.size1
{
width:500px;
height:100px;
}
|
js
Quote:
var TimeToFade = 1000.0;
function fade(eid)
{
var element = document.getElementById(eid);
if(element == null)
return;
if(element.FadeState == null)
{
if(element.style.opacity == null
|| element.style.opacity == ''
|| element.style.opacity == '1')
{
element.FadeState = 2;
}
else
{
element.FadeState = -2;
}
}
if(element.FadeState == 1 || element.FadeState == -1)
{
element.FadeState = element.FadeState == 1 ? -1 : 1;
element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
}
else
{
element.FadeState = element.FadeState == 2 ? -1 : 1;
element.FadeTimeLeft = TimeToFade;
setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "')", 33);
}
}
function animateFade(lastTick, eid)
{
var curTick = new Date().getTime();
var elapsedTicks = curTick - lastTick;
var element = document.getElementById(eid);
if(element.FadeTimeLeft <= elapsedTicks)
{
element.style.opacity = element.FadeState == 1 ? '1' : '0';
element.style.filter = 'alpha(opacity = '
+ (element.FadeState == 1 ? '100' : '0') + ')';
element.FadeState = element.FadeState == 1 ? 2 : -2;
return;
}
element.FadeTimeLeft -= elapsedTicks;
var newOpVal = element.FadeTimeLeft/TimeToFade;
if(element.FadeState == 1)
newOpVal = 1 - newOpVal;
element.style.opacity = newOpVal;
element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';
setTimeout("animateFade(" + curTick + ",'" + eid + "')", 33);
}
|