Skip to main content
GameDev.net gamedev.net
🔒 Locked

[web] I hate CSS

Started by Daniel Miller Feb 26, 2007 at 8:04 PM 9 replies 1.4k views
Original Post
Daniel Miller
Daniel Miller
I want center align my entire site. However, that being done, I want to position a div at a specific pixel position relative to the centered location of the site (if that makes any sense). Is it possible to do without using a background? In other words... how can I put a div "inside" of an image?
Daniel Miller
Daniel Miller
No, it's my post that doesn't make any sense, thanks for trying to help. :P

I want all of the content to be centered horizontally. Now, in that content:

I want to have an image with a div full of text overlapping it at a specific set of coordinates. I don't want the coordinates to be absolute to the entire page though, I want them to be absolute to the content of the site (which so happens to be centered).

In other words, I want a div with some text to be at (100, 100) relative to the top left corner of the image, and I want both the text and the image to be inside of another div (the content div) which is centered horizontally on the page. If that still doesn't make any sense, just tell me (because it probably doesn't).
swordfish
swordfish
Quote:
In other words, I want a div with some text to be at (100, 100) relative to the top left corner of the image, and I want both the text and the image to be inside of another div (the content div) which is centered horizontally on the page. If that still doesn't make any sense, just tell me (because it probably doesn't).


So you need to know how to do 2 things:

1) center a div horizontally on the page
2) put text at 100,100 relative to the top left of an image
3) put #2 inside of #1

Right?

I'm not sure about the exact solution, but I'm sure it has something to do with 'inline display', 'absolute positioning', 'float-ing', and/or 'margins'. Did you check Google?

A solution that comes to mind would be something like:

[edit]nevermind that doesn't work
http://blog.protonovus.com/
Colin Jeanne
Colin Jeanne
Also, if you choose to make the image the background of a div which contains the text you might find that (2) will be straightforward.
Daniel Miller
Daniel Miller
OK, thanks for your replies everyone!

AP (too bad I can't rate you up): When I do that, the text simply does not move with the containing div.

<img src="http://*****/top.png" width="800" height="400" alt="top pic" />
Prelaunch - February 28
Launch - March 2

div.maintext{	left:240px;	top:280px;	position:absolute;}div.site{	background-repeat:no-repeat;	margin-left:auto;	margin-right:auto;	width:800px;	height:400px;}


The "site" div centers fine, but the text is positioned absolute to the page. When I use the image as a background and use relative positioning for div.maintext, it works fine.

++ratings
Colin Jeanne
Colin Jeanne
I would use CSS to make http://*****/top.png a background image of the class "site". From there, I believe you can make class "maintext" have position : relative and life should work out.
Daniel Miller
Daniel Miller
Quote:
Original post by Colin Jeanne
I would use CSS to make http://*****/top.png a background image of the class "site". From there, I believe you can make class "maintext" have position : relative and life should work out.


Yes, it does work, but I was hoping to avoid that. That's what I'll do though. Thanks for your answers! :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.