views:

121

answers:

2

hi,

I've 2 sets of thumbnails and in each set I'm displaying them one nearby each other in 4 columns using float:left.

I would like to "merge" the 2 sets (but I cannot change the html code) because I want the thumbnails of the second set floating right after the last thumbnail of the first set.

In other terms, if in the last row there are only 2 thumbnails and the last 2 columns are empty, the thumbnails of the second set should fill the empty columns of the last row of the first set.

This is the code...

<div class="field field-type-filefield field-field-image">
    <div class="field-items">
            <div class="field-item odd">
                    <a rel="lightbox[field_image][First image&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;/lancelmaat/content/stalkshow&quot; id=&quot;node_link_text&quot; class=&quot;active&quot;&gt;View Image Details&lt;/a&gt;]" href="http://localhost/lancelmaat/sites/default/files/files/projects/Stalkshow/images/LPrisPetjong.jpeg" class="lightbox-processed"><img width="89" height="89" title="" alt="First image" src="http://localhost/lancelmaat/sites/default/files/imagecache/galleryImage/files/projects/Stalkshow/images/LPrisPetjong.jpeg"&gt;&lt;/a&gt;        </div>
              <div class="field-item even">
                    <a rel="lightbox[field_image][Second image&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;/lancelmaat/content/stalkshow&quot; id=&quot;node_link_text&quot; class=&quot;active&quot;&gt;View Image Details&lt;/a&gt;]" href="http://localhost/lancelmaat/sites/default/files/files/projects/Stalkshow/images/SeoulLEDScreen2a.jpeg" class="lightbox-processed"><img width="89" height="89" title="" alt="Second image" src="http://localhost/lancelmaat/sites/default/files/imagecache/galleryImage/files/projects/Stalkshow/images/SeoulLEDScreen2a.jpeg"&gt;&lt;/a&gt;        </div>
              <div class="field-item odd">
                    <a rel="lightbox[field_image][Third image&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;/lancelmaat/content/stalkshow&quot; id=&quot;node_link_text&quot; class=&quot;active&quot;&gt;View Image Details&lt;/a&gt;]" href="http://localhost/lancelmaat/sites/default/files/files/projects/Stalkshow/images/SeoulSKT6.jpeg" class="lightbox-processed"><img width="89" height="89" title="" alt="Third image" src="http://localhost/lancelmaat/sites/default/files/imagecache/galleryImage/files/projects/Stalkshow/images/SeoulSKT6.jpeg"&gt;&lt;/a&gt;        </div>

</div>


<!-- second set -->
<div class="field field-type-filefield field-field-video">
    <div class="field-items">
            <div class="field-item odd">
                    <a rel="lightbox[field_video][Video Number 1&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;/lancelmaat/content/stalkshow&quot; id=&quot;node_link_text&quot; class=&quot;active&quot;&gt;View Image Details&lt;/a&gt;]" href="http://localhost/lancelmaat/sites/default/files/files/projects/Stalkshow/videos/StalkSeoul8d1Mbps.flv" class="lightbox-processed"><img title="" alt="Video Number 1" src="http://localhost/lancelmaat/sites/default/files/imagecache/galleryVideo/files/projects/Stalkshow/videos/StalkSeoul8d1Mbps.flv"&gt;&lt;/a&gt;        </div>
              <div class="field-item even">
                    <a rel="lightbox[field_video][Video Number 2&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;/lancelmaat/content/stalkshow&quot; id=&quot;node_link_text&quot; class=&quot;active&quot;&gt;View Image Details&lt;/a&gt;]" href="http://localhost/lancelmaat/sites/default/files/files/projects/Stalkshow/videos/stalkshowdvd21Mbps.flv" class="lightbox-processed"><img title="" alt="Video Number 2" src="http://localhost/lancelmaat/sites/default/files/imagecache/galleryVideo/files/projects/Stalkshow/videos/stalkshowdvd21Mbps.flv"&gt;&lt;/a&gt;        </div>
              <div class="field-item odd">
                    <a rel="lightbox[field_video][Video Number 3&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;/lancelmaat/content/stalkshow&quot; id=&quot;node_link_text&quot; class=&quot;active&quot;&gt;View Image Details&lt;/a&gt;]" href="http://localhost/lancelmaat/sites/default/files/files/projects/Stalkshow/videos/StalkShowMoscow1Mbps.flv" class="lightbox-processed"><img title="" alt="Video Number 3" src="http://localhost/lancelmaat/sites/default/files/imagecache/galleryVideo/files/projects/Stalkshow/videos/StalkShowMoscow1Mbps.flv"&gt;&lt;/a&gt;        </div>
        </div>
</div>

How can I merge these divs in order to use float:left property on their children ?

thanks

A: 

If you're looking to add properties to a selectors children use

.field-items *
{
    float: left;
}

The wildcard selector * will select all of the field-items class' children. Now this may not be a final solution to the problem, but it's at least a start.

Alex Larzelere
yeah, this is the starting point. The difficult point is how to merge the 2 divs.
Patrick
If you remove the borders around everything, visually they will be merged. if you want a border around both divs so that they appear merged, then that's just some fancy border footwork. (top, right, bottom on one and top, left, bottom on the other)
Alex Larzelere
this doesn't solve the issue, I guess. I copy paste here part of the question: "In other terms, if in the last row there are only 2 thumbnails and the last 2 columns are empty, the thumbnails of the second set should fill the 2 empty columns of the last row of the first set".. and not start a new row leaving the previous row empty.
Patrick
The only thing I can think of is to change them to `display:inline;` and see if that works, but honestly you're likely going to have to manually position them to fit together. Why can't you change the html?
Alex Larzelere
because my CMS (drupal) is grouping fields by groups (images and videos in this case). My customer needs to upload files from the back-end. But in the front-end these 2 fields should be merged.
Patrick
Ahhh.... Wouldnt' it be more practical in the long run to change how Drupal presents the fields, rather than use CSS to fake it? I'm running into a similar situation where I used some CSS to hide some structural faults in the html, and now that we want to make changes it's turning into a nightmare.
Alex Larzelere
A: 

Is this what you're looking for? I don't fully understand but I'm thinking this might send you in the right direction...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Example - Thumbnails in 4 columns</title>
        <style>
<!--
.field-items {
    width:380px; /* 4 columns x 95px columns...
                    each column is an 89px thumbnail and 6px of border  */
}
.field-items a {
    float:left;
    text-decoration:none;
}
/* Just for demo purposes */
.set-1 img {
    border:3px solid red;
}
.set-2 img {
    border:3px solid green;
}
.set-3 img {
    border:3px solid blue;
}
-->
        </style>
</head>
<body>

    <div class="field field-type-filefield field-field-image set-1">
        <div class="field-items">
                <div class="field-item odd">
                        <a href="#" class="lightbox-processed"><img width="89" height="89" title="" alt="First image" src="http://richard.jp.leguen.ca/images/lenna.jpg"&gt;&lt;/a&gt;
                </div>
                <div class="field-item even">
                        <a href="#" class="lightbox-processed"><img width="89" height="89" title="" alt="Second image" src="http://richard.jp.leguen.ca/images/lenna.jpg"&gt;&lt;/a&gt;
                </div>
                <div class="field-item odd">
                        <a href="#" class="lightbox-processed"><img width="89" height="89" title="" alt="Third image" src="http://richard.jp.leguen.ca/images/lenna.jpg"&gt;&lt;/a&gt;
                </div>
         </div>
    </div>


    <!-- second set -->
    <div class="field field-type-filefield field-field-video set-2">
        <div class="field-items">
                <div class="field-item odd">
                        <a href="#" class="lightbox-processed"><img title="" alt="Video Number 1" src="http://richard.jp.leguen.ca/images/lenna.jpg"&gt;&lt;/a&gt;
                </div>
                <div class="field-item even">
                        <a href="#" class="lightbox-processed"><img title="" alt="Video Number 2" src="http://richard.jp.leguen.ca/images/lenna.jpg"&gt;&lt;/a&gt;
                </div>
                <div class="field-item odd">
                        <a href="#" class="lightbox-processed"><img title="" alt="Video Number 3" src="http://richard.jp.leguen.ca/images/lenna.jpg"&gt;&lt;/a&gt;
                </div>
                <div class="field-item even">
                        <a href="#" class="lightbox-processed"><img title="" alt="Video Number 2" src="http://richard.jp.leguen.ca/images/lenna.jpg"&gt;&lt;/a&gt;
                </div>
        </div>
    </div>

    <!-- third set -->
    <div class="field field-type-filefield field-field-video set-3">
        <div class="field-items">
                <div class="field-item odd">
                        <a href="#" class="lightbox-processed"><img title="" alt="Video Number 1" src="http://richard.jp.leguen.ca/images/lenna.jpg"&gt;&lt;/a&gt;
                </div>
                <div class="field-item even">
                        <a href="#" class="lightbox-processed"><img title="" alt="Video Number 2" src="http://richard.jp.leguen.ca/images/lenna.jpg"&gt;&lt;/a&gt;
                </div>
                <div class="field-item odd">
                        <a href="#" class="lightbox-processed"><img title="" alt="Video Number 3" src="http://richard.jp.leguen.ca/images/lenna.jpg"&gt;&lt;/a&gt;
                </div>
        </div>
    </div>

</body>
</html>

In-browser you hey something like this:

alt text

This working, however, rests upon the assumption that all thumbnails will be 89px by 89px. Aditionally, you have to make sure that any element of class field-items does not have the CSS property overflow-y:hidden.

LeguRi
hi, thanks for the answer. The issue is that the parent divs have not the same number of thumbnails, so I cannot assume parent div = row. (if I understood well your code).
Patrick
The issue here is that I need the children of the second parent to continue the float:left property effect of the children of the first parent div, in order to fill the empty cells on the last row of the previous parent div.
Patrick
Have you looked at it in a browser? This still makes 4 columns if I change the number of items per row.
LeguRi
I'm sorry it looks like what I need.. I will implement it and let you know thanks
Patrick
np. The catch is you need some kind of parent element (a `<div>` perhaps?) around all the 'rows', and you need to give that element an `overflow-y:hidden;` property, and it can't have a `height`.
LeguRi
ok it worked, I didn't know you can float elements even if they belong to different divs (!). Unluckily I cannot test it on IE yet, the website is offline. Is your solution cross-browser??
Patrick
It should be, but I don't guarantee it ;)
LeguRi