Questions tagged [offsetwidth]
52 questions
9
votes
1 answer
DOM element width can be non-integer?
I have some one page whose div elements are aligned by JavaScript. The JavaScript just check a set of div elements to find the max offsetWidth, then set all div elements' width to be the max offsetWidth. It works perfect in most browsers and…

Morgan Cheng
- 73,950
- 66
- 171
- 230
7
votes
1 answer
offsetHeight and offsetWidth calculating incorrectly on first onclick event, not second
I have written the following script to display a hidden element, then fix it's position to the center of the page.
function popUp(id,type) {
var popUpBox = document.getElementById(id);
popUpBox.style.position = "fixed";
popUpBox.style.display =…

saoyr5
- 111
- 1
- 2
- 11
5
votes
2 answers
IE 8 Quirks vs Standards retrieving offsetHeight/offsetWidth
I am in the process of converting my application to use XHTML strict mode (it didn't have a DOCTYPE before). However, I noticed a significant degradation when getting offsetHeight/offsetWidth. This is very noticeable on pages with large number of…

Paul
- 209
- 1
- 4
- 9
5
votes
1 answer
Javascript offsetWidth returning undefined
I have a JS function that gets the width of a div on my page:
function getWidth() {
var container = document.getElementsByClassName('tag');
var message = "The width of the contents width padding: " + container.width + "px.\n";
…

chazbot7
- 598
- 3
- 12
- 34
5
votes
3 answers
offsetWidth is returning incorrect value
Okay so I'm attempting to make a horizontal site but when I try getting the offsetWidth of the navigation, it returns a value far higher than the true width. The design in question can be found here. The CSS for the page is here and the JS…

Jordan Adams
- 434
- 1
- 8
- 18
4
votes
1 answer
document.querySelector(...).offsetWidth returns null in Firefox
I use the following code in my javascript (coffeescript) file:
myVar = document.querySelector('SVG > a:nth-child(2) > text').offsetWidth
In google chrome this returns the width of a the text element which is nested inside an a (anchor) element…

torvum
- 71
- 6
4
votes
2 answers
Efficient way to measure longest cell in table column
I am trying to determine the widest content in HTML table cells of fixed width. Currently I am using an external sizer DIV:
in this code
var iColWidth =…

Yuriy Galanter
- 38,833
- 15
- 69
- 136
3
votes
1 answer
Why are offsetHeight and offsetWidth intermittently inaccurate?
I've been noticing that, at least in Firefox (haven't tested extensively in other browsers yet), the offsetHeight and offsetWidth properties on a
might be off by one pixel. (And yes, I'm already accounting for borders, padding, and margin.)…

soapergem
- 9,263
- 18
- 96
- 152
3
votes
1 answer
Why is the element width not matching offsetWidth?
I tried to get the element width using nativeElement.offsetWidth but it's 2.5px lesser than the actual width. I was wondering what I'm missing?
I tried to inspect the DOM and try to find where the 2.5px but I cant find it anywhere:
export class…

Magikarp
- 492
- 6
- 19
3
votes
1 answer
offsetWidth in ff differs from actual elements width
Somehow I get different results for offsetWidth in Firefox and Chrome.
I got a simple button
which's offsetWidth is exactly 89 Pixels. Chrome says so and Photoshop…

ProblemsOfSumit
- 19,543
- 9
- 50
- 61
2
votes
1 answer
How to write unit test case for element[0].offsetWidth in angularJS
For custom directive, how to mock values for offset width and scroll width? By default its taking as 0.
link: function(scope, element, attr){
element.bind('click',function(){
if (element[0].offsetWidth <…

user3619841
- 59
- 4
2
votes
1 answer
How to fix a Bootstrap Carousel 'offSetWidth' error
I'm using bootstrap carousel to slide through data I'm bringing in from an external API. The first element in the API array shows up on the carousel, but when I press a 'next' or 'prev' arrow button, the screen blinks and I get this error: Uncaught…

just another profile name
- 722
- 1
- 9
- 31
2
votes
1 answer
offsetWidth returns unknown value (JS)
I have one linked css file for default properties and a second one for the news that it changes when the wiewport is changed. At the end of the JS script I puted an element's offsetWidth in the global value NavW. So JS seems to returns the wrong…

FlowHoa
- 75
- 7
1
vote
2 answers
Table Column Width Matching
UPDATE: Solution found
UPDATE: No proposed answers. No solution found on my end. Anybody?
I am using javascript to match the width of columns in two seperate tables (using this to create a scrollable, sticky header table. If the data is all visible…

steventnorris
- 5,656
- 23
- 93
- 174
1
vote
0 answers
Javascript table column width
I have a header table and a data table that need to match up. Currently, I am attempting to grab the first row of each table, get those cells, cycle over each cell, determine which width is the longest, and set the width of the other cell based on…

steventnorris
- 5,656
- 23
- 93
- 174