I am new to Javascript and relatively new to HTML. I would like to know which language (pure html or Javascript and html) that I should use, and some algorithm suggestions to do the following:
Place 4 squares on the background, but place them diagonally. Each square is a link that you can click to go to another page. So, how could I arrange the html elements diagonally, as shown in the image below?
http://i54.tinypic.com/2v7uw5u.png
I believe my code would look like this:
<script>
function positionIt()
{
var screenW =
var screenH =
var sq1 = document.getElementById( "square1" );
var sq2 = document.getElementById( "square2" );
var sq3 = document.getElementById( "square3" );
var sq4 = document.getElementById( "square4" );
sq1.setXPos( screenW / 4 );
sq1.setYPos( screenH / 4 );
sq2.setXPos( screenW / 3 );
sq2.setYPos( screenH / 3 );
}
</script>
// OR if I use css
.menu { background-color: blue; }
/* Position the square in absolute terms diagonally */
#square1 { x=200; y=200; }
#square2 { x=300; y=300; }
#square3 { x=400; y=400; }
#square4 { x=500; y=500; }
<div class="menu" onload="positionIt()">
<a id="square1" href="home.html"><img src="square.jpg" /></a>
<a id="square2" href="home.html"><img src="square.jpg" /></a>
<a id="square3" href="home.html"><img src="square.jpg" /></a>
<a id="square4" href="home.html"><img src="square.jpg" /></a>
</div>
source
share