Forum Moderators: not2easy

Message Too Old, No Replies

Question about CSS Theory

...and differences between IE and FF

         

tchallies

2:46 pm on May 13, 2005 (gmt 0)

10+ Year Member



I have the following code:

a.list {
background: #f2eee6;
border: 1px solid #c3c3c1;
display: block;
font-size: 10px;
padding: 6px;
text-decoration: none;
width: 280px;
min-height: 70px;
margin: 4px 8px 2px 8px;
}

I am using it to create a box that, when hovered on, has a changing border color. The box can be clicked to navigate. Inside the box is a basic span (with no formatting).

In Internet Explorer it stretches vertically to take whatever is inside it. In Firefox it does not, so if whatever is inside is too high it overflows the box.

What can I do to make FF stretch like IE?

Stormfx

3:39 pm on May 13, 2005 (gmt 0)

10+ Year Member



Hmm, I can't tell completely what you're talking about. Can post the html of the 'box'?

tchallies

4:31 pm on May 13, 2005 (gmt 0)

10+ Year Member



Sure. Here it is:

<a href="title.php?id=110" class="list"><span><img src="books/thumbs/bookcover.jpg" align="left" style="padding-right: 6px;" /><strong>Book Title</strong> by Author<br />1 Review</span></a>

So the entire a.list becomes a clickable box...

fischermx

6:22 pm on May 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've seen those clickable boxes done with similar techniques before, but never seen one vertically stretchable.

I took your CSS and Html and has been trying it for a while, with different combinations and always getting the same result : it does not stretch in firefox.

fischermx

6:29 pm on May 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think I found it, please take a look :


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>asdf</title>

<style type="text/css">
a.list {
background: #f2eee6;
border: 1px solid #c3c3c1;
display: block;
font-size: 10px;
padding: 6px;
text-decoration: none;
width: 280px;
min-height: 70px;
margin: 4px 8px 2px 8px;
overflow:hidden;
}
</style>

</head>

<body>

<br>

<a href="title.php?id=110" class="list">
<span style="float:left">
<img src="imagen.jpg" style="padding-right: 6px;">
</span>
<span style="float:left">
<strong>Book Title</strong> by Author<br>
1 Review
</span>
</a>

</body>
</html>

tchallies

6:40 pm on May 13, 2005 (gmt 0)

10+ Year Member



fischer - that may have done it. I'm going to play with it some more and make sure...

createErrorMsg

8:04 pm on May 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The reason the <a>nchor does not expand to contain the contents of the <span> is that the span if floated.

When you float an element, you pull it out of the flow, so that it no longer interacts with other elements on the page (except in very limited ways), including the element's container. In compliant browsers, this means that a float has no influence on the height of it's container. (IE auto-encloses floats in direct violation of the float specs).

In order to get a float to control the height of it's container, you can (a) use a clearing element, (b)float the container, or (c) use fischermx's overflow fix (any value other than overflow:visible will do it).

Which one to use depends entirely upon which fits better into your particular application.

cEM

fischermx

9:14 pm on May 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



createErroMsg :
Did you mean both clear and float the container at the same time, right? (not as separate solutions)

So, this works :


<style type="text/css">
a.list {
background: #f2eee6;
border: 1px solid #c3c3c1;
display: block;
font-size: 10px;
padding: 6px;
text-decoration: none;
width: 280px;
min-height: 70px;
margin: 4px 8px 2px 8px;
float:left;
clear:both;
}

But "float:left" alone does not do the job since it starts to stack the boxes on the same row.
So, it is (a) and (b) together, or (c).

createErrorMsg

9:55 pm on May 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



fischer, if the boxes need to stack vertically, yes. If not, float without clear is still an option. There might also be circumstances where the container width would not allow for adjacent floating, in which case the floats would stack vertically via their natural wrapping behavior. That's what I meant when I said, "Which one to use depends entirely upon which fits better into your particular application."

I only mentioned the float option to provide as wide a selection as possible. This way tchallies can pick the one that best suits his circumstances.

By clearing element, I meant adding an element to the bottom of the block level <a>nchor set to clear the left floated <span>. This element (<br />s and <hr />s set to visibility:hidden are most common) acts as a sort of wedge to prop open the float container. I'm not crazy about this method, but sometimes when floats or overflows would interfere with other CSS, it's necessary.

Your overflow solution is definitely one of the best. :)

cEM