Technology, Web & Business Forum

You are here: Technology, Web & Business Forum : Web Development : Design : How to align text next to a picture using CSS?


Welcome to the Technology, Web & Business Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.


Design Talk about web design techniques and ideas in CSS, HTML, etc.


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-19-2008
K B K B is offline
Junior Member
 
Join Date: May 2008
Posts: 1
Default How to align text next to a picture using CSS?

This is the code I am using:

font, img{align:left; vertical-align:top;}

It works, but for only one text line. You can see what I mean here: http://www.neopets.com/~suxaona
I want the
Age:
Guild Job:
Hobby:
and Comment:
to be aligned with the avatar. How would I do this using CSS? Also I need the code to work to in both FF and IE.

Thank you in advance.
__________________
Powered by Yahoo! Answers
Reply With Quote
  #2 (permalink)  
Old 05-19-2008
Junior Member
 
Join Date: May 2008
Posts: 3
Default

you can use
img {
position:relative;
float:left;
}

note: img affects all images
use img.image1 instead

<img src="image_source" class="image1" />
makes the image stick to the left while "pushing" the text around it, just like in newspapers.

then format the text as you like
position:relative; is needed to avoid lots of bugs

the image will then float on the left with the text on the right
you can separate the text bits with the "break tag"
br /> (yahoo does not let me type the tags)

(note: add the image within the text to avoid some common errors)
example: <p><img src="#" />name"break"age"break" hobby"break"</p>

replace "break" with proper code <' br '/>

possible bug:
situation: you have text and images inside a container box wich has automatic height, if the image is floating and there is little text then the image will overflow the box.
if you have automatic height for the "text container"
add a div at the bottom and assign it "display:block; overlow:hidden height:1%;" this will move the bottom of the text container lower
which will now move


or you can <img src=”images/sample.jpg” height=”100” width=”75” align=”left” alt=”My Sample Image” />
align can have a value of left, right, and center

P.S. nice looking site by the way
__________________
Powered by Yahoo! Answers
Reply With Quote
Reply

Thread Tools
Display Modes

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


All times are GMT -5. The time now is 12:40 PM.