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 8917615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:31:58+00:00 2026-06-15T05:31:58+00:00

I have to position a popup element dynamically inside a container. I’m trying to

  • 0

I have to position a popup element dynamically inside a container. I’m trying to get the border width of the container. I’ve found several questions like this one:

How to get border width in jQuery/javascript

My problem has been discussed but I haven’t found any answers. How do you get the border width when the property is thick, thin, or medium?

There’s word on the street that you can usually expect thin, medium, and thick to be 2px, 4px, and 6px respectively, but the CSS spec doesn’t require that.

Has anyone run across an easy (or if not easy at least consistent) way to get the width of the border on one edge of a DOM element?

  • 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-06-15T05:31:59+00:00Added an answer on June 15, 2026 at 5:31 am

    I played around with this for a little longer and the only solution I was able to come up with which would kind-off sort out the issue is similar to this:

    var thinBorder = 1;
    var mediumBorder = 3;
    var thickBorder = 5;
    
    function getLeftBorderWidth($element) {
        var leftBorderWidth = $element.css("borderLeftWidth");
        var borderWidth = 0;
    
    
        switch (leftBorderWidth) {
        case "thin":
            borderWidth = thinBorder;
            break;
        case "medium":
            borderWidth = mediumBorder;
            break;
        case "thick":
            borderWidth = thickBorder;
            break;
        default:
            borderWidth = Math.round(parseFloat(leftBorderWidth));
            break;
        }
    
        return borderWidth;
    }
    
    function getRightBorderWidth($element) {
        var rightBorderWidth = $element.css("borderRightWidth");
        var borderWidth = 0;
    
    
        switch (rightBorderWidth) {
        case "thin":
            borderWidth = thinBorder;
            break;
        case "medium":
            borderWidth = mediumBorder;
            break;
        case "thick":
            borderWidth = thickBorder;
            break;
        default:
            borderWidth = Math.round(parseFloat(rightBorderWidth));
            break;
        }
    
        return borderWidth;
    }​
    

    DEMO

    Note the Math.round() and parseFloat(). Those are there because IE9 returns 0.99px for thin instead of 1px and 4.99px for thick instead of 5px.

    Edit

    You mentioned in the comments that IE7 has a different size for thin, medium and thick.
    They seem to be off by only .5px which will be hard to deal with, seeing you most liekly need full numbers.

    My suggestion would be to either simply ignore the .5px of a difference and acknowledge the most likely unnoticable imperfections when using IE7 and lower or if you are hell-bend on dealing with it to adjust the constants by that much similar to:

    var thinBorder = 1;
    var mediumBorder = 3;
    var thickBorder = 5;
    
    // Will be -1 if MSIE is not detected in the version string
    var IEVersion = navigator.appVersion.indexOf("MSIE");
    
    // Check if it was found then parse the version number. Version 7 will be 17 but you can trim that off with the below.
    If(IEVersion > -1){
        IEVersion = parseInt(navigator.appVersion.split("MSIE")[1]);
    }
    
    // Now you can simply check if you are in an ancient version of IE and adjsut any default values accordingly.
    If(IEVersion < 7){
        thinBorder = 0.5;
        mediumBorder = 3.5;
        thickBorder = 4.5;
    }
    
    /// rest as normal
    

    Any of the above is by no means a copy-paste solution but merely a demonstration on a few ways one could deal with this issue. You would naturally wrap all those helpers into separate functions, plug-ins or extensions.

    In your final solution you might even still need to deal with float off-sets and rounding issue.

    This should be able to get you started though well enough.

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

Sidebar

Related Questions

I'm currently trying to position a popup window dynamically on screen based on an
I'm trying to place a button. I have its position set to absolute, so
I have a simplr svg-graph and I'm trying to create a simple tooltip-popup for
Hi I have been trying to get this script http://jsbin.com/ipajo5/ working but using .live()
I have an article container which has three aside tags inside it. The third
I have a tray icon with a popup menu. I am trying to set
I'm trying to create a simple modal popup. I have the CSS done, and
So currently I have: #div { position: relative; height: 510px; overflow-y: scroll; } However
Imagine you are simulating particle physics. You, then, have a position vector for each
I have a large array called data. At the 10th array position i have

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.