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

  • SEARCH
  • Home
  • 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 728435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:40:52+00:00 2026-05-14T06:40:52+00:00

I have a box built via html borders. I want to connect the bottom

  • 0

I have a box built via html borders.

I want to connect the bottom left corner to the top right corner with a diagonal line. Either with html/css or by using a background image, doesn’t matter. I’ll figure that part out later.

------
-   /-
-  / -
- /  -
-/----

Here’s the tricky part: I want a different thing to happen depending on which side of the line the mouse is hovering over. I’ll do something like make some text visible or change the background color.

Is that possible in web programing? I’ve thought of doing a “Riemann sum” type calculation with a bunch of invisible divs. Any easier way?

Thanks!

  • 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-14T06:40:53+00:00Added an answer on May 14, 2026 at 6:40 am

    You need to get mouseX and mouseY positions, div bottom and left coordinates, and solve a simple linear equaion:

    y
    |   /
    |  / y &lt (imageHeight/imageWidth)*x
    | /
    |/
    /----------x
    
    

    code:

    
    function findPosX(obj)
      {
        var curleft = 0;
        if(obj.offsetParent)
            while(1) 
            {
              curleft += obj.offsetLeft;
              if(!obj.offsetParent)
                break;
              obj = obj.offsetParent;
            }
        else if(obj.x)
            curleft += obj.x;
        return curleft;
      }
    
      function findPosY(obj)
      {
        var curtop = 0;
        if(obj.offsetParent)
            while(1)
            {
              curtop += obj.offsetTop;
              if(!obj.offsetParent)
                break;
              obj = obj.offsetParent;
            }
        else if(obj.y)
            curtop += obj.y;
        return curtop;
      }
    //source: blog.firetree.net/2005/07/04/javascript-find-position/
    
    
    //definition of widths and heights:
    var imageWidth = [];
    var imageHeight = [];
    imageWidth["one"] = 100;
    imageHeight["one"] = 300;
    
    imageWidth["two"] = 200;
    imageHeight["two"] = 300;
    //etc
    
    
    function checkClick(divId) {
        var posx = 0;
        var posy = 0;
        var e = window.event;
        if (e.pageX || e.pageY) {
            posx = e.pageX;
            posy = e.pageY;
        }
        else if (e.clientX || e.clientY) {  
            posx = e.clientX + document.body.scrollLeft
                + document.documentElement.scrollLeft;
            posy = e.clientY + document.body.scrollTop
                + document.documentElement.scrollTop;
        }
        // source of mouse position: www.quirksmode.org/js/events_properties.html#position
    
        valX = posx - findPosX(document.getElementById(divId));
        valY = posy - (document.getElementById(findPosY(divId))+imageHeight[divId]); //we need to get the bottom-left corner
        if(valY &lt posX*imageHeight[divId]/imageWidth[divId]) {
        //we are below the line - in lower part of the div
        }
        else {
            //we are in the upper part
        }}
    
    

    And that’s it. You only need to add checkClick as handler of onmouseover and set imageWidth and imageHeight

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

Sidebar

Related Questions

I have a list box built like so... @Html.ListBoxFor(model => model.SelectedCalendarId, Model.PeriodList) and have
I have a box container as shown bellow Which i want to code in
I have built an executable which launches a dialog box in which is embedded
I have built an application which sends SMS messages via Java, but I am
I have a combo box in Silverlight. It has a collection of values built
Anyone have GWT 1.6.4 running on FreeBSD? Our build server is a FreeBSD box,
I have text box to enter a phone number. I'm using AJAX MaskedEditExtender and
I have text box in which your adds values in comma separated values. Once
I have a box of selectors all sharing the class. widgetContainer can hold 3
Okay so I have a box that I made in CSS and what 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.