Newbie :-Trouble aligning text within div tag

This is a discussion on "Newbie :-Trouble aligning text within div tag" within the Web Page Design section. This forum, and the thread "Newbie :-Trouble aligning text within div tag are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Nov 23rd, 2007, 06:43
New Member
Join Date: Sep 2007
Location: India
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Newbie :-Trouble aligning text within div tag

hi.
Following is the stylesheet part thats giving me trouble
Code: Select all
.author
{
background-image:url(Feather2.jpg);
background-repeat: no-repeat; 
background-attachment:fixed;
background-position: right bottom;
height:100px;
width:20%;
align:right;
vertical-align: bottom;
border:1px solid black;
}
I am using this as
HTML: Select all
<div class="author">by AUTHOR NAME</div>
The image is 103X100
the idea is to have a feather pic as background... and allow the author's name appear over the picture. and I want to have the text at the bottom-right corner .


Cant figure out what am i doing wrong here
Must be really simple and stupid.. that i must be missing.. but cant spot it
Please helpme
thanks in advance
Deepa
Attached Images
File Type: jpg Feather2.jpg (1.2 KB, 35 views)
Reply With Quote

  #2 (permalink)  
Old Nov 23rd, 2007, 06:52
Marc's Avatar
Moderator

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Age: 15
Posts: 1,650
Thanks: 0
Thanked 8 Times in 8 Posts
Send a message via MSN to Marc Send a message via Skype™ to Marc
Re: Newbie :-Trouble aligning text within div tag

I don't think you can use the vertical-align attribute as that is mainly for tables. Can somebody please prove me wrong?

You will need to use the padding-top attribute and work out how much space there is from the top of the div - (100-font size+5)px. I don't know but that's how i would do it .
Reply With Quote
  #3 (permalink)  
Old Nov 23rd, 2007, 07:10
New Member
Join Date: Sep 2007
Location: India
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Newbie :-Trouble aligning text within div tag

Thanks marc for the quick response

..the bloc is just 20% wide
and i want the author name toi be displayed in bottom right coner...
would padding-top work with names that are both long and shot ? ?
There must be someway to do this....
Reply With Quote
  #4 (permalink)  
Old Nov 23rd, 2007, 12:55
SuperMember

SuperMember
Join Date: Sep 2006
Location: Pink House
Posts: 3,946
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Newbie :-Trouble aligning text within div tag

The closest I think you can come is something like this:
Code: Select all
.author
{
background-image:url(Feather2.jpg);
background-repeat: no-repeat; 
height:30px;
width:20%;
border:1px solid black;
text-align: right;
padding-top:70px;
}
Reply With Quote
  #5 (permalink)  
Old Nov 29th, 2007, 07:48
New Member
Join Date: Sep 2007
Location: India
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Newbie :-Trouble aligning text within div tag

Well, afer several trial and error.. i gaveup on css for this
I used table and gave teh feater as background for the cell ..
.. not happy.. but works

thanks guys for the response
Deepa
Reply With Quote
  #6 (permalink)  
Old Nov 29th, 2007, 07:57
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Re: Newbie :-Trouble aligning text within div tag

Table huh?? If you thinks it solved your entire problem, you are wrong. By using table, you will have loading problem (slow loading) compare if you just use css.

That's how everyone learn in here! Find a problem and beat the hell of it until they solved it!
We not encourage you to take the short easy way by using table for your layout.

Hope that encourage you
Cheers..
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Reply With Quote
  #7 (permalink)  
Old Nov 29th, 2007, 08:00
New Member
Join Date: Sep 2007
Location: India
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Newbie :-Trouble aligning text within div tag

yes monie.. i know.. table is not a wise way to do
but this is a stopgap arrangement for me
.. for that matter.. i hate tables myself... i used css div at all times ...
but i am tottally exhaused.. i could not go any futher on this..
Reply With Quote
  #8 (permalink)  
Old Nov 29th, 2007, 08:52
welshstew's Avatar
Lead Administrator

SuperMember
Join Date: May 2007
Location: inside the outside
Posts: 1,378
Blog Entries: 13
Thanks: 1
Thanked 15 Times in 13 Posts
Re: Newbie :-Trouble aligning text within div tag

Deepa,

Never give up, take a few hours / days away from the problem then come back to it with fresh eyes. That seems to work for me.

Anyway, try the following, it seems to work for me in FF, IE7 an IE6 but you will need to test in Safari and Opera (if you are interested to see if it works across all browsers.

HTML: Select all
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
#author{
background-image:url('Feather2.jpg');
background-repeat: no-repeat; 
background-position: right;
height:100px;
width:20%;
display:block;
border:1px solid black;
}
#author span {
float:right;
margin-top:80px;
}
</style>
</head>

<body>
<div id="author"><span>by AUTHOR NAME</span></div>
</body>
</html>
__________________
WelshStew
Lead Administrator

tierney rides tboard - uk site | xtreme wales - extreme clothing
If you think I've helped, click the "Thanks"
webforumz - facebook | LinkedIn
Last Blog Entry: Web Standards Curriculum Launched (Jul 8th, 2008)

Last edited by welshstew; Nov 29th, 2007 at 08:57.
Reply With Quote
  #9 (permalink)  
Old Nov 29th, 2007, 08:59
SuperMember

SuperMember
Join Date: Jun 2007
Location: uk
Posts: 459
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Newbie :-Trouble aligning text within div tag

Have a look here.

http://www.the-art-of-web.com/css/textoverimage/

scroll down to CSS section.

Hope it helps.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS Aligning Wesley Web Page Design 15 Jan 20th, 2008 19:49
GD Aligning? PicoDeath PHP Forum 3 Aug 2nd, 2007 16:14
Vertically aligning text at the bottom Donny Bahama Web Page Design 6 Apr 16th, 2007 02:44
Text formatting trouble BGarner Web Page Design 4 Jan 8th, 2007 11:47
Formatting Text - XML newbie wants everything! AceTutor Other Programming Languages 0 Apr 28th, 2006 13:53


All times are GMT. The time now is 03:48.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43