CSS - Text Positioning In H1 Over Image
hey all,
i'm trying to figure out how to position text in an h1 tag that uses a background image, without adding extra markup. i just need it 15px from the left of the image, and 10px from the top. here's the css for the h1 tag: Code: h1 { height:50px; width:100%; background:white url(images/h1_background.gif) no-repeat left; margin-top:12px; color:white; font-size:11pt; } and the html is just; Code: <h1>welcome</h1> thanks! Similar TutorialsHi, I have a table cell where I have to place an image and title (centered) by the side of it. I am using the following code but does not work the way I wanted. <table> <tr> <td> <img src="graphics/gifs/spotlight_xlr.gif"> Title </td> </tr> </table> The "Title" text is getting displayed by the side of the image but to the bottom. I want the Text to be centered around the image. Both the IMG and Text should be part of the same TD tag. I know with CSS it is possible. Please help. Thanks, VMRao Hi Guys, Ive not been doing the CSS stuff too long as I used to use tables all the time for this stuff. Im ultimately trying to get 3 news articles for eg on a homepage with a mini image to the left of the text which wraps around it. The text sometimes is not going to be the size of the image so the next article needs to drop to the next line underneath. It isnt though and its listing in a diagonal line instead. Any one got any tips. Code: <div id="m1"> <div class="nw1"> <h2><a href="/">Money test title</a></h2> <p><img src="/includes/img/archive/100x77-0000000001.jpg" width="100" height="77" class="img1" />Latest shinanigans on the money savings scene today are... just gonna pack this out to see if the image does eventually fit in at all which would be nice because it should work! But who knows eh? :D Its just an interesting topic to look into la de dah de dah!</p><br /> </div> <div class="nw1"> <h2><a href="/">Money test title</a></h2> <p>Latest shinanigans on the money savings scene today are...<img src="/includes/img/archive/100x77-0000000001.jpg" width="100" height="77" class="img1" /></p><br /> </div> <div class="nw1"> <h2><a href="/">Money test title</a></h2> <p>Latest shinanigans on the money savings scene today are...<img src="/includes/img/archive/100x77-0000000001.jpg" width="100" height="77" class="img1" /></p><br /> </div> </div> Ive tried a few things like putting div's around each specific article see if i could somehow force it to a new line but it isnt working. The img tags ive moved about. Im using float left on them. Any one any suggestions? Im really stumped and close to hitting the monitor If it helps I could pm the url to you if you think u can help. Thanks guys. Im hoping this is a relatively easy problem as most sites layout like this just I can't get it to do it! hehe! Hi, I have centered a table horizontally and vertically. To do this I put a table inside a table. so i don't want to use absolute positioning, as the position would change if the window size changes... My problem, with relative positioning, is that I can't figure out how to put my "some text" over an image -which is inside the table cell- in the exact position i want, without "collateral damage"... The collateral damage is that if I put the <div> tag inside the table (see example 1), it will occupy the space and as result the image wll be moved down and layout won't be centered vertically anymore... If I put the <div> tag outside the table (see example 2), as result there will be more occupied space at the top, and the layout isn't centered anymore... Here you can see the code i used for both example 1 and example 2: example 1: <html> <head> <title>relative problem - example 1</title> </head> <body> <table width="100%" height=100% border="1"> <tr> <td width="100%" height="100%" align="center" valign="middle"> <table border=1> <tr> <td width="640" height="480"> <div id="Layer1" style="position:relative; left:50px; top:50px; width:50px; height:200px; text-align:left; overflow: auto; z-index:1;"> some text some text some text some text some text some text some text some text some text some text some text some text </div> <img src="http://www.pbworks.net/images/help.jpg" width="640" height="480"> </td> </tr> </table> </td> </tr> </table> </body> </html> example 2: <html> <head> <title>relative problem - example 2</title> </head> <body> <table width="100%" height=100% border="1"> <tr> <td width="100%" height="100%" align="center" valign="middle"> <div id="Layer1" style="position:relative; left:0px; top:200px; width:50px; height:200px; text-align:left; overflow: auto; z-index:1;"> some text some text some text some text some text some text some text some text some text some text some text some text </div> <table border=1> <tr> <td width="640" height="480"> <img src="http://www.pbworks.net/images/help.jpg" width="640" height="480"> </td> </tr> </table> </td> </tr> </table> </body> </html> thx for letting me know... 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? this is the first time im making a CSS website. w3schools.com really is a big help, but i came upon a problem. on the layout, on the upper left, i got my main menu. i positioned some text there with this code in <head> Quote: h1 { position: relative; top: 46px; left: 135px; font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #FFFFFF; } h2 { position: absolute; top: 63px; left: 135px; font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #FFFFFF; } ( as u can see, i tried "relative" but it doesnt work ) and then typed the links of the menu like this: Quote: <h1><a href="index.html">Home</a></h1> <h2><a href="aboutus.html">About Us</a></h2> ect. but when i rezise the browser or take a different resolution, then the text also moves along. the text doenst stay on its place on the menu. for example, if i make the length of the browser smaller, then the text moves out of the menubox, to the right. i hope u understand this. how can i make sure that the text will always stay on its place, on every browser size/resolution? Hello all, My second post . I have a div box with text in it. It looks fine in ie, but the text drops when viewed in mozilla. I have highlighted the border for clarity and want the text to remain directly underneath. I have tried adding styles to mainsection, the div in question, and also the p text attribute, with no joy. As with my last problem I am sure the solution is a simple style, but I can't find it. Any help would be much appreciated. thanks Solar. html page: http://darkspeed.atspace.com/Textest.htm CSS link: http://darkspeed.atspace.com/txtstyle.css thanks again. Hi Basically i have positioned some text on my site in the place i need, and it looks fine while the browser is maximised. But when i resize, the text moves to accommodate. Is there anyway i can have the text in the right place, but not move when the browser is resized? Thanks Hi Guys, Basically, I have Text in a content box, all fine and dandy, this content box has a fixed width and an expanding height depending on supplied content. I now need 2 further divs, one of which floats to the right, and positioned at the top of this content div, the other also floats right but needs to be alligned bottom. Ive tried absolutes with content being relative but although this does solve the positioning problem, obviously the content text will not wrap around the divs. ------------| ------------| ------------|_______| --------------------------- ------------------ ---------------------- ---------------------------- ------------------------ -----------| -----------| -----------| -----------|_______________| Basicaally like above (sorry, cant screenshot the project im working on :]) Code: <div style="width:591px; position:relative; z-index:1;"> <div style="width:150px; height:100px; float:right;"> ZZZZZZZZZZZ </div> <div style="width:150px; height:100px; float:right;"> ZZZZZZZZZZZ </div> <div style="width:291px; height:100px; float:left;"> asfasfasgsdgdsdbn gksdjbgvsdb gjkdgkjsdb gkjsdbgksd jb gjksgsd dkj kasfasfasgsdgdsdbn gksdjbgvsdb gjkdgkjsdb gkjsdbgksd jb gjksgsd dkj kasfasfasgsdgdsdbn gksdjbgvsdb gjkdgkjsdb gkjsdbgksd jb gjksgsd dkj k </div> <div class="clear"></div> </div> Hello, If you go to http://tombraiders.net/katie/sid/index.html User: letme Pass: in you'll see that the body text is shifted halfway down the page as well as the menu. Anyone know how I can fix this? Also, how can I fix the rollover for the menu? I don't want the rollover coloured square to be so long. Thanks! I'm trying to position some things inside a DIV. Here's the basic layout: What I did was put them in DIVs position them within the "parent" DIV relative to the upper left. Doesn't seem to work, so I'm doing something wrong. Image One is easy, but the text and Image Two I just don't seem to grasping. I've looked at the Floatutorial, I'm not grasping it, or the answer isn't there. Should the text block and Image Two be within a separate DIV? My problem is with 2 textfields that I am using css to text attributes, all is well in IE, but in netscape and firefox the letters q,y,p the bottoms get cut off. Any suggestions greatly appreciated. here is a link to the page i am working on http://www.cfwilson.com/365c/index.htm Charles Hi, I've recently built my first site using the Magento eccomerce paltform. I'm having a problem with the text box for the item descriptions on the product pages. The problem is that on page load the item description drops about 200px and overlaps outside of the text box area. This only happens in IE. I'm sure this is a CSS stylign issue but i'm not entirely sure what needs to be done or which attribute wil fix it. Any help would be appreciated. I'm not allowed to post urls on this forum as a new user but the website is a UK site called lowpricememory. The url is lowpricememory with dot co dot uk. You will see the problem on any product page. Thanks, Tim Its been a long time now and I am finnaly getting back into website desiging. I am doing a simple coding but I am having a hard time trying to figure out how to do the following. I want to create a table but using only divs. So basically I am going to have a parent div acting as the whole table then sub-div acting as each row, and within those divs there will be more divs acting as each cell. But I can't figure out how to make each cell be right next to each other instead of on the next line. How do I make it look like below: |<div>| |<div>| |<div>| |<div>| |<div>| |<div>| |<div>| |<div>| |<div>| |<div>| |<div>| |<div>| |<div>| |<div>| |<div>| |<div>| Also, what CSS properity do I have to use so that the content of each cell will overlap with all th surrounding cells? By overlap I mean so they will be touching each other. I'm pretty new to CSS so bear with me if this is a silly question. I want to go totally CSS and 0 tables. 1 problem that I've been having with my site is that I have several forms for data entry. These are of course done in 2 column tables, label in the 1st column, text box in the right. The problem I'm having is that I cannot get the text boxes to line up properly using CSS. I am trying a test page simulating a login page. But since the words Username and Password are different lengths, the left edges of the text boxes don't line up evenly. What is the best technique to get CSS to display 2 columns like a 2 column table where the first 'column' contains a text label and the 2nd column has the input boxes aligned nice and neat? Hi, Here is the problem I'm having: This: see attached cssprobl.jpg should become: http://www.thephotofactory.nl/csstest/cssprobl-goal.jpg Here's the CSS code I have: Code: body{ background-color: #FFFFCC; margin: 0px; padding: 0px; } .holder{ background-color: red; width: 250px; height: 400px; float: left; margin: 10px 10px; } .img{ padding: 0px; width: 200px; height: 200px; margin: 20px 10% 0px 10% ; border: 2px white solid; } h1{ font: 35px Arial, Helvetia, sans-serif; color: white; text-align: center; margin-top: 10px; } .omschrijving{ background-color: grey; font: 15px Arial, Helvetia, sans-serif; text-align: left; margin-top: 10px; padding: 5px; } .prijs{ font: 25px Arial, Helvetia, sans-serif; color: white; text-align: center; margin-top: 10px; } .dec{ vertical-align: super; font: 14px Arial, Helvetia, sans-serif; color: white; } .euro{ font: 14px Arial, Helvetia, sans-serif; color: white; } .omschrijvingholder{ background-color: black; width: 250px; height: 100px; margin-top: 0px; } .prijsholder{ background-color: green; width: 80px; height: 40px; vertical-align: bottom; float: right; } and this is one of the sections: Code: <div class="holder"> <h1>Theeglas </h1> <div class="img"> <img src="theeglas.jpg" alt="theeglas met bedrukking" title="theeglas met bedrukking" width=200 height=200></img> </div> <div class="omschrijvingholder"> <div class="omschrijving"> Een mooi theeglas met een doorzichtige bedrukking. </div> <div class="prijsholder"> <div class="prijs"> <span class="euro">€</span> 9,<span class="dec">95</span> </div> </div> </div> </div> SO: how do I get that green part exactly there (and without going outside the red box), and how do I wrap the text in the grey part around it? After 2 hours of trying all kinds of options I give up and call for help Here is the full link: http://www.thephotofactory.nl/csstest/valentijn.htm Second problem: in IE the white border around the img is too low, leaving a red space. How to avoid that? Thanks in advance, Papermouse PS How do I put an uploaded image in this message? Hi there, I recently started up an internship at a music magazine and they asked me to do a simple side site to present some information. I left it pretty simple for most of it but wanted to challenge myself a bit with some CSS for one of the pages. The page in question is the 05 Panel Page It looked better in Firefox earlier, but I recently made some changes according to the site editors which made it look a lot less clean in Firefox and damn ugly in IE. I would like to have that introductory block of text be where it is with the panel information on the left side and the photos and text wrapping where appropriate. I've been fiddling with padding a lot, but haven't made too much headway. I know that there's a lot going on to be helped out with specific parts (although I wouldn't mind if anyone could). But if you had any topics that I should concentrate looking up information on, then that would be just as helpful. Edit: I was also having problems giving the entire side enough padding to stay away from the edges of the browser window. However I ran into problems on the right side of the page: some of the text would go too far past the headers. And if that didnt happen, extra space in general appears on that right side. HTML -- CSS I decided my last layout looked like poop so I'm changing it. In FF the center logo fits right in the middle of the background image to give it a stretching effect. In IE the image is slightly above the baseline. (maybe 3-5 px) Any help here? Is this possible with css? I have a single table cell thats 100% wide. I want an image left aligned, an image right aligned and a background image spaning the entire cell. I also want to type text into the cell between the two images. Using html I get bugs in IE so I think css might be the better option? I'm working inside of a classifieds software app and trying to position a button inside an area that I don't have access to the raw HTML. I built the image file and I know where I want it to appear on the page, but don't know the correct parameters to put in to get it there. I would like it to find the center of the page then go left 190 pixels and be about 400 pixels down from the top. Site is http://www.ineedihave.com. In the code below, why is the image not positioned at the very top of the DIV in IE only (seems to be fine in FF)? Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Untitled</title> <style> .test { width: 200px; height: 100px; border: 1px solid #003366; } .image { position: relative; left: 0px; top: 0px; } </style> </head> <body> <div class="test"> <img class="image" src="images/block_up.gif" width="11" height="11" border="0" alt=""> </div> </body> </html> |