Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4013334
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:21:31+00:00 2026-05-20T09:21:31+00:00

I am new to Javascript & relatively new to HTML. I would like to

  • 0

I am new to Javascript & relatively new to HTML. I would like to know what language(pure html or Javascript & html) I should use & some suggestions of an algorithm in order to do the following:

Place 4 squares on a background but position them diagonally. Each square is a link you can click to go to a different page. So how would I be able to position html elements diagonally like my picture below?

http://i54.tinypic.com/2v7uw5u.png

I believe my code would look like this:

<script>
    function positionIt()
    {
        var screenW = // javascript function to get screen width??;
        var screenH = // javascript function to get screen height??;

        var sq1 = document.getElementById( "square1" );
        var sq2 = document.getElementById( "square2" );
        var sq3 = document.getElementById( "square3" );
        var sq4 = document.getElementById( "square4" );

        // What javascript functions set a elements x,y positions?
        // Should I use another way of positioning the square (not by absolute terms)
        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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:21:32+00:00Added an answer on May 20, 2026 at 9:21 am

    Live Demo
    Live Demo (with left properties order changed to match your mockup)

    I tried to keep to the numbers you asked for.

    HTML:

    <div class="menu">
        <a id="square1" href="home.html"><img src="http://dummyimage.com/100/f90/fff" /></a>
        <a id="square2" href="home.html"><img src="http://dummyimage.com/100/f90/fff" /></a>
        <a id="square3" href="home.html"><img src="http://dummyimage.com/100/f90/fff" /></a>
        <a id="square4" href="home.html"><img src="http://dummyimage.com/100/f90/fff" /></a>
    </div>
    

    CSS:

    .menu {
        background: blue;
        width: 800px;
        height: 800px;
        position: relative
    }
    /* Position the square in absolute terms diagonally */
    #square1 { position:absolute; left:200px; top:200px; }
    #square2 { position:absolute; left:300px; top:300px; }
    #square3 { position:absolute; left:400px; top:400px; }
    #square4 { position:absolute; left:500px; top:500px; }
    

    How does this work? See: http://css-tricks.com/absolute-positioning-inside-relative-positioning/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm absolutely new to JavaScript and would like to modify a textarea of a
I am relatively new to javascript and I am facing some difficulty.I have two
i'm new to javascript, and I would like to retrieve values from JSON and
I'm relatively new to Javascript and was wondering if there's a quick way to
Being fairly new to JavaScript, I'm unable to discern when to use each of
I'm new to javascript/jquery and I've done some poking around the web, but I
I'm very new to javascript & jQuery, and can't work out how to do
I'm trying to create a robust audio player in javascript (& jQuery). I know
I am relatively new to javascript. I am trying to code my web version
I am very new in JavaScript world. function ButtonClickAction2 (zEvent) { self.location=xxx.asp?action=go&Locale=2; } I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.