Bill Lumbert
Bill Lumbert

Reputation: 5013

Specify position of elements, React-Bootstrap

I am new to JS world and stuck with this, probably, simple problem: I want to specify position of the element that will be added to another element and I want to set position in the app, but not in .css.

Now I have

var obj = DOM.div({className: 'testPlace'},
             React.createElement("a", {id: 'testPlace'},".")
         );

and in .css

div.testPlace {  position: absolute;
                    right: 50px;
                    bottom: 100px;
                }

I want to set parameters for right and bottom inside of the app, not in .css. How can I do this ?

Thanks!

Upvotes: 1

Views: 3801

Answers (1)

adrield
adrield

Reputation: 625

In ReactJS, you can set this while creating the element, as shown here:

It would be:

React.createElement("a", {style: {position: "absolute", right: "50px", bottom: "100px"}}, {id: 'testPlace'},".")


In plain Javascript, you can set the properties as:

element.style.right = "50px";

element.style.bottom = "100px";

Upvotes: 1

Related Questions