Questions tagged [offsetwidth]

52 questions
1
vote
0 answers

I would like to set the size of the text to be dynamic/flexible depending on the window size with Javascript

I am trying to set the size of the text to be responsive to the window width. I am using this script flexFont = function () { var divs = document.getElementsByClassName("flexFont"); for(var i = 0; i < divs.length; i++) { var…
1
vote
3 answers

OffsetWidth is always '0'

I'm stuck with something, while creating something. I want to set div's width and height to the same. So, I set div's width to 14% and the height of the div to the offsetWidth. So the div will be fully square in shape. But, offsetWidth is always 0.…
1
vote
2 answers

Test DOM Element offsetHeight & offsetWidth efficiently, without attaching

I have the need to test the offsetWidth and offsetHeight of an element. Presently, the element is attached and then the offsetWidth and Height are tested, after which the element is remove. It looks like this: var sizer =…
hrdwdmrbl
  • 4,814
  • 2
  • 32
  • 41
1
vote
0 answers

ie7 clientWidth and clientHeight problems

I've tried to get the offsetWidth and offsetHeight properties like so:
alert(document.getElementById('somediv').offsetWidth); Unfortunately, on IE7 offsetWidth only…
Marius
  • 3,976
  • 5
  • 37
  • 52
1
vote
2 answers

Observe size change of element

This is not a duplicate! I'm not satisfied with the result of other answers. If you still think it is a duplicate, please comment it before why you think it is! I have to observe size changes of elements. I've tried to do it by creating a setter on…
blaumeise20
  • 2,148
  • 8
  • 26
1
vote
0 answers

Wait on element resize done after changing width trough renderer

Is there a way to detect when an html element (native element) is done with resizing after the style: width property has been changed trough the use of the angular renderer2? I have currently implemented a font sizing system based on the width of…
1
vote
1 answer

Why am I getting a cannot read property message in my console when I try to use children property and offsetWidth?

I am new to coding and programming and I have been following, on Youtube, a screen recording of a programmer making a responsive thumbnail slider using HTML, CSS, and Javascript. I've gotten to a point where I am trying to check if my Javascript was…
1
vote
2 answers

Why is my clientWidth and offsetWidth equal?

var mydiv = document.getElementById("mydiv"); console.log("offset width = " + mydiv.offsetWidth); console.log("client width = " + mydiv.clientWidth); #div1 { height: 5000px; width: 5000px; background-color: #000000; }
Normajean
  • 1,075
  • 3
  • 11
  • 28
1
vote
1 answer

How to get only Visible Elements using document.getElementsByTag and document.queryselectAll

I am trying to create a chrome extension that will search for any elements from the web-page. Currently i am using, var elm = document.getElementsByTagName("input"); This gives me all the elements with tag input. But sometimes the element is not…
1
vote
0 answers

How to get offsetWidth of Polymer Component

I'm trying to get the offsetWidth of two custom components inside of another component. Everything I've tried returns a value of 0. The information I need doesn't seem to be ready during the attached phase of the life cycle. One approach may be…
ChoKim
  • 196
  • 1
  • 6
1
vote
3 answers

Why does the string not moving within the certain interval?

I am trying to make a simple code of a line moving 1px every 20 milliseconds (smt like a ticker) . Also, want it to disappear once it reaches the edge of the browser window using .offsetWidth property. Unfortunately, I'm stuck and I don't know why…
Ani
  • 57
  • 1
  • 1
  • 7
1
vote
4 answers

offsetWidth or CSS expression problem for IE6

I need to set the width of textboxes as 80% of it's parent. So first I used td input[type="text"] { width: 80%; } But it was not rendering properly if the input is the child of td. So, I used Css expressions td input[type="text"] { …
Bipul
  • 1,327
  • 4
  • 16
  • 33
1
vote
1 answer

when is the proper time to call UIObject.getOffsetWidth?

i want get the uiobject's offsetwidth in gwt. but this value depends: where the uiobject attached or not? where relative css loaded or not? uiobject's size may be modified in onload callback. ... so, things get complicate, especially when you want…
turtledove
  • 25,464
  • 3
  • 23
  • 20
1
vote
1 answer

how do I make my submenu position dynamic based on the distance to the edge of the window?

I'm trying to write a jQuery script that will find the distance to the right edge of the browser window from my css class element and then position the child submenu dropdowns to the right or left depending on the available space to the right. Also…
0
votes
0 answers

div element showing same offSetWidth value with or without scrollbar

I tried to calculate offSetWidth of a div element which has the following css properties: 1)Height:500px 2)overflow:auto 3)dir:rtl 4)box-sizing:border-box I added less content in the div so that the div does not show any scroll and used offSetWidth…