Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Spacing three images with CSS?
Old 06-01-2009, 01:35 AM Spacing three images with CSS?
Experienced Talker

Posts: 43
Name: Jon
Trades: 0
I have three images that I would like to space evenly across a div so that the middle image is centered within the div and the left and right images are all the way over to their sides with a 0 margin.

I have a feeling this is a simple thing to do, but the best I could do was center all three images within the div. I just want them to spread out more.

Any suggestions?
Foppa is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-01-2009, 02:35 AM Re: Spacing three images with CSS?
World's Avatar
Extreme Talker

Posts: 202
Location: Santa Monica, CA
Trades: 0
Are you working with a fluid or a fixed design?

In a fixed design it's not that hard. You have a total width of the web page and a total width of the three images. The rest you can fill up with margins and padding and borders.

With a fluid design that might be different. You have to work with percentages and ems.

There is a good book to learn this: it's called "CSS Mastery".
World is offline
Reply With Quote
View Public Profile
 
Old 06-01-2009, 02:42 AM Re: Spacing three images with CSS?
Experienced Talker

Posts: 43
Name: Jon
Trades: 0
I'm actually not sure what kind it is, but if I had to guess I would guess fixed.

I've been messing with the margins and paddings but it doesn't seem to be doing anything.
Foppa is offline
Reply With Quote
View Public Profile
 
Old 06-15-2009, 04:39 AM Re: Spacing three images with CSS?
WebDizanSajtova's Avatar
Average Talker

Posts: 23
Name: Miloš Krčedinac
Location: Novi Sad, Serbia
Trades: 0
Foppa, the easiest way to space 3 images evenly across a width of web page, is with table. I recommend it to you, if you have only 3 images, it is the most adequate way. But if you have more images, css is the required solution. According to your posts, I concluded you are pretty familiar with: divs, css, paddings, margins, floating, etc., and you are lack of any idea or concept to solve this. One idea is to float left, left image, next to float right, right image and to put center image width left and right margins that overlaps other two images. Or another idea is to float left, images next to each other, toward left direction, of course evenly spaced. I hope it’s not complex. One of examples is web page web dizajn, look at web banners at the bottom of the page, just tweak the margins between them, and that's it.
__________________

Please login or register to view this content. Registration is FREE
I
Please login or register to view this content. Registration is FREE
I
Please login or register to view this content. Registration is FREE
I
Please login or register to view this content. Registration is FREE
I
Please login or register to view this content. Registration is FREE

WebDizanSajtova is offline
Reply With Quote
View Public Profile Visit WebDizanSajtova's homepage!
 
Old 06-15-2009, 09:54 AM Re: Spacing three images with CSS?
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
Quote:
the easiest way to space 3 images evenly across a width of web page, is with table
No, no, and NO! There is absolutely no need to resort to tables for this. Yes, learning CSS is a challenge, but you'll never learn it if you keep going back to tables!
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 06-15-2009, 10:58 PM Re: Spacing three images with CSS?
World's Avatar
Extreme Talker

Posts: 202
Location: Santa Monica, CA
Trades: 0
CSS, at its current stage of development, is unpredictable and rough enough.

I don't want to even imagine how it was working with tables, spacer gifs, and...

... I imagined it too much. Now I feel sick.
World is offline
Reply With Quote
View Public Profile
 
Old 06-15-2009, 11:36 PM Re: Spacing three images with CSS?
grdbum's Avatar
Experienced Talker

Posts: 35
Name: James R. Juris
Location: Englewood, Colorado
Trades: 0
I would recommend that you do NOT use tables to position your 3 images across the webpage. You should be able to position the 3 images with padding and margin using CSS.

I would make a duplicate page of the page that you want to use for your images and make that duplicate page your experimentation page. That way you won't be altering your original work.

Then I would start by postioning the 3 images where you want them to be horizontally on the page. Place one image on the left, one image on the right and one image in the center of the page. Then adjust the padding and/or margin for the left and right images until they are positioned where you want them.
__________________
Jim Juris

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
grdbum is offline
Reply With Quote
View Public Profile Visit grdbum's homepage!
 
Old 06-15-2009, 11:55 PM Re: Spacing three images with CSS?
World's Avatar
Extreme Talker

Posts: 202
Location: Santa Monica, CA
Trades: 0
Even though I wouldn't want to use tables, I can understand why some experienced people do not want to switch.

Tables work in all browsers, and CSS is full of bugs and logical contradictions. It's a typical early model-version.

You can't rely that a certain property says the same in all contexts.

It always changes what it means in every context.

If you spoken language would be logically so inconsistent as CSS, we'd be talking in poems.

CSS is truly not developed enough, and as soon as you stray off the beaten path, you enter unpredictable territory.

I currently am in a situation, where the usual tiling of the background to complete a column simply doesn't work, just because it concerns a nested div. Very frustrating.
World is offline
Reply With Quote
View Public Profile
 
Old 06-16-2009, 03:50 AM Re: Spacing three images with CSS?
GeekSpecialties's Avatar
Super Talker

Posts: 132
Name: Leonard
Location: Minnesota, USA
Trades: 0
This is a pretty simple thing to do with css.
You can see it working here.
http://geekspecialties.com/test/css-image.html

Code:
<style type="text/css">
<!--
#wrapper {
    background: #EEEEEE;
    padding: 20px;
    width: 95%;
}
#wrapper #photos {
    background: #E5E5E5;
    margin: 0px;
    padding: 0px;
    border: 1px solid #AEAEAE;
    min-width:540px;
    clear: both;
}
#wrapper #photos img {
    background: #FFFFFF;
    padding: 5px;
}
.rfloat {
    float: right;
}
.lfloat {
    float: left;
}
.center {
    margin: 0px auto;
}
img{
    display:block;
}
-->
</style>
</head>

<body>
<div id="wrapper">
<div id="photos">
<img class="rfloat" src="/test/images/imageX125a.png" alt="image a" title="image a floated right"/>
<img class="lfloat" src="/test/images/imageX125a.png" alt="image b" title="image b floated left"/>
<img class="center" src="/test/images/imageX125a.png" alt="image c" title="image c margin auto"/>

</div>
</div>

</body>
</html>
GeekSpecialties is offline
Reply With Quote
View Public Profile Visit GeekSpecialties's homepage!
 
Old 06-16-2009, 04:04 AM Re: Spacing three images with CSS?
Experienced Talker

Posts: 43
Name: Jon
Trades: 0
Thanks everyone! I got it looking right finally.
Foppa is offline
Reply With Quote
View Public Profile
 
Old 06-16-2009, 04:22 AM Re: Spacing three images with CSS?
Junior Talker

Posts: 4
Name: Kris
Location: Poland
Trades: 0
GS, your code doesn't work on IE7 (center image is moved to left)...
Arrviasto is offline
Reply With Quote
View Public Profile Visit Arrviasto's homepage!
 
Old 06-16-2009, 12:44 PM Re: Spacing three images with CSS?
GeekSpecialties's Avatar
Super Talker

Posts: 132
Name: Leonard
Location: Minnesota, USA
Trades: 0
I don't know what you're seeing, It works fine in IE7.
http://dl-client.getdropbox.com/u/41218/css-image.jpg
GeekSpecialties is offline
Reply With Quote
View Public Profile Visit GeekSpecialties's homepage!
 
Old 06-16-2009, 03:11 PM Re: Spacing three images with CSS?
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
Quote:
I don't want to even imagine how it was working with tables, spacer gifs,
I can tell you, since I started there... it was ugly, infuriating, and kludgey - and it's STILL a kludge !

CSS is harder to master - no question about it, but it's SO much more flexible to work with. As with anything worth doing, it's worth taking the TIME to learn it.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Spacing three images with CSS?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.45001 seconds with 12 queries