Solved

Picture wrapping in CSS

Posted on 2004-09-02
8
303 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
Comment Utility
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
Comment Utility
and to justify the text use:

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

Author Comment

by:basiclife
Comment Utility
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
 
LVL 5

Author Comment

by:basiclife
Comment Utility
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 4

Expert Comment

by:PeterCN
Comment Utility
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
Comment Utility
and try to get some sleep if you can :-)
0
 
LVL 31

Expert Comment

by:seanpowell
Comment Utility
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
Comment Utility
Cheers all. Much appreciated.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now