Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sandbag Div (text around image) problem 1

Status
Not open for further replies.

requested89

IS-IT--Management
Sep 6, 2005
44
GB
 
The example page you posted the link for looks fine for me in FF (Win)... so is there possibly any CSS from their page you didn't copy over that might cause it to break?

Hope this helps,
Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
When you say it looks fine, is the text on the page wrapping around the image of the face or is it going over it? It just goes over it on my computer as if the float is being ignored.

Thanks,

Chris
 
My page isn't done exactly the same it just uses the principle of the different length divs to control the flow of the text. The main problem is that I can't get the divs to line up correctly. They should be left right aligned but instead they seem to be left aligning which means the image doesn't look right.

By the way, the example site I gave (not mine but the tutorial) works fine in all the browsers I've tested as well.

Any ideas?

Thanks in advance.

Chris
 
Having the divs inside a span might be confusing it. It might also be confused by the fact you've declared a 50 pixel width for each div, regardless of the width of the image.

The tutorial you linked to actually uses a true background image for the girl, then overlays it with (what would normally be) empty <div>s floated into place like old fashioned spacer gifs.

The technique you're using - slicing up the actual image and floating the slices - is more akin to that shown on . Frankly, wrapping each image in its own <div> looks like overkill to me. Try marking it up like this:
Code:
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In hendrerit, dolor ut consectetuer convallis, diam tortor scelerisque eros, in volutpat purus nibh vulputate libero.
<span class="wrapright">
<img id="smr-00" src="assets/face_02.jpg" alt="" />
<img id="smr-01" src="assets/face_04.jpg" alt="" />
<img id="smr-02" src="assets/face_06.jpg" alt="" />
<img id="smr-03" src="assets/face_07.jpg" alt="" />
<img id="smr-04" src="assets/face_09.jpg" alt="" />
<img id="smr-05" src="assets/face_11.jpg" alt="" />
<img id="smr-06" src="assets/face_13.jpg" alt="" />
<img id="smr-07" src="assets/face_15.jpg" alt="" />
</span> 
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In hendrerit, dolor ut consectetuer convallis,
Then, instead of applying rules directly to #smr-00, #smr-01, etc. you can do this:
Code:
.wrapright img {
  float: right;
  clear: right;
  padding: 0;
  border: 0;
}
You may then need to add individual width rules for each slice (but try without first):
Code:
#smr-00 { width: 243px; }
#smr-01 { width: 251px; }
... etc ...

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Thanks guys problem sorted. It now renders perfectly in Firefox, IE, Safari & Netscape. It seems the problem was the width:50px being honored as you point out BillyRayPreachersSon.

Thanks for the help ChrisHunt, I've awarded you a star for your excellent pointers. I didn't realise I would be able to put them all in one span and then align that instead of individual divs. I actually thought that it should work yesterday in theory but after trying for a while it clearly didn't. Live and learn I guess.

By the way could you just help me out as to what the practical difference is between using an ID Selector over a Class Selector. Judging by what I've seen using a Class means you have to refer to a particular type of tag i.e. div, a, img etc whereas using an ID I could refer to any tag with the same ID. What is the benefit of using a Class?

Thanks in advance,

Chris
 
Class can be reused as many times as you want on a single website, while id uniquely identifies one element. That is the only difference.
 
I didn't realise I would be able to put them all in one span and then align that instead of individual divs.
That's not, technically, what my CSS does.
Code:
[green].wrapright[/green] [red]img[/red] {
  float: right;
  ... etc ...
}
applies the floating and so on to all [tt][red]img[/red][/tt] elements that are contained within an element with [tt]class="[green]wrapright[/green]"[/tt]. So it's still the individual images that are aligned, but I use the power of CSS to address them collectively rather picking them out individually with a [tt]class[/tt] or [tt]id[/tt].

Incidentally, if you don't need to explicitly assign a width to each one (and I don't think you do), you can dispense with the images' [tt]id[/tt] attributes too.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
I've re-read he CSS and I understand now ChrisHunt. The CSS is controlling the Img as you rightly point out.

It's pretty impressive stuff this CSS isn't it.

Thanks for you help.

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top