/    Sign up×
Community /Pin to ProfileBookmark

position something relative inside a div?

hey, ive got a main container div. how can i position something in there relative to the container like its 1024 pixels wide. how could i make something like 150 pixels to the left and 150 pixels from the top?

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJan 18.2006 — <i>
</i>margin-left: 150px;
margin-top: 150px;
Copy linkTweet thisAlerts:
@ray326Jan 19.2006 — Here's an illustrative snippet.
[code=html]
#main {
width:400px;
height: 500px;
margin: 250px auto;
background: #ff4;
position: relative;
}
#child {
width: 50px;
height: 50px;
background: #833;
position: absolute;
top: 100px;
left: 200px;
}
</style>
<script type="text/javascript">
</script>
</head>
<body>
<div id="main">
<div id="child"></div>
</div>
[/code]
×

Success!

Help @welsh 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.6,
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,
)...