dangercrow Posted January 21, 2010 Share Posted January 21, 2010 I want to get some text to be centered within a DIV, but for the DIV itself to be on the left side of the page. Server time:<br />08:40:20PM<br />on the<br />21/01/2010 Is what I have atm...Can someone help please?Thanks Link to comment Share on other sites More sharing options...
Ingolme Posted January 21, 2010 Share Posted January 21, 2010 Add text-align: center; to the CSS of the <div> Link to comment Share on other sites More sharing options...
dangercrow Posted January 21, 2010 Author Share Posted January 21, 2010 dont wanna do CSS can you paste a bit of CSS that i can shove at the top then?Thanks though Link to comment Share on other sites More sharing options...
Ingolme Posted January 21, 2010 Share Posted January 21, 2010 You really should learn CSS, without it, your page won't look any better than pages did in the 90s.Considering that you say the <div> is on the left, I was supposing you were already using CSS to begin with. Link to comment Share on other sites More sharing options...
jeffman Posted January 21, 2010 Share Posted January 21, 2010 Not learning CSS is like not learning pizza. All you have left is bread.Try these two pages. One demonstrates text alignment. The other discusses different kinds of selectors you can use. They're all you need to solve this particular problem. Experiment with the try-it pages. Fun and easy.http://www.w3schools.com/css/tryit.asp?fil..._text-align_allhttp://www.w3schools.com/css/css_id_class.asp Link to comment Share on other sites More sharing options...
dangercrow Posted January 22, 2010 Author Share Posted January 22, 2010 Ok, I have this: <div style="text-align: center;" id="time">Server time:<br />05:33:58PM<br />on the<br />22/01/2010</div> but the i need the div to act like a textbox, so the text is on the left, but it lines up with the lines above and below Link to comment Share on other sites More sharing options...
Ingolme Posted January 22, 2010 Share Posted January 22, 2010 You just said you wanted the text to be centered. You can have the text centered and left-aligned at the same time. I can't imagine what you want. Link to comment Share on other sites More sharing options...
thescientist Posted January 22, 2010 Share Posted January 22, 2010 maybe he means vertical alignment? Link to comment Share on other sites More sharing options...
jeffman Posted January 22, 2010 Share Posted January 22, 2010 Post a link to your site. Maybe we can see what is wrong. Or just draw a picture. Link to comment Share on other sites More sharing options...
dangercrow Posted January 23, 2010 Author Share Posted January 23, 2010 basically, my web page is locally hosted only atm, and is not on the web, but heres a pic:http://sites.google.com/site/dangercrow/untitled.gifwhat i want is the div on the left, but the text in it contained to be center aligned, as below:____________________________________|the form |submit |..................................||________|______|..................................||.Server time:..........................................||...12:00:00.............................................||......on the..............................................||...1/11/2011 ..........................................||.............................................................||.............................................................||___________________________________|so that the div is kind of contained, like a table.I tried using a table, but couldnt get it to work... any help appreciated Link to comment Share on other sites More sharing options...
jeffman Posted January 23, 2010 Share Posted January 23, 2010 To center the text in the div, use text-align:center on the div, as Ingolme posted before.The default position of a div is on the left. But you're having problems getting it on the left?Does it have a float property? Is it inside a container that centers it or has a lot of padding on the left side?Does the div itself have padding or margin that keeps its content from appearing on the left?I don't think you've mentioned yet what the div is doing that you don't want it to do. I know it's supposed to go on the left. Where is it now? Link to comment Share on other sites More sharing options...
Ingolme Posted January 24, 2010 Share Posted January 24, 2010 If you haven't given the <div> a width, it will take the whole width of the page. Just add something like width: 200px; to the <div> and you'll see that it goes to the left while the text in it stays centered. Link to comment Share on other sites More sharing options...
dangercrow Posted January 24, 2010 Author Share Posted January 24, 2010 Thanks Ingolme, that's fixed it! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.