CSS - Display: Inline, With Img Inside?
Hello, I have a question about div's set to display: inline.
First let me explain what I'm trying to do so that if I'm going about it the wrong way you can show me the light. I'm trying to have multiple divs centered on the screen and lined up horizontally, like so: | (div1)(div2)(div3)(div4) | The thing is, I have images in the divs. I also have a border on the divs. So when I set display: inline, the border goes through the image (although the divs are positioned correctly with the body text-align: center). However, when I set display: block, the border is exactly how I want it (i.e. it includes the image) but the divs are placed one on top of the other vertically and they are left-aligned. Is there a simple way to do this? Thanks Similar TutorialsI need to style all images within a div. For example, I want to do something like this: <div style="img{border: 0;}"> <img src="" /> <img src="" /> <img src="" /> </div> But that does not seem to work. Is it this possible with css? It is for an ebay template, so I don't think I can reference a separate stylesheet. thanks. Charley I've been seeing people using ul and li tags to make their menus in css. So I've started trying to do the same, here is an example. But obviously here, the buttons are not displaying inline. All of the styles are within the page code itself. I've got a display: inline style on the li tag, but it's still not working? How can I get this to work or is there any other way to get a ul li menu to display this way? Damn another problem good thing you guys are so helpful.... What am I doing wrong here? css Code: #footer{ position:relative; z-index:-1; margin-top:-50px; background-color:#666666; width:100%; height:100px; margin-left:auto; margin-right:auto; border-top:#000000 10px solid; } #footer ul{ position:absolute; padding:0px; margin-top:50px; margin-left:auto; margin-right:auto; } #footer li{ display:inline; padding:0px; margin:0px; } #footer a{ font-family:Arial, Helvetica, sans-serif; font-size:10px; border-right:#FFFFFF 1px solid; } html Code: <div id="footer"> <ul> <li><a href="#">Nav 1</a></li> <li><a href="#">Nav 2</a></li> <li><a href="#">Nav 3</a></li> <li><a href="#">Nav 4</a></li> <li><a href="#">Nav 5</a></li> <li><a href="#">Nav 6</a></li> <li><a href="#">Nav 7</a></li> </ul> </div> Just can't seem to get the list centered inside the div Ok, so maybe I don't understand the display attribute quite right. What I'm doing makes sense to me, but it's not working right when displayed. I have a div that is set to display inline (so that I don't have to use floating). Since inline elements can't have height/width attributes, i have another div inside of it, with display set to block. This inner div has height and width attributes. Now, if I place another similar structure (block div inside inline div) in the code, the two outer divs /should/ (in my mind) render side-by-side with the heights and widths of their child div's. When I try it though, it displays everything as block-type. Any ideas? PHP Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Title</title> <style type="text/css"> img{ border: 0px black solid; height: 200px; } div.outerholder{ display: inline; } div.innerholder{ text-align: center; height: 200px; width: 267px; margin: 0px; padding: 0px; display: block; } div.centerme{ text-align: center; margin-left: auto; margin-right: auto; } </style> </head> <body> <div class="centerme"> <div> <div class="outerholder"> <div class="innerholder" style="margin-right: 5px;"><a href="dir1/PICTURE.JPG"><img src="dir1/PICTURE.JPG" /></a></div> </div> <div class="outerholder"> <div class="innerholder" style="margin-left: 5px;"><a href="dir1/PICTURE.JPG"><img src="dir1/PICTURE.JPG" /></a></div> </div> </div> <div> <div class="outerholder"> <div class="innerholder" style="margin-right: 5px;"><a href="dir1/PICTURE.JPG"><img src="dir1/PICTURE.JPG" /></a></div> </div> <div class="outerholder"> <div class="innerholder" style="margin-left: 5px;"><a href="dir1/PICTURE.JPG"><img src="dir1/PICTURE.JPG" /></a></div> </div> </div> <div> <div class="outerholder"> <div class="innerholder" style="margin-right: 5px;"><a href="dir1/PICTURE.JPG"><img src="dir1/PICTURE.JPG" /></a></div> </div> </div> </body> </html> P.S. It also doesn't center properly in FF, but that's secondary... Im trying to get an input field and form button to line up to the right of an <li> tagged menu and not sure of the approach i should take. I'd prefer not to use a table if possible, and the table im using now is a bit buggy anyway. this is a page with the menu as it shows right now.... http://www.seesawusa.com/products/ this is the page with the basic idea of what im trying to do http://www.seesawusa.com/pages/74/ Things i'v tried 1. put the form inside a LI tag.... This results in putting the search box below the list of menu items across all my test browsers. 2. put the UL and the FORM inside a table with 2 cells... in FF, i get the result i want... except the LI and INPUT field are not aligned to the right in IE6 & 7 I get it lined up the way i want it. But the table pushes the the height and width of the containing div to an unacceptable level I've seen this type of thing before and in my searching other sites i've only found complicated table based layouts that use it. Does anyone know an approach that would allow me to leave out tables, or at the very least only use one? Thanks for the glance. P.S. Interestingly enough, the page you are reading has a menu and text field configuration that im wanting to use, but it is very table oriented. Hello, I know that putting a block level element (such as <p> or <div>) inside an inline element (such as <a>) is against "xhtml 1.0 strict" rules, so I'm putting a <span> (inline) within an <a> (also inline). I've made my <span> "display: block;", and it works in all browsers and validates fine, but I feel like I'm cheating the system a bit? The thing is, I need to put a margin under a piece of text without using <br /> (as when a browser forces a line break, it will use that rule and make different pieces of text look odd), but all the text is within an anchor tag, so I can't use <p> or <div>. Would appreciate any thoughts on the matter, Cheers! Could someone enlighten me why the page in the following URL functions perfectly in both IE6 and FF and yet, I seem to be totally unable to get the darn thing working locally? I am trying to avoid JavaScript and this looked like a very clean way of hiding and revealing menu items. I don't speak Japanese so I don't understand the text on the page either. http://www.amy.hi-ho.ne.jp/staka/hp/dhtm/s_disp.htm Hello, my code works fine on my MAC browsers, but on my PC, IE6 browser, the buttons underneath the body of the page don't align. Here's the site: http://www.caillouette.com/Utilitrek/three/ Here's the CSS:http://www.caillouette.com/Utilitrek/three/style2.css Can someone tell me if this site looks okay in IE 7? I can't download IE 7 because of some technical quirk on my computer. And if they don't align in IE 7, please tell me what I should do. thanks -Sean This is bugging me to death. I cannot get these to top elements to display inline. If anyone could take a look in firebug to see element and related css applied and tell me whats wrong. The page is: http://travelmagoo.com/index.php?option=com_resource&controller=article&article=384&category_id=201&Itemid=0 at the top header there is a title and to the right there is an image. I would like the image and title to be on the same line but everything i do will not let me do this. any ideas? I am working on a drupal site and I having problems getting some images in a block to display inline. I am able to effect some of the aspects of the images (they are list items in a ul) but I can't get them to display inline. Here is the html from the source: <div id="block-views-recent_images" class="block block-views"> <div class="blockinner"> <h2 class="title"> recent images </h2> <div class="content"> <div class='view view-recent-images'><div class='view-content view-content-recent-images'><div class="item-list"><ul><li><div class='view-item view-item-recent-images'><div class='view-field view-data-node-data-field-user-images-field-user-images-fid'><a href="/image-upload/admin/05-sep-2007/204"><img src="(xxxxxx) image_0.jpg" alt="" title="" /></a></div></div> </li><li><div class='view-item view-item-recent-images'><div class='view-field view-data-node-data-field-user-images-field-user-images-fid'><a href="/image-upload/admin/05-sep-2007/201"><img src="(xxxxxxx) image.jpg" alt="shack" title="some image" /></a></div></div> </li></ul></div></div><div class='more-link'><a href="/recent_images">more</a></div></div> And here is the css that I have attempted so far: #block-views-recent_images { background: #EBE9ED; } #block-views-recent_images li{ list-style-image: none; list-style-type: none; padding: 0; margin: 0; display: inline; } I am new to CSS so I know I may have taken a completely wrong approach. Thanks for any suggestions on how to get the images to display inline. Thanks Hi, I have created a horizontal navigation before with no problem, yet I am now having trouble. Here's the site: http://www.caillouette.com/Catering/ I have the Div named "indentmenu" and the <ul class="toolbar"> Here's the style sheet: http://www.caillouette.com/Catering/style2.css and here's the navigation: http://www.caillouette.com/Catering/header_nav.inc what am i doing wrong? thanks in advance. Hello, I am having trouble with the display: inline tag. ******************************************** Here is the style: H1.nolinebreak { font-size : 12pt; display: inline; } Here is an HTML snippet: <p> Here is my content text. Blah blah <H1 class="nolinebreak"> inline header 1 </H1> blah blah blah <H1 class="nolinebreak"> inline header 2 </H1> </p> ******************************** The second and additional instances of the <h1 class="nolinebreak"> works great. But the first one always puts in a line break. I need them all to display inline. What am I doing wrong? Thanks in advance. Hi, I have some simple code as follows: Code: #stars{ width:400px; height:33px; } .star{ width:33px; height:33px; background-image: url('images/product_review/star.gif'); font-size:0pt; } </style> </head> <body> <div id="stars"> <div class="star">1</div><div class="star">2</div><div class="star">3</div><div class="star">4</div><div class="star">5</div><div class="star">6</div><div class="star">7</div><div class="star">8</div><div class="star">9</div><div class="star">10</div> </div> I tried dislpay:inline; for the #stars and the .stars CSS, but inline makes the images disappear. They only show when I remove "inline", but they are stacked in a vertical row. I need them to be horizontal. Here's the link: click here Can someone show me what I doing wrong? thanks I know that display:inline is supposed to change a Block element to view like an inline element. I take that to mean that the display:inline will eliminate any added space the Block element has in it. Meaning images and text will butt up against each other, but it's not working the way I expected. I have a list with images that I want to butt up against each other vertically . These images stack on top each other and to the left. The list has zero pixels for padding and margins. In the browsers that 5 pixel line shows up unless I code in a <p> then I adjust the <p> to have no padding or margin. EX: Code: <div id="maincontent"> <ul> <li class="hoodmenu"><p><a href="#"><img src="bu_streetware.jpg" alt="street ware"></a></p></li> <li class="hoodmenu"><p><a href="#"><img src="bu_dolls.jpg" alt="womens"></a></p></li> <li class="hoodmenu"><p><a href="#"><img src="bu_dudes.jpg" alt="guys"></a></p></li> <li class="hoodmenu"><p><a href="#"><img src="bu_beginners.jpg" alt="children"></a></p></li> </ul> </div> This seems like a hack. I have tried using display;inline but the spaces still appear. The code validates in 4.01 HTML and in CSS3. I also noticed I don't have to use the <p> in Opera or Safari, but I do for Firefox. Is this the correct way to handle this problem? If not, how should I actually write the code? Thank you! Thanks for taking the time to read my question. I have two containers that I want to line up at the top. I can't seem to make them line up. I have a picture inside a <div>, then I have a paragraph. It works in IE7, but in FF, the <p> appears under the picture. If I put a width on the <p> it moves up, but never up all the way so that it is inline with the picture. I'm stumped and not sure what to do. I tried putting display:inline; on either classes, and on both classes at the same time. Not sure what else to do. If I put a width on the <p>, it looks like this in FF |------| |Icon | |---------------------------| |------| | ElevatorSpeech ES2..........| .............|---------------------------| It looks like this if I have no width on <p> |------| |Icon | |------| |---------------------------| |ElevatorSpeech ES2...........| |---------------------------| HTML: Code: <div class="ESContainer"> <p class="Title1">Control</p> <div class="Icon"><img src="Images/Remote.jpg" align="Zone All Control Remote Control" /></div> <p class="ElevatorSpeech ES2">Control your surroundings with confidence, get the results you deserve.</p> <p class="ElevatorFull"><span class="EFLargeText">Zone-All</span> has been manufacturing room comfort temperature controls for more than two decades. Its variable air volume and variable temperature solutions for zone controls are applicable to heating and cooling systems that are designed using both incremental HVAC units and central station air handlers.</p> </div> CSS: Code: .Icon { float: left; margin-left: 10px; padding: 0px; height: 100px; background-color:#FF0000; } .ElevatorSpeech { font-size: 19px; margin-left: 10px; margin-right: 10px; float: left; padding: 0px; /*width: 225px;*/ background-color:#FFFF00; } Thanks, Brad Please look at this site - http://www.hitechtranny.com In FF and IE7. Notice in FF that the last link "Contact" on the main nav does not fit? I use this navigation on numerous sites and I always get this problem. Is there a quick fix such as a margin/padding issue I am missing that would fix this? Thanks. Tom hi, I am having problems with nav list It displays inline on firefox but not in IE..but I can not see why? any ideas?? thanks PHP Code: /* NAV */ #nav { width: 420px; height: 70px; float: right; margin: 0; padding: 0; } #nav li.on ul, #nav li.off ul { margin: 0; padding: 0; } #nav a { text-decoration: none; } #nav li { /*float the main list items*/ margin: 0; float: right; display: inline; padding-right: 0px; background: url(../images/pipe.gif) no-repeat; background-position: 0 10px; } .noback { background: none; } #nav li ul { display: none; float: right; } #nav li.off ul, #nav li.on ul { /*put the subnav below*/ position: absolute; top: 88px; *top: 104px; left: 503px; padding-top: 10px; height: 28px; width: 420px; } #nav li a { color: #155089; font-size: 20px; display: block; height: 15px; padding: 10px; background-position: 0 10px; } #nav li.on a { color: #000; background-position: 0 10px; } #nav li.on ul a, #nav li.off ul a { float: left; /*ie doesn't inherit the float*/ border: 0; color: #C1D1E0; width: auto; margin-right: 0px; font-size: 18px; line-height: 0px; background: none; } #nav li.on ul { display: block; background: none; } #nav li.off:hover ul { display: block; z-index: 6000; background: #fff; } #nav li.off a:hover, #nav li:hover a { color: #000; background: #fff; background: url(../images/pipe.gif) no-repeat; background-position: 0 10px; } #nav ul li.off a:hover, #nav ul li:hover a { color: #000; background: none; } ul#nav li.off ul li, ul#nav li.on ul li { background-image:none; } ul#nav li.off ul li a:hover, ul#nav li.on ul li a:hover { background-image:none; } ul#nav li.on a.nopipe, ul#nav li.off a.nopipe { background-image:none; } /* END OF NAV */ and the html PHP Code: <div id="divnav"> <ul id="nav"> <li class="off"><a href="#">contact</a></li> <li class="off"><a href="#">products</a> <ul> <li><a href="#">testemonials</a></li> <li><a href="#">samples</a></li> </ul> </li> <li class="off"><a href="#">about us</a> <ul> <li><a href="#">processes</a></li> <li><a href="#">plant list</a></li> <li><a href="#">benefits</a></li> <li><a href="#">features</a></li> </ul> </li> <li class="on" style = "background-image:none;"><a href="#" class = "nopipe">home</a></li> </ul> </div> thank you Hi, My site is loading fine in IE but messing up in FF, the tables (yes tables, sry) are loosing all height and widths. Ive had a look about but cant work out how to fix/get around this. HTML Code: <div id="products"> <table border="0" cellpadding="0" cellspacing="0" bgcolor="#ED1C24" style="width:194px; height:114px; margin-right:5px;margin-bottom:5px;"> <tr> <td align="left" class="code" style="padding-left:3px;"> AKA </td> <td align="right" class="name" style="padding-right:3px;"> TITLE </td> </tr> <tr> <td colspan="2" align="center" valign="middle" style="background-image: url(images/item_bg.gif); background-repeat:no-repeat;"> <a href="details.php?id=CODE"> <img src="images/products/photos/CODE.jpg" alt="TITLE" border="0" style="height:84px; width:184;" /></a> </td> </tr> </table> </div> CSS Code: #products { padding-bottom:10px; line-height:20px; font-family:Arial, Helvetica, sans-serif; font-size:11px; letter-spacing:1px; display:inline-table; vertical-align:top;} #products table {display: inline} How can i get the same effect so FF looks the same as IE? Thanks for any help. Mike I'm new to CSS (Other then very basic CSS) Anyway I have a menu which uses a tags, that also have a background image. I am adding in the background image with CSS, I have the display set to inline-block as block would put everything to the next line and inline would not allow for the image to show though in full (only enough for the text inside the link. Anyway using display: inline-block it seems to put padding on the links, is there a way to remove this? i want the background images from the links to be next to each other with no spacing or padding. My code: #buttonBackground { display: inline-block; background-image:url(/media/images/button_background.jpg); background-repeat:no-repeat; width: 113px; padding-top: 4px; height: 23px; text-align:center; vertical-align: bottom; (This isn't working either?) } and a sample link: <a href="default.asp" id="buttonBackground">HOME</a> Anyone able to help me remove the padding surronding the a tag? Okay i have been working on this for a while now, and i hate asking for help.. but i have given up on it. Firstly i started using display:inline-block; which meant i could have a width so my hover over menu effect would work. But this did not work in IE7 which means it is useless to what i am doing. So i then moved onto Display:inline; This worked fine, in both IE and Firefox, but the width cannot be set with this value. This value just wraps itself around the content. But i need to set a width to the Inline value. Any help? CSS: Code: #navcontainer ul{ margin: 0; padding: 0; list-style-type: none; text-align: center; } #navcontainer ul li { display: inline; width: 65px; height: 21px; background: url("images/tabbg.gif") 0 0 no-repeat; text-decoration: none; text-align:center; } #navcontainer ul li a{ display:inline; width: 65px; height: 21px; background: url("images/tabbg.gif") 0 0 no-repeat; text-decoration: none; } #navcontainer ul li a:hover{ background-position: -65px 0; color:#FFFFFF; } html: Code: <div id="navcontainer"> <ul> <li><a href="#">Milk</a></li> <li><a href="#">Eggs</a></li> <li><a href="#">Cheese</a></li> <li><a href="#">Vegetables</a></li> <li><a href="#">Fruit</a></li> </ul> </div> Also a link to the actual page is http://www.therow2.com/adsense/zzzzzzzzzzzzzzz.php |