/    Sign up×
Community /Pin to ProfileBookmark

Easy Positioning isn’t…

I know I’m doing something wrong here, and I’d be grateful for some eyes.
Here’s my code:

[code]
var example = document.createElement(“div”);
example.style.fontWeight = “bold”;
example.style.color = “red”;
example.style.background = “blue”;
example.style.height = “100px”;
example.style.width = “150px”;

// the following positioning items do NOT work!
example.style.left = “500px”
example.style.top = “100px”;

var newText = document.createTextNode(“New Text Here”);
var bodyName = document.getElementsByTagName(“body”).item(0);
example.appendChild(newText);
bodyName.appendChild(example);
[/code]

I get the text, the colors, the font-weight, the height and the width — but no positioning! It’s all on the top left of the screen.

What am I missing?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Daniel_TJul 22.2004 — Put this in right above the left and top poitioning attributes:
example.style.position = "absolute";
Copy linkTweet thisAlerts:
@llanitedaveauthorJul 22.2004 — D'OH!!!

tank u vewy much. I so embarrassed...
×

Success!

Help @llanitedave spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...