So, I have tried to add the "SOLD!" sign across the diagonal of my house-selling web-page. Here is what I tried.
HTML:
CSS:
JavaScript:
I haven't yet managed to sell my house. My mother keeps insisting that the real price is 45'000 euros, even though I think houses like that are usually sold at around 30'000 euros.
But, anyway, what I have done now works in Firefox when run on my laptop, however, for some reason, it moves away from the diagonal as I resize the window. Can you find the error?
You can see my house-selling web-page here (the "display" of that "span" is set to "none" instead of to "block").
HTML:
Code:
<span id="prodano">PRODANO! - SOLD!</span>
Code:
#prodano
{
background-color:#FF7777;
color:#000077;
font-size:36px;
line-height:50px;
position:fixed;
display:none; /*Has not yet been sold!*/
text-align:center;
}
Code:
document.body.onresize=function()
{
var content=document.getElementById("content");
var sirinaProzora=(window.innerWidth || //Moderni internetski preglednici
document.documentElement.clientWidth || //Internet Explorer 8
document.body.clientWidth //Internet Explorer 6
);
var visinaProzora=(window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight);
content.style.left=sirinaProzora/2-content.clientWidth/2+"px";
var prodano=document.getElementById("prodano");
var sirinaNatpisaProdano=Math.sqrt(Math.pow(sirinaProzora,2)+Math.pow(visinaProzora,2))+2*50;
prodano.style.width=sirinaNatpisaProdano+"px";
var nagibNatpisaProdano=Math.atan2(visinaProzora,sirinaProzora);
prodano.style.transform="rotate("+nagibNatpisaProdano+"rad)";
var yKoordinataNatpisa=(visinaProzora/2-Math.cos(nagibNatpisaProdano)*50);
prodano.style.top=yKoordinataNatpisa+"px";
prodano.style.left=-(Math.sin(nagibNatpisaProdano)*yKoordinataNatpisa)+"px";
}
window.onresize=document.body.onresize;
window.onload=document.body.onresize;
But, anyway, what I have done now works in Firefox when run on my laptop, however, for some reason, it moves away from the diagonal as I resize the window. Can you find the error?
You can see my house-selling web-page here (the "display" of that "span" is set to "none" instead of to "block").