-1
"Window": {
    backgroundColor: '#fff'
},
"Label": {
    font: {
        fontSize: 32,
        fontWeight: 'bold'
    }
},
"Button": {
    width: '50%',
    height: Ti.UI.SIZE
},
".button": {
    randomProp: 'OK',
    top: window.height * somevalue;
}

How can i use my Window's Height to set to my button's top.

theJava
  • 14,620
  • 45
  • 131
  • 172

2 Answers2

0

You can access styling properties of an object through the .style attribute of the object. I.e:

mybutton.style.top = "10px";

Getting the windows current hight is trickier in pure JS, but the jQuery library does it with ease:

$( 'window' ).height();

If you don't want to use jQuery then here is how to do it with just JS: JavaScript - Get Browser Height

If your intent is achievable with just CSS and percent values that is the best way to go, but I assume you are trying to attach something that is going to float relative to window size, like a footer that is always in the bottom, which without some of the new CSS3 selectors can be a pain in CSS and probably should be solved in JS.

Community
  • 1
  • 1
Andreas Hagen
  • 2,335
  • 2
  • 19
  • 34
0

You don't need JavaScript for this.

You can use position: absolute; to set the position of your button relative to the viewport.

button {position: absolute; top: %/px;}

Here is your jsFiddle.

Jezen Thomas
  • 13,619
  • 6
  • 53
  • 91