Solved

Picture wrapping in CSS

Posted on 2004-09-02
8
317 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
[X]
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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

728 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