473,479 Members | 2,128 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Quadratic DIVs with not quadratic photos?

97 New Member
Hi there,

I have a nice collection of photos on my photoblog, for which I created as well an archive, which shows the last 50 or so photos at the same time.

Now, I would like to have the photos displayed all in the same size (although they are originally in different sizes, some cropped, some landscape, some portrait).

Is it possible via the use of CSS to "squeeze" the photos in for example a quadratic shape without deforming the photo? Thus only some part of the photo is being displayed, the other kind of masked?

Thanks for any hints!

Stef
Jul 25 '07 #1
11 2888
tburger
58 New Member
I'm not sure what you mean by quadratic shape, but I think you can at least limit all of the photos to a consistent size by setting a fixed height and width for the image and then hiding the overflow. I know this works when using an image for a background...

This would be more of a "thumbnail" approach...

Can you post a little more description on what you are looking for?

I like the gallery, by the way...very clean look...

Tom
Jul 25 '07 #2
luftikus143
97 New Member
I'm not sure what you mean by quadratic shape, but I think you can at least limit all of the photos to a consistent size by setting a fixed height and width for the image and then hiding the overflow.
Thanks for the flowers! And yes, perhaps there are different approaches... The thing is that I would like to display the photos in the gallery say in 150x150px size. That would mean that only parts of the photos is being displayed, as the relative size of the photos is in many cases 3:2 and not 1:1.

This "hiding the overflow" is exactly what I thought how it should work. But I have no idea how...

Could you give me some hints?!

Thanks a lot!
Jul 30 '07 #3
tburger
58 New Member
A couple of questions first:

1. Did you code the photoblog yourself or did you use a service/site/program to do it for you?

2. If you didn't code it, do you feel comfortable adding CSS to your archive's HTML?

3. You want the photos in the archive to link to a new page with the original photo displayed, correct?

If you answer these, I'm pretty sure we can work something out for you...

I won't go into too much detail (until you answer, that is), but here's the sort of thing I'm thinking...

We can essentially make a box for each of the pictures in your archive. Each box will be set to a constant, fixed size like 150 x 150 px. We would then make a given picture the "background-image" of one box. This would afford you the opportunity to see any 150 x 150 window of the photo using the "background-position" CSS attribute. Additionally, we could position each box independently on the page - creating any pattern we would like.

I can definitely help you further- this sounds like a cool project.

If you want to go it alone, I would try this code (for each div box you create):

Expand|Select|Wrap|Line Numbers
  1. #box
  2. {
  3.    position: absolute;
  4.    height: 150px;
  5.    width: 150px;
  6.    background-image: url(picturename.jpg);
  7.    background-repeat: no-repeat;
  8.    overflow: hidden;
  9.    left: xx; ( where xx is the number of pixels from the left of the page where the picture is to be placed)
  10.    top: xx; (where xx is " " from the top)
  11. }
  12.  
Sorry for the incomplete message...if you can answer the questions above, I think this is definitely possible...

Until again,

Tom
Jul 31 '07 #4
luftikus143
97 New Member
1. Did you code the photoblog yourself or did you use a service/site/program to do it for you?
Some parts have been developed by myself, some adopted from other script.

2. If you didn't code it, do you feel comfortable adding CSS to your archive's HTML?
No problem at all.

3. You want the photos in the archive to link to a new page with the original photo displayed, correct?
Yes.

Expand|Select|Wrap|Line Numbers
  1. #box
  2. {
  3.    position: absolute;
  4.    height: 150px;
  5.    width: 150px;
  6.    background-image: url(picturename.jpg);
  7.    background-repeat: no-repeat;
  8.    overflow: hidden;
  9.    left: xx; ( where xx is the number of pixels from the left of the page where the picture is to be placed)
  10.    top: xx; (where xx is " " from the top)
  11. }
  12.  
Hmmm, tried it, but have a problem with the "position: absolute" as each DIV is then superposed by another DIV...

Thanks for helping out!

Stef
Jul 31 '07 #5
tburger
58 New Member
will work on it tomorrow...i'll put an example up for you...

Tom
Aug 1 '07 #6
luftikus143
97 New Member
I won't be in the office until Monday. So, no worry if you don't hear anything from me... I am keen to see what you come up with! :-)
Aug 1 '07 #7
luftikus143
97 New Member
So?? Did you manage?
Aug 6 '07 #8
tburger
58 New Member
I believe so...let me finish up... I will post what I have tonight...

I'm on east coast time.

Tom
Aug 6 '07 #9
tburger
58 New Member
I commed you on your patience, luftikus. I apologize for the wait. I'm nearing the end of another website, and have been working hard to get it up and running before I head back west.

I put some thought into your question and here's what I came up with:

Tom's Unofficial Guide to Styling Photo Archives

First, we go ahead and create some div boxes that will act as the "frames" for our pictures. For the sake of ease, I have included the CSS styling within the HTML page (If you view the page source (right click), you'll see what I mean). Using "p1" through "p5" as identifiers for individual frames, I made all the boxes 150 by 150 px. Without CSS styling, these five boxes would rest on top of each other in the upper left corner of the page. But, by positioning each frame absolutely, we can move it anywhere we want on the page. In this example, I simply styled the boxes to be grey with a white border. I then arranged them to show this approach's flexibility:

Example #1

Just for fun, I played around with the boxes' colors. Check it out:

Example #2

Of course, it's entirely possible that your desired arrangement will look nothing like this. For dealing with actual photos, I spread the boxes out in an attempt to avoid overlap (unless you want it ;)) :

Example #3

Pretty cool...but we still haven't covered the real issue.....PHOTOS!!

I took a couple old pictures out of iPhoto and resized them to 216 by 162 px. You can leave them whatever size you would like, but remember that we are dealing with an 150px square window.

**On a side note, if you are using a Mac, I like to use Image Shackle to resize my photos....it's a really useful widget to have in your Dashboard...

Next, I assigned one of the pictures to each of the "frames" using the "background-image" attribute.

The necessary syntax is:
Expand|Select|Wrap|Line Numbers
  1. #p... 
  2. {
  3. background-image: url(whatever.jpg);
  4. background-repeat: no-repeat;
  5. overflow: hidden;
  6. }
  7.  
The "background-repeat" ensures that the photo won't be printed more than once in the frame. More importantly, the "overflow:hidden" attribute makes sure that any part of the photo exceeding the frame will stay out of sight.

To choose what part of the picture is shown in the frame, use the "background-position" attribute.

The syntax, again:

Expand|Select|Wrap|Line Numbers
  1. background-position: xxpx  AApx;
  2.  
Where "xx" is the number of pixels shifted right and "AA" is the number of pixels shifted down. To make these shifts occur in the other direction, place a negative "-" sign in front of the pixel value.

When all is said (and sort of) done, we get something like this:

Example #4

Excuse the silly photos, if you will.

Using this model, you are free to arrange the photos anyway you would like. You have control over the frame's size, location, and content. =)

Finally, to make each frame link to the full photo, simply add an anchor <a> to each div.

For example:

Expand|Select|Wrap|Line Numbers
  1. <div id="p1">
  2. <a class="link" href="whateverpathyouwouldlike..">picture1</a>
  3. </div>
  4.  
Next, style the anchor:

Expand|Select|Wrap|Line Numbers
  1. a.link
  2. {
  3.   display: block; 
  4.   height: 0px;
  5.   width: 150px;
  6.   padding-top: 150px;
  7.   overflow: hidden;
  8. }
  9.  
You could style these links individually, but I used a class for the links in my example....

In doing this, you are making a linked "mask" over the entire picture. Make sure the "padding-top" attribute is set to the full height of your frame. This way, the actual text of the link is pushed below the frame and hidden by the "overflow" rule.

In the end, you should get something like this:

Example #5

Notice that the original, linked photos are Larger than those displayed in our frames...

And that, my friend, is all I have to say about that....unless you have questions, of course...

Enjoy, and let me know if you get something working...

Tom
Aug 7 '07 #10
luftikus143
97 New Member
Hey Tom, many thanks for that. It's really too great!!

Here is how the archive looks now! Really cool!!

I had to do some minor changes to your code - e.g. the position of the DIVs is relative and not absolute, I added a float:left and because I can't allocate a specific id to each DIV due to the number of photos, I changed it the following way:

Expand|Select|Wrap|Line Numbers
  1. <div class="box" style="background-image: url(<?php echo callI_image_function_here; ?>)">
  2. <a class="link" href="<?php the_permalink(); ?>">picture1</a>
  3. </div>
Great, it's really looking amazing now. What do you think?
Aug 7 '07 #11
tburger
58 New Member
That looks really, really great!!!

An excellent adaptation of the tutorial model. The border you chose is simple and clean- it gives the page a VERY professional feel. The "window" approach is ideal for this - giving the viewer a sneak peak at the eclectic and unique nature of the photography. Most importantly, with the "frames" set to constant dimensions, the page flows much more.

Flow, as you may agree, is always a good thing. =)

The only possible suggestion I have is playing with some of the thumbnail image sizes if you can. I see that you used a 185px square frame on the page. Some of the thumbnails do not quite fill this frame (i.e. the beautiful shot of the bird over water in the last row of the archive). I personally think it looks good the way it is. However, if you wanted to try to fix this, I would suggest compressing a new thumbnail from the original photo. This way, you can make the picture slightly larger than its frame, without losing the quality of "resizing" the existing thumbnail. There are only a few photos that fit this category, but it might add the final touch...

If you don't have a Mac to use Image Shackle, or simply don't have software with this proportional resizing ability, let me know. I'd be happy to do it. It seriously might take 45 seconds.

Now, as much as it pains me to say this, I think we have taken care of the issue at hand....=) Thanks so much for staying engaged - You don't know how many responses go unanswered, or even worse, unused! Great project you're working on, keep it up!

I've sent you a message with my primary email. Feel free, anytime.

Hope this finds you well,

Tom
Aug 7 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

6
2315
by: fb | last post by:
Hello everyone. I'm having a touch of trouble solving a problem using the quadratic formula. I get a domain error...Somewhere in the sqrt function I think. Could you guys give me a hint on...
3
2563
by: michelle koen | last post by:
Hi Folks, on <a href="http://donbrice.com/new/page.php?section=schools">this page</a> and for all the sections I can't get Safari(2.02) or Firefox-PC(1.5) or the latest vers. of Opera-Mac to...
3
5159
by: amitsoni.1984 | last post by:
Hi, I need to do a quadratic optimization problem in python where the constraints are quadratic and objective function is linear. What are the possible choices to do this. Thanks Amit
1
1660
by: maya | last post by:
I'm using a function like this to load divs dynamically (and hide current one..) function get_img(curr_img,curr_nav,new_img,new_nav2) { var img_top = eval('document.getElementById(' +...
6
14821
by: Trev17 | last post by:
Hello, I am new to C++ and i have tried for several hours to make a program my teacher has given me as a lab. Here is the Lab question: the roots of the quadratic equation ax^2 + bx + c = 0, a...
1
3466
by: judacris | last post by:
I've seen the threads here about molding 2 divs in a centered fashion. but I can't seem to solve this thing. my blogger blog is functioning well on my site for now, but the blog feed (left) and...
1
2359
by: bbench123 | last post by:
Make a program that will ask for values of a quadratic equation (ax2+bx+c). the program must determine the roots of the equation using the quadratic equation determinants to distinguish if the roots...
2
1187
by: shapper | last post by:
Hello, I created a function to show a div given its id and hide the other divs (defined in a div): function show(id) { //var e = document.getElementsByTagName("div"); var e = {"home",...
2
7181
by: David | last post by:
I'm trying to style a kind of minimalist welcome page where each of X number of (gray?) boxes will be links to a part of the site. I want to implement the navbar (ie, set of boxes linking to...
0
7027
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
6719
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6847
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5312
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4757
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4463
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2980
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2970
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1288
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.