CSS - Icons Next To Text Block
I'm trying to put an icon next to a block of text, but I have a bunch of strange width problems. I'd like it to be directly next to the news story, but without the text wrapping. So far, my solution causes the gap between the icon and the text to get really huge as resolution increases. What I want is for the icon to be about 20 or 30 pixels away regardless of the resolution.
Any simple way for me to do this? I'm still trying to get the hang of all this CSS stuff. News page: http://www.brickfilms.com/ Story code: Code: <div id='newsItem'><img src="<?echo $icon;?>" width="64" height="64" class="newsIcon"> <div id='newsText'> <h3 class='newsTitle'><?echo $title;?></h3> <p class='newsStory'><i>by <?echo $author;?>, <?echo $date;?></i><br> <?echo $story;?> </p> <br></div> </div> The CSS is at http://www.brickfilms.com/brickfilms.css Thanks in advance. Similar TutorialsGreetings, I've set an anchor tag to display:block and have set the height to 80px. Unfortunately, it seems I am unable to move the text associated within the hyperlink to the middle (vertically) of the block. Any ideas on how this can be done? Hi All, I built a website for a friend which is essentially working ok (thanks in large part to help I found on the net). She wanted to add a blog and I decided that this may be a good time to rework the site to a 960px width, partly to make it easier to make everything uniform. (A lot of blog templates are based on the 960) I have been working on a new homepage based on the old homepage but with things moved around slightly due to the new size. I also had a very long and convoluted CSS page before as it covered more than one page layout, so I decided to create a new simpler one just for this page. Basically I took all the elements from the old CSS page that applied to the original homepage and put them in the new one, changing positioning coordinates where appropriate. I've clearly done something wrong. While the text links are in the correct places, they're not supposed to be visible (they should be hidden behind the various icons. Those icons should in turn have a rollover effect - If you check the original homepage you can see what I mean.) The problem is something to do with the #nav1 and #nav2 attributes, but, because I'm a total newb, the original CSS was predominantly created by a couple of helpful souls I found online, but this means that I still don't really understand parts of it (though I am learning) Please help. This is my CSS: Code: * { padding:0; margin:0; list-style-type:none; } .link1 a:link,.link1 a:visited,.link1 a:active { color:#000000; font-family:arial,helvetica,sans-serif; font-weight:bold; } .link1 a:hover { background-color:#000000; text-decoration:none; } .link2 a:link,.link2 a:visited,.link2 a:active { color:#00def5; font-family:arial,helvetica,sans-serif; font-size:100%; font-weight:bold; } .link2 a:hover { color:#fff; background-color:#286d8c; text-decoration: none; } body { background-color:#000; font-family:tahoma,arial,helvetica,sans-serif; font-size:100%; text-align: center; } h1 { font:italic 16px tahoma,helvetica,arial,sans-serif; color:#fff; text-shadow: 0 1px 1px #000; text-align: center; } #container1 { width:960px; height:1186px; margin:auto; background-image:url(../images/Homepage-Image960.jpg); } #content1 { width:430px; height:50px; padding-top:460px; padding-bottom:20px; padding-right:5px; padding-left:5px; border:3px solid transparent; margin-top:0px; margin-bottom:155px; margin-right:0px; margin-left:66px; text-align:center; font-style:italic; overflow:auto; } #nav1 { margin-bottom:25px; overflow:hidden; } #nav1 li { margin-bottom:29px; } #li1 {margin-left:697px;} #li2 {margin-left:631px;} #li3 {margin-left:565px;} #li4 {margin-left:499px;} #li5 {margin-left:433px;} #li6 {margin-left:367px;} #li7 {margin-left:36px;} #li8 {margin-left:93px;} #li9 {margin-left:93px;} #li10 {margin-left:98px;} #li11 {margin-left:320px;} } #nav1 a,#nav2 a { position:relative; display:block; height:24px; background-image:url(../images/Homepage-Image960-Invert.jpg); } #nav1 span,#nav2 span { position:absolute; top:0; left:0; height:24px; z-index:1; background-image:url(../images/Homepage-Image960-Invert.jpg); cursor:pointer; } #about,#about span { width:239px; background-position:-697px -691px; } #appts,#appts span { width:305px; background-position:-631px -740px; } #fees,#fees span { width:371px; background-position:-565px -789px; } #faq,#faq span { width:437px; background-position:-499px -838px; } #links,#links span { width:513px; background-position:-433px -887px; } #blog,#blog span { width:579px; background-position:-367px -936px; } #about:hover span { width:239px; background-position:-697px -691px; } #appts:hover span { width:305px; background-position:-631px -740px; } #fees:hover span { width:371px; background-position:-565px -789px; } #faq:hover span { width:437px; background-position:-499px -838px; } #links:hover span { width:513px; background-position:-433px -887px; } #blog:hover span { width:579px; background-position:-367px -936px; } #nav2 li { float:left; display:inline; } #nav2 a { height:96px; } #nav2 span { height:96px; } #bps,#bps span { width:131px; background-position:-26px -972px; } #hps,#hps span { width:131px; background-position:-178px -972px; } #scp,#scp span { width:131px; background-position:-330px -972px; } #pay,#pay span { width:131px; background-position:-482px -972px; } #email,#email span { width:131px; background-position:-851px -972px; } #bps:hover span { width:131px; background-position:-26px -972px; } #hps:hover span { width:131px; background-position:-178px -972px; } #scp:hover span { width:131px; background-position:-330px -972px; } #pay:hover span { width:131px; background-position:-482px -972px; } #email:hover span { width:131px; background-position:-851px -972px; } And this is the HTML it applies to: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="language" content="english"> <meta http-equiv="Content-Style-Type" content="text/css"> <title>Helen Stow - Counselling Psychologist, Therapist, Life Coach.</title> <meta name="google-site-verification" content="3hCMQLpWU3lVVahmEEWDtI_wRso4VELEwEnMbYvlTBk" > <meta name="keywords" content="Lincoln, Psychologist, Counselling, Therapy, Therapist, Life Coach, Coaching, Paypal" > <meta name="description" content="Homepage for Lincoln based, BPS Chartered Counselling Psychologist, Therapist and Life Coach Helen Stow." > <meta name="abstract" content="Homepage for Lincoln based, BPS Chartered Counselling Psychologist, Therapist and Life Coach Helen Stow." > <meta name="author" content="Helen Stow" > <meta name="copyright" content="April 2011" > <meta name="contact" content="helenstowcpsychol@btinternet.com" > <meta name="googlebot" content="all, index, follow, none, noindex, nofollow, noarchive, nosnippet" > <meta name="revisit" content="2 days" > <meta name="subject" content="Homepage for Lincoln based, BPS Chartered Counselling Psychologist, Therapist and Life Coach Helen Stow." > <meta name="title" content="<title>Homepage for Counselling Psychologist, Therapist and Life Coach Helen Stow</title>" > <meta name="seoconsultantsdirectory" content="5" > <link rel="stylesheet" type="text/css" href="style_homepage.css"> </head> <body> <div id="container1"> <div id="content1"> <p><h1>Helen Stow is a Lincoln based, Counselling Psychologist, Therapist and Life Coach.</h1></p> </div> <div class="link1"> <ul id="nav1"> <li id="li1"><a id="about" href="http://helenstow-cpsychol.co.uk/about_helen.html" title="About">ABOUT<span></span></a></li> <li id="li2"><a id="appts" href="http://helenstow-cpsychol.co.uk/appts_fees.html" title="Appointments" >APPTS<span></span></a></li> <li id="li3"><a id="fees" href="http://helenstow-cpsychol.co.uk/fees.html" title="Fees">FEES<span></span></a></li> <li id="li4"><a id="faq" href="http://helenstow-cpsychol.co.uk/faqs.html" title="FAQs">FAQs<span></span></a></li> <li id="li5"><a id="links" href="http://helenstow-cpsychol.co.uk/links.html" title="Links">LINKS<span></span></a></li> <li id="li6"><a id="blog" href="http://helenstow-cpsychol.co.uk/blog/" title="Blog">BLOG<span></span></a></li> </ul></div> <div class="link1"> <ul id="nav2"> <li id="li7"><a id="bps" href="http://www.bps.org.uk/" title="http://www.bps.org.uk/">BPS UK<span></span></a></li> <li id="li8"><a id="hps" href="http://www.hpc-uk.org/" title="http://www.hpc-uk.org/">HPC UK<span></span></a></li> <li id="li9"><a id="scp" href="http://www.societyforcoachingpsychology.net/" title="http://www.societyforcoachingpsychology.net/">SCP UK<span></span></a></li> <li id="li10"><a id="pay" href="http://helenstow-cpsychol.co.uk/paypal_payment.html" title="Paypal Payments">PAY<span></span></a></li> <li id="li11"><a id="email" href="mailto:helenstowcpsychol@btinternet.com" title="Email Me">EMAIL ME<span></span></a></li> </ul></div> </div><!-- end #container --> </body> </html> I really would be incredibly grateful for all and any help. My very best wishes, Tom hello I am currently working on a website with a template from mambo open source. Unfortunately there are some icons built in the css that are rather ugly to look at. Would any one of you know how to hide them? thank you and regards, schnauzer I can't post URLs here, so please copy/paste the URL below. Look at the "email to friend" and "post to facebook" links on this page (url) proofs.gentryfoto.com/p/rswedding/1281copy27 (/url). My goal is to: 1. underline the text only, not the icon. 2. center the icons over the large image on the screen 3. Have it look the same in IE and FF. Currently, the icons are in the same row in IE, but are breaking into multiple lines in FF. I want them all on one line. What am I doing wrong? I am doing all kinds of experiments but can't get this right. Thanks. What I need to do is align a series of icons to the center, but there are a few complications, they must continue to be centered with any combination of 4-5 different(same sized) icons. For example icon 3 and 4, when displayed must be centered together, and at the same time, if icon 1 and 5 are being displayed they must also be centered correctly. First of all they are appearing on 2 seperate lines, and I seem to be unable to put them on the same line without using float:left on one. But I can't just float:left image one to put them on the same line, as image one may not be displayed in the next instance(with a different combination of images). And I don't think I can set a width on the div and center it because there will not be the same number of icons displayed in each instance(could be 1-5, 14x14 icons). My guess is that some % values can make this work but I'm just not sure how. I was going to post an illustration of what I mean but I guess it's blocked... Any help would be greatly appreciated. Thanks. http://warcraftpress.com/theme/theme.html I'm trying to have #footer be pushed down instead of the menu lapping over it. Basically, I want the menu to push it down, but it just overlays it. Thanks I would like to have a table with 6 td's across and the 7th td to break line and default to under neath the first td. I tried using display block and firebug outline the area where my content should be but it is still to the right of the 6th td. I would just like to do this to keep it in the same row so i can hide and show it dynamically outside of those first 6 td's. i coudnt find the forum search feature...? but anyone help with wht i am doing wrong? much appreciated Hi guys, can you give me some tips to centering a block (<div>) of code? I would like it centered vertically and horizontally and I would also like the background of the element centered (so the whole thing). text-align doesn't work, it only centers the text, not the element. Thanks, Josh Hi Guys, I have a generic Question/Problem to do with a Block Element (in this case a div) in an li tag. This seems to be a problem in browsers like IE8 and Safari but not IE7 and the latest FireFox version. Where with the div item 'drops down' a line from the li bullet. Like this (. is the li): . Here is My Div Content I want it to be like this: . Here is My Div Content Now this only doesn't happen if I just have plan text between the div with no class, so I'm thinking that something in my css dragHandle class may be at fault. Either that or I need to add something to it to do with float or display: line or block etc? Any thoughts or ideas are most appriciated (note I'm using a div in an li as I'm using the AJAX reorder list control and need something for a 'drag handle' to select an item in the list. The reorderlist uses ul and li to display itslef to I have to use this markup structure). Here is my markup. <ul> <li> <div class="dragHandle"> </div> </li> </ul> DragHandle class is as follows .dragHandle { width: 20px; height: 25px; background-image: url(/styles/icons/selectarrow.JPG); background-position: center; background-repeat: no-repeat; cursor: move; } Hi guys I was just wondering why cant i see these two <b></b> "blocks" on each side of my <UL> block in ie6 but in Firefox i can? Screenshot of situation: here is my code for the <b> blocks: PHP Code: .navbar b.lefty { display:block; position:absolute; z-index:604; height:100%; width:20px; top:0px; left:-20px; padding:0; margin:0; background-color:#ffffff; } .navbar b.righty { display:block; position:absolute; z-index:604; height:100%; width:20px; top:0px; left:136px; padding:0; margin:0; background-color:#ffffff; } Here is my code for the <UL> block: PHP Code: .navbar :hover ul { z-index:604; width:136px; top:40px; left:0px; padding:0; margin:0; background-color:#333333; text-align:left;} Now here is my HTML: PHP Code: <ul> <b class="lefty">d</b> <li><a href="#">Link</a></li> <li><a href="#">Link</a></li> <li><a href="#">Link</a></li> <li><a href="#">Link</a></li> <li><a href="#">Link</a></li> <b class="righty">d</b> </ul> In the attached gif, you should be able to see exactly what I mean, if I don't explain it well enough. I have a containing block, #content_main, defined as such: Code: #content_main { margin-left: 170px; padding: .5cm .25cm 50px; } Headers (h1, h2, h3, etc) are used inside #content_main and are defined like this: Code: h1, h2, h3, h4, h5, h6 { font-family: georgia, serif; border-bottom: 1px solid #009; } If you look at the attached gif, you'll see the problem. The top one is what happens. It extends the border-bottom to the width of the containing block, even though it places the text correctly. The second one "Something Else" is what I want it to look like. I edited that with Fireworks. Since it renders the same in Firefox and IE, I figure it's my code that's wrong. Any thoughts? MPEDrummer I have this CSS for my "globalNav" class: .globalNav {width: 217px; background-image:url(images/barbackground.jpg); background-color: #1B619E; background-repeat: repeat-x; border-right: 1px solid #075284; position: absolute; left: 0px; top: 125px; height: 450px} .globalNav A {background-color: #004E82; border-top: 1px solid #407AA1; border-bottom: 1px solid #00375C; border-right: #00406B; color: white; font-weight: bold; padding: 2px 5px 2px 5px; text-decoration: none; display: block} This is my code for globalNav: <div class="globalNav"> <a href="#">Global 1</a> <a href="#">Global 2</a> <a href="#">Global 3</a> <a href="#">Global 4</a> <a href="#">Global 5</a> <a href="#">Global 6</a> </div> For whatever reason, display block won't work in IE unless I remove the width, height, and positioning. Anyone know any tricks to make this work? Hi, im trying to create a block of colour of various width. Im trying to do it with <span> like so <span style="background-color:#336699; width:100px"></span> Now why wouldnt that work and is there a better way to do what im trying to achieve? Hey, I been wondering, when using XHTML Strict, what is considered the correct way of making a block level element (like a division) and the document body fill-out/fit the browser window vertically? The way I've been accomblishing this is by using javascript to set the height of the body when-ever the page is loaded and resized, though using something like this(of course, using document.documentElement.clientHeight for IE and using a more sane variable name for the sum of the top and bottom margins ) Code: document.body.style.height = (window.innerHeight - sumOfTopAndBottomBodyMargins) + "px"; and and setting the block level elements css height property to 100%. This works, but its lame! When resizing, the block level element doesn't get resized before you are done resizing and the appropriate event is fired. Not very 21th century. So, to sum up.. can some friendly soul please enlighten me on how I can do this in a decent way using only CSS? Cheers I have been reading about the problems regarding visibility with IE/FireFox/Safari. I have: Code: <input type="button" onClick="toggleSurveyView('block')"> <input type="button" onClick="toggleSurveyView('table-row')"> <tr id="surveyDetails"> <td>HI</td> </tr> function toggleSurveyView(visible) { document.getElementById('surveyDetails').style.display = visible; } In IE visible: block works great in FireFox/Safari visible: table-row works great. Is there a work around to get this visibility issue resolved for all browsers? Or am I going to have to perfrom some sort of browser type check? I just want to be able to toggle showing this table row on and off Hi, I was wondering if it's possible to put 2 block-level elements next each other without float and absolute positioning? Can you make them display as inline-elements so that they line up next each other? greets I have been using css for a while, but mostly just for style, not layout. I am trying to do a site, with basically three divs. One on the left for content, two on the right...one for a menu, and the other showing an image. I have stripped down the page to the smallest possible that I can show the problem. Basically, I want the image (red background) to be below the menu (dark purple bg), and both of them on the right of the content (lavendar bg). I have validated the html, but I am not getting a response from the css validator right now. Here is my html so far: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "(URL address blocked: See forum rules)"> <html> <head> <title>Vote YES Mosinee!</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <style type="text/css"> body{ padding: 0px; background-color: #FFF; text-align: center; font: 76% Verdana,Arial,sans-serif; } div#container{ width:800px; margin: 0 auto; text-align: left; background: #ff0; } div#content{ background: #d1c9e2; width:550px; } div#nav{ float: right; width:240px; background: #484393; } div#nav p{ padding: 5px 0; } div#nav h2{ font-size: 110%; color: #333; } div#imageSection{ float: right; width: 240px; background: #ff0000; } </style> </head> <body> <div id="container"> <div id="nav"> <ul> <li>There will be a menu here.</li> <li>It will have many items.</li> <li>It will have many items.</li> <li>It will have many items.</li> <li>It will have many items.</li> <li>It will have many items.</li> <li>It will have many items.</li> <li>It will have many items.</li> <li>It will have many items.</li> </ul> </div> <div id="imageSection"> <img src="(URL address blocked: See forum rules)" alt="Children"> </div> <div id="content"> <p>Vote YES is dedicated to reaching out to the members of the Mosinee community and to raising awareness of the situation our elementary students face each school day. Through their efforts, they hope to gain the support of Mosinee's voters and help the community create a facility that enables an optimal and safe learning environment.</p> <p>After years of failed referendums and the advent of another proposed addition, numerous community members have come together and organized "Vote YES" (VOTE for Your Elementary School). The organization was formed to support the referendum proposed by the school board and help educate individuals around the community. </p> <p>On April 3, 2007, the voters of the Mosinee School District will be asked to approve a referendum to address space inadequacies and safety issues at the current elementary school. The VOTE YES group formed for a number of different reasons. Teachers and parents found it difficult to ignore the glaring parking issues, overcrowding in the cafeteria, the use of hallways and storage closets for classes, and the 20-year band-aid solution of adding portable classrooms. Taxpayers couldn't ignore the problem and individuals throughout the community stepped forward to help. </p> <p>Many More Paragraphs....</p> </div> </div> </body> </html> How can I achieve this? I have several <a>'s on my page, where their display is set to block, and I want to put a submit button in each of them. When I put the <button> in the <a></a>, though, the submit button doesn't go to the processing page, it just goes where the <a> was headed. How to I get the submit button to go to the processing page and not where the <a> was headed? I could put the submit button below the <a> block, but that's very unattractive, and I want the user to be able to click anywhere in the block to go to the next page (except for where the submit button is.) Any help much appreciated! Hi! Is it OK to mix inline and block elements? For example: <imp ... /> <p> .... </p> Thanks I'm trying to use image sprites to make images on my website switch to another image when the user hovers over them. These images are each placed in their own td that are set at different percentages within a 100% table. The reason I need to use percentages is because I want the table and images to re-size to fit each individual computer screen. They do this beautifully, but when I add the image sprite, which has "display: block;" in its CSS, my images wont re-size. They just cut off. Is there a way to use image sprites without the display: block code? Or is there a similar way to make images seamlessly grow and shrink to fit a browser without using a width percentage? Thanks! |