CSS - Centring Text
Similar Tutorialshello guys, I am creating a webpage using CSS for my layout. when I look at the page, it seems ok but all my "DIV" are positoned relative to the left side of the screen. so if you maximize the screen, you get a huge space on the far right side of the screen. I was wondering if there is anyway I can centre the page in the window no matter the size of the screen. I have provided a link to a version of the page and the CSS file is included here. each id represents a DIV in the design. http://www.radien.plus.com/test.html thanks guys Code: #Logo { Margin : 0; Padding : 0; Width : 125px; Height : 125px; Border-color : aqua; Border-top-width : medium; Border-right-width : medium; Border-bottom-width : medium; Border-left-width : medium; Border-top : 1px solid#00; Border-bottom : 1px solid#00; Border : 1px solid#00; Border-left : 1px solid#00; Border-right : 1px solid#00; } #news { Font-family : Arial , Helvetica , Sans Serif; Font-size : 80%; Font-weight : normal; Margin : 0; Border-top-width : medium; Border-right-width : medium; Border-bottom-width : medium; Border-left-width : medium; Width : 150px; Height : 250px; position : absolute; top : 140px; Padding : 3; Margin-top : 0; Text-indent : 3px; Border-top : 1px solid#00; Border-right : 1px solid#00; Border : 1px solid#00; Border-left : 1px solid#00; Border-bottom : 1px solid#00; } #Products { Font-family : Arial , Helvetica , Sans Serif; Font-size : 80%; Font-weight : normal; Margin : 0; Border-top-width : medium; Border-right-width : medium; Border-bottom-width : medium; Border-left-width : medium; Width : 150px; Height : 200px; position : absolute; top : 397px; Padding : 3; Margin-top : 0; Text-indent : 3px; Border-top : 1px solid#00; Border-right : 1px solid#00; Border : 1px solid#00; Border-left : 1px solid#00; Border-bottom : 1px solid#00; } #unknown { Font-family : Arial , Helvetica , Sans Serif; Font-size : 80%; Font-weight : normal; Margin : 0; Border-top-width : medium; Border-right-width : medium; Border-bottom-width : medium; Border-left-width : medium; Width : 150px; Height :150px; position : absolute; top : 605px; Padding : 3; Margin-top : 0; Text-indent : 3px; Border-top : 1px solid#00; Border-right : 1px solid#00; Border : 1px solid#00; Border-left : 1px solid#00; Border-bottom : 1px solid#00; } #banner { Font-family : Arial , Helvetica , Sans Serif; Font-size : 80%; Font-weight : normal; Margin : 0; Border-top-width : medium; Border-right-width : medium; Border-bottom-width : medium; Border-left-width : medium; Width : 604px; Height : 125px; position : absolute; left : 140px; Padding : 3; Margin-top : 0; Text-indent : 3px; Border-top : 1px solid#00; Border-right : 1px solid#00; Border : 1px solid#00; Border-left : 1px solid#00; Border-bottom : 1px solid#00; } #shopping { Font-family : Arial , Helvetica , Sans Serif; Font-size : 80%; Font-weight : normal; Margin : 0; Border-top-width : medium; Border-right-width : medium; Border-bottom-width : medium; Border-left-width : medium; Width : 125px; Height : 125px; position : absolute; top : 7px; left : 750px; Padding : 3; Margin-top : 0; Text-indent : 3px; Border-top : 1px solid#00; Border-right : 1px solid#00; Border : 1px solid#00; Border-left : 1px solid#00; Border-bottom : 1px solid#00; } #search { Font-family : Arial , Helvetica , Sans Serif; Font-size : 80%; Font-weight : normal; Margin : 0; Border-top-width : medium; Border-right-width : medium; Border-bottom-width : medium; Border-left-width : medium; Width : 150px; Height : 90px; position : absolute; top : 140px; left : 725px; Padding : 0; Text-indent : 3px; Border-top : 1px solid#00; Border-right : 1px solid#00; Border : 1px solid#00; Border-left : 1px solid#00; Border-bottom : 1px solid#00; } #poll { Font-family : Arial , Helvetica , Sans Serif; Font-size : 80%; Font-weight : normal; Margin : 0; Border-top-width : medium; Border-right-width : medium; Border-bottom-width : medium; Border-left-width : medium; Width : 150px; Height : 210px; position : absolute; top : 238px; left : 725px; Padding : 3; Margin-top : 0; Text-indent : 3px; Border-top : 1px solid#00; Border-right : 1px solid#00; Border : 1px solid#00; Border-left : 1px solid#00; Border-bottom : 1px solid#00; } #footer { Font-family : Arial , Helvetica , Sans Serif; Font-size : 80%; Font-weight : normal; Margin : 0; Border-top-width : medium; Border-right-width : medium; Border-bottom-width : medium; Border-left-width : medium; Width : 150px; Height : 210px; position : absolute; top : 238px; left : 725px; Padding : 3; Margin-top : 0; Text-indent : 3px; Border-top : 1px solid#00; Border-right : 1px solid#00; Border : 1px solid#00; Border-left : 1px solid#00; Border-bottom : 1px solid#00; } I would like to pop up the text, that is, make it bigger when the user hovers on it. but the problem everytime the text gets bigger, the whole row moves and the surrounding texts gets displaced. any idea ? tutorial? let me know if i need to explain more. Good Morning All, Been having a slight problem with the visual in the screenshot below. The blue line is our H2, and the purple one is our H3, however, as you can see, the underline spans the entire width of the column, not just underneith the text, which is our requirement. ***As i am not allowed to upload a url as a new user, the underline is as follows. With the text centre aligned. text ----------------------------------------------------------- rather than text ------ and obviously by the css, the underline on the headers is a small image, repeated - x. Please see relevant css information. * (line 23) { margin-top: 0pt; margin-right: 0pt; margin-bottom: 0pt; margin-left: 0pt; padding-top: 0pt; padding-right: 0pt; padding-bottom: 0pt; padding-left: 0pt; } h2, h3, h4, h5, h6 (line 101) { font-size: 1.2em; font-weight: normal; padding-bottom: 4px; margin-top: 0.6em; margin-right: 0pt; margin-bottom: 0.8em; margin-left: 0pt; text-align: center; } .contentArea h2, #secondaryNavigation h2 (line 114) { background-color: transparent; background-image: url("../images/h2_gradient_bg.gif"); background-repeat: repeat-x; background-attachment: scroll; background-position: left bottom; color: #0066cc; } Many Thanks in advance. Marc. can someone help me with this? here is the page&css I have been working on... the page file the css file I might be silly to use a template that I did on illustrator (with all the banner, boxes and navbar read and just use that as my container background. then I made some transparent boxes for puting in text, images or form elements. Is that why I am not able to select any other those things on the site? this is the first time I try using css to make the whole webpage, so I would appreciate any guidance...thanks!! I know how to position regular text using the in-line style "text-align:right", but when I try to do that with a link I get nowhere. Simplified example: Code: <html> <body> <td><p style="text-align:right">Google</p></td> <td><a href="http://www.google.com" style="text-align:right">Google</a></td> <td><a style="text-align:right" href="http://www.google.com">Google</a></td> <td><span style="text-align:right"><a href="http://www.google.com">Google</a></span></td> <td style="text-align:right"><a href="http://www.google.com" style="text-align:right">Google</a></td> <span style="text-align:right"><td><a href="http://www.google.com" style="text-align:right">Google</a></td></span> </body> </html> The first body line works fine to move the text to the right, but the link in lines 2-5 of the body are stuck on the left. Any suggestions? (My actual code invokes a class from a css page in a particular <td> and I'm trying to force a link in that <td> to the right using an in-line style; while I can do that for regular text I haven't found the secret of doing that for a link.) i have almost perfected the text wrap for this page.... http://defunctgames.com/helpfix/relevent.php4 problem is, i put a margin-top:50px on the image, and i want the text above the image, to flow all the way to the left. thus fully wraping the text. I saw a website that was throwing text that was written and recalling it with a link into a textbox...are there any tuts or anyone help me out with this one thanx aim rpduece Hi. See code below. Why does the outer SPAN in TABLE not grow with the image height. If the text is longer so it is forced below image then it looks as it should. Please also read some comments in the code. Code: <html><body><center><br><br> Why does image not force the outermost span to be at least as high as image?<br> If the text are long enough and gets below the bottom border of image it look good though.<br><br> NOTE: I need to put Image and text either within separate span or in same span as the examples below.<br> In my real application I'm using an <a href=" ...> around the outer span in examples below.<br> <br><br> <table border=1 cellpadding=0 cellspacing=0 width=200px><tr><td> <span style="display:block; background-color:#ffa827; padding-top:10px; padding-left:10px; padding-right:10px;"> <span style="display:block; float:left"> <img src="landscape.jpg" height="40px" width="40px" alt="" border="0"> </span> <span style="display: block; color: white;"> Text here. </span> </span> </td></tr></table> <br><br> <table border=1 cellpadding=0 cellspacing=0 width=200px><tr><td> <span style="display:block; background-color:#ffa827; padding-top:10px; padding-left:10px; padding-right:10px; color: white;"> <img src="landscape.jpg" height="40px" width="40px" alt="" border="0" style="float:left"> Text here. </span> </td></tr></table> </center></body></html> I'm having trouble with a page I'm working on- I posted here a few weeks ago with something sort of similar. This time, though, I'm at a loss, I've tried several different things but nothing worked. http://www.geocities.com/nny555/eup/newschedule.html As you can see, the div where the content is, the text is stretching right through the div. Is there any way to fix this? Hmm, This is a problem that has plagued me for a while, but just recently decided to find a solution. Basically I like to single out words for empasis on certain pages. Well with EM that's fine. However on a new website I'm coding I need to do (TYPE 1 FONT) (TYPE 2 FONT) (TYPE 3 FONT). All are different decorations. Is there a way to create a tag for each word? Thanks. Based on the questions I see being asked and answered here, I'm concerned many of you will laugh at my ignorance, but here goes anyway. I want to know how to use CSS on just a little text. For example, let's say I want to render One-Two-Three-BOOM as text on a Web page, except that what I really want is for the BOOM part to be in a larger font and bold-faced. Can that be done using CSS? Can I select the BOOM part in Front Page 2003 and impose a CSS style to those four letters and only those four? Everything I try, based on the CSS file I'm using, results in applying the new style to all of the text within a whole paragraph. I want to be able to apply the style to just a little text at a time. As another example, I want to render the following two lines Johnny G. Doe 123 West South Street in such a way that, using CSS to control everything, I can get the second line to appear in a smaller font. I can get it to work if there's a <p> between the two lines, but not if I want to separate them with a <br>. I'm not asking whether it's a good idea to use CSS this way, I'm just asking how to do it. I will try to attach a file to this thread that shows the first several lines of the CSS file I'm using, in case that makes a difference. If this doesn't work, please let me know. Thanks. --Johnny Hi, Howdo you get text and and image on the same line. I want text and 2 images on the same line but the image appears on the next line like a <br> has been entered. There is plenty of room for all data.Each has its own <div>. Is it possible to have text run around a div positioned with absolute positioning? I'm having trouble getting text to wrap within a DIV. In my purposely garish sample code below, what I want is for the image and the paragraph to appear side by side within the red DIV, with the paragraph wrapping onto multiple lines as necessary. What happens instead is that if the paragraph is too long to fit on one line beside the image, the blue DIV moves underneath the red one and the text remains on one line. Not what I want at all! Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <style type="text/css"> p { margin: 0 0; color: white; } #title { background-color: red; height: 105px; } #left { float: left; margin: 20px 20px; background-color: yellow; } #right { float: right; margin: 20px 20px; background-color: blue; overflow: hidden; } </style> </head><body> <div id="title"> <div id="left"> <a href="index.htm"><img src="http://i52.tinypic.com/2u9l5z9.png" alt="" width="429px" height="65px" border="0" /></a> </div> <div id="right"> <p>The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog.</p> </div> </div> </body></html> If you shorten the paragraph you can see where I want the text to be displayed. It's only when it exceeds the available width within the red DIV that the whole blue DIV moves further down the page, where the text is suddenly quite happy to start wrapping. This can probably be solved with a single line of CSS but I've been trying all sorts with no joy. Can anyone please pinpoint what I need to do? I finished a website for a friend located at www.woodenitbenicecfw.com and on all my systems I have tested it looks fine but my friend says that some people are telling her that the image is over the text and I am not sure why I dont know why I cant see it because on my end it looks fine. Can someone please have a look and let me know what they see and what the problem is I am sure that it is probably a problem with the div. Thanks Tim Hi, I am having a problem with positioning of text within a div. The CSS for my div is: #menuItem { background-image: url('../../images/menu_bg_off.jpg'); width: 146px; height: 28px; font-family: Verdana, sans-serif; font-size: 14px; font-weight: bold; background-repeat: no-repeat; } <div id="menuItem"><img src="images/spacer.gif" width="33" height="1" /><a href="">Home</a></div> The problem lies in getting the text to appear in the middle of the div. I've tried using padding-top: to nudge it down a bit, but that extends the height of the div.. which I don't want to happen. I have a bunch of these lined up vertically (forming a menu) and I don't want any space between them. margin-top: also adds this unwanted space. As you can see I'm using a transparent spacer image to nudge the text horizontally to where I need it to appear, which works. My question is.. how do I position the text vertically to where I want it to appear inside the div? Here's the css code. Code: .toolbar a:hover, .toolbar a:focus, .toolbar a:active { background-color:#F5F9FA; } .toolbar { border:0; padding:0; margin:auto; border-collapse:collapse; } .toolbar a { display:block; text-align:center; vertical-align:middle; white-space:nowrap; } .toolbar a:hover, .toolbar a:focus, .toolbar a:active { text-decoration:none; } It works fine when you hover over a link, it lights up the back of the td which is what I want. However I would like the whole td to act as a link. So wherever you move the mouse over the td it lights up and would link to the page, instead of just over the text. Any suggestions? Hi there, ahhhh I have just decided to start using Firefox and now am rreworking my site. All new set up issues to try and fix and i don't even know where to start. Here is my site: www.kohlrbaby.com The issues: 1) nav bars are no longer positioned correctly vertically, nor can I get the text to center in FF 2) the white box extends longer then it should in FF vs IE 3) the text is extending off the white box in the catalogue area in FF please please offer me some css insight here is my .css code: BODY { PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-TOP: 0px; PADDING-BOTTOM: 0px; margin:0px auto; SCROLLBAR-HIGHLIGHT-COLOR: #ffffff; SCROLLBAR-SHADOW-COLOR: #a1b7d2; SCROLLBAR-FACE-COLOR: #a1b7d2; SCROLLBAR-ARROW-COLOR: #003366; SCROLLBAR-TRACK-COLOR: #cccccc; FONT-FAMILY: verdana, helvetica, arial, sans-serif; BACKGROUND-COLOR: #a1b7d2; TEXT-ALIGN: center; COLOR: black; FONT-SIZE: 12px; } #menuList { PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px } #menuList UL { PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px } #menuList LI { DISPLAY: inline; LIST-STYLE-TYPE: none } A.actuator { PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 9px; PADDING-BOTTOM: 0px; MARGIN: 0px; COLOR: #000; PADDING-TOP: 0px; BACKGROUND-COLOR: transparent; TEXT-DECORATION: none } A.actuator:hover { COLOR: #958550 } .menu { BORDER-RIGHT: #ccc 1px solid; BORDER-TOP: #ccc 1px solid; VISIBILITY: hidden; BORDER-LEFT: #ccc 1px solid; COLOR: #000; BORDER-BOTTOM: #ccc 1px solid; POSITION: absolute; BACKGROUND-COLOR: #ffffff } .menu LI A { PADDING-RIGHT: 10px; DISPLAY: block; PADDING-LEFT: 10px; FONT-SIZE: 9px; PADDING-BOTTOM: 0px; MARGIN: 0px; COLOR: #000; LINE-HEIGHT: 1.75em; PADDING-TOP: 0px; BACKGROUND-COLOR: #ffffff; T EXT-DECORATION: none } .menu LI A:hover { COLOR: #eee; BACKGROUND-COLOR: #a1b7d2 } SPAN.key {TEXT-DECORATION: underline} #homeMenu {WIDTH: 100px} #catalogueMenu {WIDTH: 100px} #wholesaleMenu {WIDTH: 100px} #wheretobuyMenu {WIDTH: 100px} #contactMenu {WIDTH: 100px} A {FONT-WEIGHT: normal; COLOR: #000000; TEXT-DECORATION: none } A:visited {COLOR: #000000} A:hover {COLOR: #958550} A.set1:link {text-decoration: none; color: #7c8895 } A.set1:visited {text-decoration: none; color:#990000} A.set1:hover {text-decoration: none; color:#958550} #navHeader { PADDING-TOP: 0; HEIGHT: 110px; BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; MARGIN-LEFT: auto; MARGIN-RIGHT: auto; WIDTH: 650px; POSITION: relative; BORDER-BOTTOM: #000000 1px solid; BACKGROUND-COLOR: #ffffff; TEXT-ALIGN: center; z-index: 10; } #logoHolder{ position: relative; } img.nav_left{ float: left; } #smallLogo { POSITION: relative; top: 30px; left: -145px; font size: 11px; font-weight: bold; } div.gray_layer { background:#cccccc; height: 20px; width: 650px; border: solid #000000; border-right-width: 0px; border-left-width: 0px; border-top-width: 1px; border-bottom-width: 1px; position: relative; text-align: center; z-index: 50; top: 56px; } #second_links { FONT-SIZE: 9px; TEXT-ALIGN: center; position: relative; top: 58px; MARGIN-LEFT: auto; MARGIN-RIGHT: auto; margin:0px auto; } #navImageBox{ BORDER-RIGHT: #000000 1px solid; BORDER-TOP: 0px; BORDER-LEFT: #000000 1px solid; MARGIN-LEFT: auto; MARGIN-RIGHT: auto; WIDTH: 650px; POSITION: relative; BORDER-BOTTOM: #000000 1px solid; BACKGROUND-COLOR: #ffffff; TEXT-ALIGN: center; } #verticalLine{ height: 12px; width: 500px; border-right:#000000 1px solid; } img.banner{ BORDER-TOP: #000000 1px solid; BORDER-bottom: #000000 1px solid; } #contentHolder{ PADDING-TOP: 0; PADDING-bottom: 0; PADDING-left: 0; PADDING-right: 0; BORDER-RIGHT: #000000 1px solid; BORDER-Bottom: #000000 1px solid; BORDER-LEFT: #000000 1px solid; MARGIN-LEFT: auto; MARGIN-RIGHT: auto; WIDTH: 650px; POSITION: relative; BACKGROUND-COLOR: #ffffff; text-align: center; } #text{ padding: 10 30 0 30; line-height: 1.75em; text-align: left; } #catalogue{ padding: 20 30 15 25; width: 650px; position:relative; height: 100%; background:transparent; margin-right: auto; margin-left: auto; } .outline {border: 1px solid black;} div.catalogue_pic { position: relative; float: left; padding-right: 8px; } div.catalogue_text{ text-align: left; position: relative; LINE-HEIGHT: 1.25em; } div.float { position: relative; float: left; margin: 5 5 5 5; } div.float p { text-align: center; } #bottomText{ padding: 0px; margin-top: 10px; margin-bottom: 0px; margin-right: 20%; margin-left: 20%; /* opera does not like 'margin:20px auto' */ background: none; border: none; border-top: none; text-align:center; voice-family: "\"}\""; voice-family:inherit; font-family: verdana, arial, helvetica, sans-serif; font-size: 11px; } #blueBox{ text-align: center; position: relative; height: 27px; width: 150px; background-COLOR: #a1b7d2; top: -26px; } Hi, I have a problem that I'm trying to figure out. If I have a div such as the following: PHP Code: #Div1 { background: url(title.gif) no-repeat; position: absolute; top: 30px; left: 30px; width: 387px; height: 55px; .. which I want to be able to use absolute positioning to place within my page. My question is, is there a way to make it so that text will wrap around it (such as a regular aligned image) instead of the text appearing underneath it? |