Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Picture wrapping in CSS

Posted on 2004-09-02
8
307 Views
Last Modified: 2008-02-26
Ok, I have to admit I'm not sure if this is possible - I haven't played with CSS much but I'd imagine it must be...


I want to have a picture in my document and have the text wrap around it. (ie more than one line of text next to picture)

My first solution would be to use a table, however, if the user has a different browser are size to me then there will either be too much text next to the picture or too little, giving the wrong look. I'm after something like...


Heading

Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here.
|||||||||||||||||||||||| Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here.
|||||||||||||||||||||||| Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here.
|||||||||||||||||||||||| Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here.
|||||||||||||||||||||||| Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here.
|||||||||||||||||||||||| Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here.
|||||||||||||||||||||||| Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here.
Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here.

Ideally, I would also like the text fully justified

I'm sure Word could export something that does this as "HTML" but tbh I don't want 8,000 lines of code just for this one thing :-)

Thanks in advance
0
Comment
Question by:basiclife
  • 4
  • 3
8 Comments
 
LVL 4

Accepted Solution

by:
PeterCN earned 500 total points
ID: 11961264
float (css) does that :-)  And perhaps you might want to use a classname for floating images, so that other images don't unneccessarily start to float:

<img src="someimage.jpg" class="picture">
<p>
     Lots of text....
</p>

css:

img.picture {
   float:left;
}
0
 
LVL 4

Expert Comment

by:PeterCN
ID: 11961270
and to justify the text use:

p {
    text-align:justify;
}
0
 
LVL 5

Author Comment

by:basiclife
ID: 11961339
Stuning. Give me 10 minutes to play. I'm guessing I can use right and center as well (although not sure why I'd want center :-D)
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 5

Author Comment

by:basiclife
ID: 11961378
I have played and it works. One more question, if you don't mind:

Is it possible to have a non-rectangular "float" ie a transparent gif with the text wrapped to it? I have some circular images and of the text could follow the curve it'd look a lot nicer than a straight line. I understand that this would be technically wrapping around AND writing over so I'm guessing it's not possible. If you know, however, I'd appreciate it.

Please excuse typing. It's 09:30 and I haven't slept yet - No sleep and Caffeine makes for great creativity but bad typing
0
 
LVL 4

Expert Comment

by:PeterCN
ID: 11961546
Floating around curves or slants is possible, but tricky. Everything in html is basically a rectangular shape, so curves don't really exist, but you could layer a few floating elements and visually fake a curve. There are a few demo's of this on Meyerweb:

slantastic
http://www.meyerweb.com/eric/css/edge/slantastic/demo.html

curvelicious
http://www.meyerweb.com/eric/css/edge/curvelicious/demo.html

pyramidal
http://www.meyerweb.com/eric/css/edge/slantastic/demo2.html

enjoy :-)
0
 
LVL 4

Expert Comment

by:PeterCN
ID: 11961549
and try to get some sleep if you can :-)
0
 
LVL 31

Expert Comment

by:seanpowell
ID: 11964924
Very funny Peter ...

If you're talking about text wrapping around a curve, I can't think of a better example :-)
http://www.bigbaer.com/css_tutorials/css.image.text.wrap.htm
0
 
LVL 5

Author Comment

by:basiclife
ID: 11969896
Cheers all. Much appreciated.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
remove background quote mark from widget 6 66
Looking for magnifying glass wingding font 3 18
Only three borders showing on image 5 28
div to fit another div 8 28
Unordered lists (HTML ul tags) are very handy to create menus of all types, shapes and sizes.  All it takes is a little knowledge of CSS and the possibilities are endless. First off, you should know the general format for menus created using the …
When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question