CSS - Text Padding Woes
Okay, another simple problem, but every solution I find on the internet does not work.
I need to add padding to a <p> element, so I have this in my CSS: Code: .p{ font-family: Arial, Helvetica, sans-serif; font-size: 10pt; font-color:#000000; float: left; margin-left:5px; padding: 5px; } any help is appreciated. -S Similar TutorialsSeems a simple question, but how do I add padding to text within a box but not affect the images? in my columns I have little 'features' but I have a title above each image and some description text below. What's the simplest way to code it so all the text has side padding, but not the image? Firstly, excuse my title, I couldn't think of a better way to put it . Now to the problem. In my layout I have a floated object, and text that flows around it, I can pad the text away from this floated object by using margins on the floated object. But I have created a class for <p> that I want to be padded further, and if I add padding-left to p.quote (the class) it makes no difference because the padding is simply going behind the float... As rubbish as that explanation was, I expect someone will pick up on what I'm going on about. How can I have some text indented (padded) further away from the float than other ? Thanks in advance. What is the CSS property for valign-center for the vspace-like padding for the text? Hi! How does padding and margin on text and images behave? And on other inline elements? Didn't get it to work in IE6. Thank you Hello, Is there a way to have padding (say 15px) all around a cell, but allow for expections, like having one div element float:left and align far left against cell border while everything else is inset 15px. ie. Code: <style> #menubox { float:left; margin-left:15px; margin-bottom:7px; } .main_cell { padding:15px; } </style> <body> <table width=600 border=0 cellpadding=0 cellspacing=0> <tr> <td valign=top class="main_cell"><div id="menubox">table with menu items taht is achored far left against cell wall</div> Some text that wraps around "menubox" but needs to be padded around cell walls.</td> </tr> </table> </body> Thanks, Rey Hey everyone, I am making a design to kill some time, and I have come across a problem. I have a menu at the top which has no top padding unless I give it padding of 87px. I find this very odd, and it happens in every browser( Firefox 2.0.0.3, Opera 9, IE6-7 ); is it a bug in CSS itself or am I doing something wrong? Here is my code, maybe I am missing something. html4strict Code: Original - html4strict Code <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <title></title> <style type="text/css"> body { background-color: #082567; color: #FFFFFF; margin: 0; padding: 0; font-family: verdana,tahoma,"Bitstream Vera Sans",arial,helvetica,sans-serif; font-size: 12px; text-align: justify; } #top-menu { background-image: url( http://secretgeek.net/Gradient.aspx?Direction=H&Length=130&StartColor=082567&EndColor=0C39A1&Format=jpeg ); background-repeat: repeat-x; height: 130px; } #top-menu h1 { float: left; font-weight: bold; letter-spacing: -3px; font-size: 31px; padding: 5px; } #menu { float: right; list-style-type: none; text-align: center; } #menu li { display: inline; } #menu a { background-image: url( http://secretgeek.net/Gradient.aspx?Direction=H&Length=130&StartColor=082567&EndColor=0C39A1&Format=jpeg ); background-repeat: repeat-x; color: #FFFFFF; padding: 50px; } #menu a:hover { background-image: url( http://secretgeek.net/Gradient.aspx?Direction=H&Length=130&StartColor=0C39A1&EndColor=082567&Format=jpeg ); background-repeat: repeat-x; } </style> </head> <body> <div id="top-menu"> <h1>ryon.hunter</h1> <div id="menu"> <ul> <li><a href="">asdf</a></li> <li><a href="">asdf</a></li> <li><a href="">asdf</a></li> <li><a href="">asdf</a></li> <li><a href="">asdf</a></li> </ul> </div> </div> </body> </html> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" I validated it and it validates fine, any suggestions? ok I've been playing with divs and trying to get them working well, but no matter what I do I can never get any site I try and create with divs looking as good as I could do with tables. I've just grown up using tables, and am irritated that that's the way it was because I would like to be using divs. I posted a thread earlier and got some good help, but have since decided on using a different design and can't quite get it the way I want it. so, this is a big ask, but could someone 'convert' this table based site to something that looks the same using divs so I try and relate how divs work to how tables work a bit better? thank you very very much to anyone that can. html Code: <html> <head> <style> @import url(template.css); </style> </head> <body> <table id='main' cellspacing='0'> <tr> <td id='logobox'> logo </td> <td id='menu'> menu </td> </tr> <tr> <td id='content' colspan='2'> content </td> </tr> <tr> <td id='footer' colspan='2'> footer </td> </tr> </table> </body> </html> css Code: body, html { height: 100%; background-color: #fff; margin: 0px; } td { border: 1px solid #000; } table#main { width: 60%; height: 100%; margin: 0px auto; border: 1px solid #000; } td#logobox { width: 80px; height: 80px; } td#menu { } td#content { columnspan: 2; } td#footer { height: 1%; } Please look at these two pages - www dot aamco-houston dot com www dot aamco-houston dot com/warranties.asp On the second page, in IE9, the navigation gets broken and put on two lines. In IE7, IE8, Firefox,etc. it looks fine. Can someone give me a workaround perhaps? Thanks. Tom I would really appreciate some help with this layout issue I am having. Look at this page in IE 9 - http://www.hotstepperspainting.com/.../assistance.asp Notice the menu wraps the last link around and onto the body of the page? Also note that the bottom nav bar is doubled up. Now in IE8 I don't have the menu problem but do have the footer issue. In IE7 it looks like it should. I would really appreciate it is someone could shed some light for me on this. Tom Hi, This will help explain it: http://www.mattvonfat.com Now there is a container DIV (the box that goes down to almost bottom of screen) and 4 DIVs in the container (Logo, two link bars and my content). My problem is that I want the content to fill up as much as possible and have the bottom link bar (which is bordered) to be at the very bottom. Now, I tried adding height: 100%; to my content style but that made it 100% of the body height. Is there way to get it to just fill up as much as possible? I just noticed that one problem could be that the containing DIV uses absolute positioning to make the container 50px from both bottom and top. Would this be a problem? Here is the css for both the container and the content: css Code: Original - css Code /* container */ div#outer { position: absolute; width: 700px; font: 12px Verdana; background-color: #FFFFFF; border: 1px solid #000000; top: 50px; bottom: 50px; left: 50%; margin-left: -350px; padding: 0px; min-width: 700px; } /*content*/ div#indexs { border-top: 1px solid #000000; padding: 10px; margin: 0px; text-align: center; }
Thanks for any help you can give me with this, Matthew [edit] Hmm and i just realised that it doesn't even appear in IE the way it does in mozilla so I have two problems...[/edit] I am trying to get my suckerfish dropdown menu to be centered on the page regardless of the resolution of the monitor. I know this is possible, but I just can't wrap my head around it. This is what I have so far: Code: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" > <head> <title><?php echo $title_page; ?></title> <meta http-equiv="content-type" content="application/xhtml+xml; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="site_files/style/web.css" /> <link rel="Shortcut Icon" href="site_files/pictures/favicon.ico" /> <script type="text/javascript" src="site_files/ie_drop.js"></script> </head> <body> <div id="header"> <p>NAVPACMETOCCEN San Diego Operational Home Page</p> </div> <div id="info"> <p>This page will be down at 1100 GMT on 20 June 2005. Click <a href="site_files/php/status.html">here</a> for more information.</p> </div> <div id="menu"> <ul id="nav"> <li><a href="index.php">Home Page</a></li> <li>Support <ul> <li><a href="site_files/php/a.html">Ship Specific</a></li> <li><a href="site_files/php/a.html">Unit Specific</a></li> <li><a href="site_files/php/a.html">Detachment</a></li> <li><a href="site_files/php/a.html">Mobile Env. Team</a></li> <li><a href="site_files/php/a.html">Coast Guard</a></li> </ul> </li> <li>Satellite <ul> <li><a href="site_files/php/a.html">Infrared</a></li> <li><a href="site_files/php/a.html">Visual</a></li> <li><a href="site_files/php/a.html">Water Vapor</a></li> <li><a href="site_files/php/a.html">Lightning</a></li> <li><a href="site_files/php/a.html">Analysis</a></li> </ul> </li> <li>Products <ul> <li><a href="site_files/php/a.html">Warnings</a></li> <li><a href="site_files/php/a.html">Forecasts</a></li> </ul> </li> <li>Aviation <ul> <li><a href="site_files/php/a.html">Products</a></li> <li><a href="site_files/php/a.html">Contact Info.</a></li> <li><a href="site_files/php/a.html">OBS/TAFS</a></li> <li><a href="site_files/php/a.html">Aviation Links</a></li> </ul> </li> <li><a href="site_files/php/links.html">Links</a></li> </ul> </div> <div id="leftside"> <p class="leftmenu"><a href="http://www.navy.com">Navy Jobs</a></p> <p class="leftmenu"><a href="http://www.donhr.navy.mil/NoFearAct.asp">No Fear Act</a></p> <p class="leftmenu"><a href="http://www.navy.mil">U.S. Navy Website</a></p> <p class="leftmenu"><a href="html/privacy.html">Privacy Policy</a></p> <p class="leftmenu"><a href="site_files/disclaimer.html">DoD Disclaimer</a></p> </div> </body> </html> And here is the style sheet: Code: /* This part tells us how the hyperlinks will be handled by the browsers, and also what the background will be */ a:link { /* This is the link standard color*/ color: #000000; /*black*/ } a:visited { /* This is the color of an already visited link*/ color: #800080;/*purple*/ } a:hover {/* This is the color your link will take when you move your mouse over it*/ color: #FF0000;/*red*/ text-decoration: none; } a:active {/* This is the color and effect when you physically click on the link*/ color: #008080; /*teal*/ } a { /*This tells the browser not to underline any links */ text-decoration: none; } /* This begins the header and the information notice portion */ #header { margin: -14px -8px 0px -8px; padding: 10px; height: auto; background: #000060; } #header p { margin: 0; height: auto; color: #FFFF1B; text-align: center; font: small-caps 24px verdana, san-serif, serif; } #info { margin: -1px -8px 0px -8px; padding: 1px; height: auto; } #info p { margin: 0; height: auto; color: #0000FF; background: #FFFFFF; text-align: center; font: bold 12px arial, san-serif, serif; } /* This ends the header and the information notice portion */ /* This begins the Drop-down menu portion*/ #menu { /* Top-Right-Bottom-Left */ margin: 0 0 0 145px; padding: 0; width: auto; font: small-caps bold 12px verdana, san-serif, serif; } ul { /* all lists */ padding: 0; margin: 0; list-style: none; } li { /* all list items */ float: left; position: relative; width: 125px; } li ul { /* second-level lists */ display: none; position: absolute; top: 14px; left: 0; } li>ul { /* to override top and left in browsers other than IE, which will position to the top right of the containing li, rather than bottom left */ top: auto; left: auto; } li:hover ul, li.over ul { /* lists nested under hovered list items */ display: block; } /* This ends the drop-down menu portion */ /* This begins the left-side menu portion */ #leftside { margin: 100px 0px 0px -8px; width: 115px; color: #000000; font: small-caps 12px arial, san-serif, serif; } .leftmenu { margin: 5px 0 2px 0; height: 15px; background: #DDEEFF; } #pkinotice { margin: 0px 50px 0px 125px; font: bold 12px arial, san-serif, serif; } .pki { border: 2px solid #FF0000; As you can see, I've just moved it over manually 145 px, and that centers it pretty well if you are viewing it at 1024x768, but at higher resolutions, the 145px is not sufficient for the centering. If anyone has an idea on how to fix it, I'd appreciate help. The solution must be able to validate, and work in both IE and a compliant browser (mozilla or firefox is what I use). Also, if the style sheet code can be cleaned up, or you see mistakes, don't hesitate to tell me. I've been learning CSS2.1 for about 3 months now, but I am not a whiz at it... I appreciate the help. Many thanks... Bryan Hi I am having a nightmare trying to get my horizontal navigation items to fill the width of my page and looking the same in IE and FF. Here is the page http://www.designhomemanagement.com/new/ You will see that in IE the spacing is different. They need to fill the width of the design (760px) Please someone help me! Thanks I'm having trouble getting my background to render for my site. When I write the code in the HTML ex. <body background="images/currentbgimage.jpg"> it brings up the image fine. This would suffice if I could tell the image not to repeat. But you can't to my knowledge in the body tag. The image won't display if I write it in the CSS though. ex. body {background-image: url('images/currentbgimage.jpg')} or body {background: url('images/currentbgimage.jpg')} I also tried it with the JPG in the folder with the HTML code, but to no avail. Any help will be appreciated. Skolar I'm working on reworking my flash site into a CSS/HTML site. Tired of dealing with flash. Anyways....I am working on this page currently and am having trouble getting 3 divs to line up properly in IE. They look great in Firefox! Take a look and let me know if you have any ideas. Any help is much appreciated. Here's the link www .crealities.com/2008/inspiration.htm I'm having serious problems with the Peekaboo bug in IE. At least I think its that - I've tried all the fixes listed on positioniseverything and none are fixing it... http://ucy.sitemakers.com/courses.php I've got a three column layout taken from alistaparts Holy Grail layout which I've had working on many other sites with no problems, but I have added another two column layout directly above the three column one in this case. The problem im having is a jumping div element, the left column. When you click on the Courses link the element is in the centre of the page but moving the mouse around the main menu items will make it jump back into place. On page refresh the column is in the right place. Wierdly hovering over the link in the centre column doesnt make the offending div jump back like I would have expected. Taking out the following IE hack from the CSS: *html #cc_l { left:22em;} Makes the div appear in the correct place when clicking on the Courses link, until I hover over the menu again - then it jumps off the left of the page! This is doing my nut in, anyone have any ideas? Having some problem's with this layout i'm 'attempting' to develop in CSS... The Div setup Code: <div id="header"> Header </div> <div id="container"> <div id="menu_left"> Menu Left </div> <div id="content"> Content </div> <div id="menu_right"> Menu Right </div> </div> <div id="footer"> Footer </div> The CSS Code: /* specific divs */ #container { margin: -3px; width: 100%; text-align: center; } #header { height: 100%; text-align: left; border-style: dotted; border-width: 1px; border-color: #000000; } #content { width: 60%; position: fixed; float: left; border-style: dotted; border-width: 1px; border-color: #000000; } #menu_left { width: 20%; position: fixed; float: left; border-style: dotted; border-width: 1px; border-color: #000000; } #menu_right { width: 20%; border-style: dotted; border-width: 1px; border-color: #000000; } #footer { border-style: dotted; border-width: 1px; border-color: #000000; } I've been looking around I don't really know where I'm going wrong due to my lack of experiance with CSS.... But in IE it won't float the DIV [menu_right] i've tried using position absolute|relative|fixed none seem to work i've been trying different combo's of Floats and mostly anything I can think of if someone here would be able to spare some time to help a 'noob' i'd be very gratefull... Thanks Hi. I've been trying to add some basic CSS to my forums. Basically it's just this: Code: <div style="float:left;width:24%;"> </div> <br /> <div style="float:left;width:24%;"> </div> <div style="float:right;width:74%;"> </div> It works fine with just the first and last div. But it won't work with the middle div there. I dunno what CSS to use. Edit: I can understand why it's doing that, add left | at 24%, add another | at 24% beside it for || but the last | is 74% and won't fit so it goes on a new line. Then the second | stretches to 74% to fit the | at 74% below it. Hmm, might revert to tables. Hey, all! I'm having a seemingly simple problem... and I'd really appreciate if you guys could help me out! I have no idea how to do what I want done, but I know it's possible. I want to give every <tr> in <table class="forumList"> a 'border-bottom: 1px solid #000;' style.... except for the last <tr>. HOWEVER, if a new table is created, I want it to start showing the border-bottom again... until the last <tr> in the table. How would I go about doing this? Hi. K, the site (thus far) looks great in IE, as the CSS is functioning perfectly. However, when checked in FF, it pretty well ignores the CSS for the body. I"ve undoubtedly missed somethin', just don't know what it is. Thanks here's the css; Code: .borders { border: 1px solid #666666; text-align:center; } } .text { font-family:Century Gothic, Arial, sans-serif; font-size: 11px; color: #333333; text-align:left; } } .listtext { font-family:Century Gothic, Arial, sans-serif; font-size: 11px; color: #333333; text-align:left; } table.menu { border:1px solid #999999; background:#CCCCCC; } table.menu a:link, table.menu a:visited { display:block; font-family:Century Gothic, Arial, sans-serif; font-size:12px; line-height:16px; color:#006600; text-decoration:none; padding: 2px 2px; } table.menu a:active, table.menu a:hover { color:#CCCCCC; background:#006600; } table.menu a { width:144px; display:block; font-family:Century Gothic, Arial, sans-serif; font-size:12px; line-height:16px; color:#006600; text-decoration:none; padding: 2px 2px; } and here's the HTML Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Kyrtsakas Law - Home</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="description" content="Kyrtsakas Law Office - Title Insurance from an experienced Real Estate Lawyer offers the best protection for your investment"> <meta name="keywords" content="Kyrtsakas, Law, Law Office, Lawyer, real estate, estate, will, title, Windsor, purchases, mortgages, power of attorney, attorney, CAW"> <link href="kyrtsakas_styles.css" rel="stylesheet" type="text/css"> </head> <body topmargin="0" bgcolor="#666666"> <table width="640" align="center" cellpadding="2" cellspacing="2" bgcolor="#CCCCCC" class="menu"> <tr valign="top"> <td align="center" width="640" colspan="6"> <img src="images/Kyrtsakas_header.jpg" alt="Kyrtsakas Law Office"> </td> </tr> <tr valign="top"> <td class="borders" width="106" colspan="1"> </td> <td class="borders" width="106" colspan="1"> <a href="http://www.kyrtsakaslaw.com/index.htm">Home</a> </td> <td class="borders" width="106" colspan="1"> <a href="http://www.kyrtsakaslaw.com/profile.htm">Profile</a> </td> <td class="borders" width="106" colspan="1"> <a href="http://www.kyrtsakaslaw.com/tools.htm">Online Tools</a> </td> <td class="borders" width="106" colspan="1"> <a href="http://www.kyrtsakaslaw.com/contact.htm">Contact</a> </td> <td class="borders" width="106" colspan="1"> </td> </tr> <tr valign="top"> <td class="borders" width="106" colspan="1"> </td> <td class="borders" width="640" colspan="4"> <div class="text"><br> Welcome to <b>Kyrtsakas Law Office</b>.<br><br> <b>Christos Kyrtsakas</b>, <b>LL.B.</b> specializes in <b>Real Estate Law, Title Insurance, Purchases, Sales, Mortgages,</b> and readily welcomes <b>CAW Plans</b>.<br><br> Call Chris today at (519)-974-6303, or drop by the office, located at 5655 Tecumseh Road East (across from the Fire Station), Windsor, ON.<br><br> "<i>Having a Lawyer Makes it Safer for You</i>!"<br><br> </div> </td> <td class="borders" width="106" colspan="1"> </td> </tr> <tr valign="top"> <td class="borders" width="106" colspan="1"> </td> <td class="borders" width="640" colspan="4"> </td> <td class="borders" width="106" colspan="1"> </td> </tr> </table> </body> </html> Thank you! I can't get a drop down menu to display and don't know what I'm doing wrong. My guess is that other styles for this menu are interfering, but I've tried experimenting and it never works. Can anyone kindly assist? Here's the CSS for the part of my navigation menu I'm working on (I know this is not the most streamlined): Code: #nav2 { float: right; background-image: url(../2010site/graphics/nav2back.jpg); background-repeat: no-repeat; height: 32px; font-size: 14px; color: #ffffff; text-decoration: none; text-align: center; margin: auto; padding: 0px 30px 0px 0px; } #nav2 ul li { display: inline; list-style: none; background-image:url(../2010site/graphics/rednavdetail.jpg); background-repeat: no-repeat; margin: auto; padding: 0px 20px 0px 20px; } #nav2 a { color: #ffffff; margin: auto; padding: 0px 0px 0px 0px; } #nav2 a:hover { text-decoration: underline; margin: auto; padding: 0px 0px 0px 0px; } Then I'm trying to add a drop down to a nested list item within that navigation using Code: li ul {display: none;} li:hover > ul {display: block;} But whenever I add that at the end of the nav2 styles, I can only see my nested menu that is supposed to appear during the hover. The other menu items beyond the nested UL don't appear at all. Here's the html: Code: <ul> <li><a href="http://">Schedule</a> <ul> <li><a href="http://">item one</a></li> <li><a href="http://">item two</a></li> <li><a href="http://">item three</a></li> </ul> </li> <li><a href="http://">Programs</a></li> <li><a href="http://">Events</a></li> <li><a href="http://">Donate</a></li> </ul> |