This is a discussion on "Div Alignment" within the Web Page Design section. This forum, and the thread "Div Alignment are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
Div Alignment
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Hey, Im working with CSS to code all my div layers, and I am wondering how I can specifically position my divlayers through CSS. I cant figure it out, nor can I find it on any of my "educational" websites for webdesign. Can someone help me out?
|
|
|
|
#2
|
||||
|
||||
|
Re: Div Alignment
These examples will help you out:
float: left; float: right; position: absolute top: 200px; position: absolute: left: 90px bottom: 0; position: absolute; right: 50%; |
|
#3
|
|||
|
|||
|
Re: Div Alignment
Wow! Thanks a lot! Thats exactly what I needed!
|
|
#4
|
||||
|
||||
|
Re: Div Alignment
No problem. Here's a full reference of all the CSS properties:
http://www.w3schools.com/css/css_reference.asp |
|
#5
|
|||
|
|||
|
Re: Div Alignment
Don't forget position:relative; etc..
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
|
|
#6
|
|||
|
|||
|
Re: Div Alignment
I just needed to know that float is the command, and a few examples. Thanks for all the help guys! Ill be back later for more help I'm sure :P
|
|
#7
|
|||
|
|||
|
Re: Div Alignment
Let me bring the thread back to life for a second. Let me make sure what I am doing wrong here, and hopefully Ill understand! This is the Index file right here...
Quote:
Quote:
Its the Div command Im using thats not working. It dosnt look like I am having any control over my Div propertys at all. How can I pull this stuff off? |
|
#8
|
|||
|
|||
|
Re: Div Alignment
Your mistake is in this syntax here:
|
|
#9
|
|||
|
|||
|
Re: Div Alignment
Heh. Thanks! I shoulda known better.
|
|
#10
|
|||
|
|||
|
Re: Div Alignment
Alright I have a new problem. The code that positioned the layer didnt work entirely. I could swap out the colors and stuff, but its not allowing a border to show at all, and its not positioning to the center properly. Wouldnt that right 50% command do that for me?
|
|
#11
|
|||
|
|||
|
Re: Div Alignment
No. What that is saying is position the element (its right side) 50% of the window width from the right-hand side of the window. To position something in the centre, you nedd to use the margin: auto; instruction. You can set various combinations such as margin: auto auto; which will centre top to bottom as well. You can also use fixed measurements for say top to bottom and auto for side to side. Have a play. WARNING: IE 6 doesn't do this properly but it is fixed in IE7 we are told! To get round this, you need to give the div containing the one you wish to centre the attribute definition; text-align: center; As this has a ripple down effect, you will need to compansate for this by using text-align: left; at the next level in. |
|
#12
|
|||
|
|||
|
Re: Div Alignment
Alright now, I hate to keep coming back to you, but its helping, so if you would still hang in here with me it would be MUCH appreciated.
Your margin:auto worked great, but now I need to pull it down from the top a bit. What should I do about this. I have an idea that I should probably just use the .main div to hold many other divs inside, and use that as a template, but is there a better way? I also noticed that the way I have my background set up... Quote:
|
|
#13
|
||||
|
||||
|
Re: Div Alignment
This is CSS shorthand:
|
|
#14
|
|||
|
|||
|
Re: Div Alignment
That works great! I can now write freehand. Didnt know about it. Dreamweaver also supports it in its auto writing stuff, so that helps a lot!
How does that "0 20px" thing work? Does it have a special order to it, or am I not seeing it? Ah! Im also answering a few of my own questions myself. I think I am getting the hang of this! So far so good Last edited by escaflowne11; Sep 6th, 2006 at 04:13. |
|
#15
|
||||
|
||||
|
Re: Div Alignment
The order is left top. If you used 20px 50%, it would put the background image 20 pixels from the left and vertically centered.
|
|
#16
|
||||
|
||||
|
Re: Div Alignment
Oh, most sites use top left as a designation (top, right, bottom and left are also valid positons), but this is wrong it should be left top. I've always found it easier to use pixels and percentages though, plus it reminds the coder of the proper order. Right bottom would be 100% 100%, whereas left top would be 0 0, 0px 0px or 0% 0%.
|
|
#17
|
||||
|
||||
|
Re: Div Alignment
first number is horizontal, second is vertical. Usually you will designate it, because you can push it from the other direction, e.g. position: relative; bottom: 10px; right 9px;
|
|
#18
|
|||
|
|||
|
Re: Div Alignment
Here is the code I have right now, and now for the problems I ran acrossed yet again. Thanks for getting me so far in this, I hope I can repay the favor later on!
Quote:
Quote:
If you want to see the style I am aiming for check out the old, trashy site. http://www.scoffshop.com Thanks! |
![]() |
| Tags |
| div, alignment |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| DIV alignment help | ||||