473,657 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Three equally separated images

Hi:

I am using CSS instead of tables for the layout of a webpage but I
don't know how to do something.

I need to place three images with the same distance among them and the
border of the page. Something like this:

---------------------------------------------
| |
| --------- --------- --------- |
| x | Image 1 | x | Image 2 | x | Image 3 | x |
| --------- --------- --------- |
| |
---------------------------------------------

Where the length x should be the same.

Using tables, an example of what I am asking:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title> Test </title>
<style type="text/css">
table {
width: 100%;
border-collapse: collapse;
}
td {
width: 200px;
border-style: solid;
text-align: center;
}
td.auto {
width: auto;
}
</style>
</head>
<body>
<table>
<tr>
<td class="auto"> </td>
<td> Image 1 </td>
<td class="auto"> </td>
<td> Image 2 </td>
<td class="auto"> </td>
<td> Image 3 </td>
<td class="auto"> </td>
</tr>
<tr>
<td class="auto"> </td>
<td> Image 4 </td>
<td class="auto"> </td>
<td colspan="4"> content </td>
</tr>
</table>
</body>
</html>

Is it possible to do it using <div> instead of tables for this layout?

Thanks in advance,
--
Fernando Arbeiza

Nov 23 '05 #1
3 1789
I would recomend a list. Something like:-

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title> Test </title>
<style type="text/css">
ul.imageList {

list-style: none;
margin: 10px
}
ul.imageList li {
list-style: none;
display: inline
margin: 10px
}
</style>
</head>
<body>
<ul class="imageLis t">
<li>Image 1</li>
<li>Image 2</li>
<li>Image 3</li>
<li>Image 4</li>
</ul>
</body>
</html>

You can set the margins to whatever you like, and if you want, you can set
the width of the <ul>, or leave it blank to flow the whole set of images. To
limit the no. of pictures in a row and fit the page width may be a bit
trickier though. Maybe margin:auto, and some <br />s. dunno

Martin

--
Martin Eyles
ma**********@NO SPAM.bytronic.c om

<ar******@ono.c om> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
Hi:

I am using CSS instead of tables for the layout of a webpage but I
don't know how to do something.

I need to place three images with the same distance among them and the
border of the page. Something like this:

---------------------------------------------
| |
| --------- --------- --------- |
| x | Image 1 | x | Image 2 | x | Image 3 | x |
| --------- --------- --------- |
| |
---------------------------------------------

Where the length x should be the same.

Using tables, an example of what I am asking:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title> Test </title>
<style type="text/css">
table {
width: 100%;
border-collapse: collapse;
}
td {
width: 200px;
border-style: solid;
text-align: center;
}
td.auto {
width: auto;
}
</style>
</head>
<body>
<table>
<tr>
<td class="auto"> </td>
<td> Image 1 </td>
<td class="auto"> </td>
<td> Image 2 </td>
<td class="auto"> </td>
<td> Image 3 </td>
<td class="auto"> </td>
</tr>
<tr>
<td class="auto"> </td>
<td> Image 4 </td>
<td class="auto"> </td>
<td colspan="4"> content </td>
</tr>
</table>
</body>
</html>

Is it possible to do it using <div> instead of tables for this layout?

Thanks in advance,
--
Fernando Arbeiza

Nov 23 '05 #2
"ar******@ono.c om" <ar******@ono.c om> wrote:
I am using CSS instead of tables for the layout of a webpage but I
don't know how to do something.

I need to place three images with the same distance among them and the
border of the page. Something like this:

---------------------------------------------
| |
| --------- --------- --------- |
| x | Image 1 | x | Image 2 | x | Image 3 | x |
| --------- --------- --------- |
| |
---------------------------------------------

Where the length x should be the same.


http://homepage.ntlworld.ie/spartani...ced_images.htm

1) This should probably be done with a CSS table, but due to IE not
supporting those a hack is required.
2) My arithmetic skills are lousy, you'll have to devise the formula for
calculating the "left" offsets yourself (I did it by eye).
3) The images do not wrap if the viewport width isn't sufficient (a hor
scrollbar is produced).
4) It requires a min-width hack for IE, I threw in something ugly
because I got bored with it.

--
Spartanicus
Nov 23 '05 #3
Tanks a lot, it works like a charm!

I have no problem with the wrapping if the view port width is not
sufficient, so I have simplified it to devise a formula. Perhaps it is
useful to someone else:

If we have n images of width w px:

HTML:

<div class="wrap">
<img class="image_1" src="1.jpg" />
<img class="image_2" src="2.jpg" />
. . .
<img class="image_i" src="i.jpg" />
. . .
<img class="image_n" src="n.jpg" />
</div>

CSS:

div.wrap img {
position: absolute;
top: auto;
}

and for image i:

div.wrap img.image_i {
margin-left: m%;
left: lpx;
}

where
m = 100 * i / (n + 1)
l = (1 - (i / (n + 1))) * w

Thanks for your answers
--
Fernando Arbeiza

Nov 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
9133
by: Sona | last post by:
I need to find a minimum of three float values.. what would be the most efficient way of doing this? Can someone please share a #define macro or something with me for doing this? Thanks Sona
2
3365
by: stefan.moser | last post by:
Hi All, I'm having a problem implementing the Separated Interface pattern from Martin Fowler's book Patterns of Enterprise Application Architecture. I'm using C# in Visual Studio 2005. The problem I'm trying to solve is one of validation. Let's say I'm building a book store application and I have a Genre object in my Domain Model. When I'm adding a new genre, I want to validate the new object to make sure that a genre with the same...
62
4405
by: robert | last post by:
I'd like to use multiple CPU cores for selected time consuming Python computations (incl. numpy/scipy) in a frictionless manner. Interprocess communication is tedious and out of question, so I thought about simply using a more Python interpreter instances (Py_NewInterpreter) with extra GIL in the same process. I expect to be able to directly push around Python Object-Trees between the 2 (or more) interpreters by doing some careful locking. ...
8
3814
by: Woodchuck | last post by:
Hi:) I've been trying to position some element's on my page and I can't come up with a way to equally position 4 DIV's in another DIV without explicitly setting the width of the "child" DIV's. Here's what the code look's like: <div id="Heading"> <a id="WP">WERSJA POLSKA</a> <div id="Buttons"> <div id="Home" class="ButtPart"><img src="Images/Buttons/blank_button.gif" alt="" class="InButtPart" />
6
1967
by: John | last post by:
Hi I have three tables with a common id with which they can be linked. I need to merge them in a way that the resultant table has all records from three tables. Below is what sort of result I am expecting; Table 1 ID Value1 1 A1
4
1414
by: tobin | last post by:
Hi folks, We're looking for a CMS system for our organisation, and we're picking potential solutions. We need something that is scalable cause we're a growing company, so there's potentially 2000+ simultaneous users. It's been recommended that we favour applications which can be separated into three separate physical tiers (web server, application
4
5510
by: Jim Carlock | last post by:
I'm working with three column layouts without tables. The page in question... http://www.microcosmotalk.com/images/garden/vine.asp Using clear:both; causes problems in the left and right <div> columns, meaning that each <divis not autonomous, they interact with each other when clear: styles apply.
9
1832
by: saurabh1 | last post by:
hi, I want to put three images on a single button.... and also middle image should be change dynamically. plz give suggestions. Regards, Saurabh
7
1153
by: Bryan Parkoff | last post by:
Can you please advise me how to write two separated objects? Sometimes, two objects have the same variable name and function name, but they have different algorithm to perform. The C++ Compiler allows you to create two classes. Two classes bind their own local variables and local functions. For example: Class Blue {
0
8421
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8325
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8742
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8621
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
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 we have to send another system
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.