Click here to Skip to main content
12,632,959 members (32,833 online)
Click here to Skip to main content
Add your own
alternative version

Stats

96.4K views
19 bookmarked
Posted

Split Image

, 28 Aug 2003
Rate this:
Please Sign up or sign in to vote.
Displaying a split image using a table

Sample screenshot

Introduction

You can create some nice pictures by splitting them up into smaller images. Doing this in Photoshop and keeping the proportions isn't easy (I'm no photoshop guru), instead you can do it using a table. The code below creates the image of the sailboat.

How it's done

The image is loaded into a table as a background image

<style>
#splitimg {
    background:url(http://soderlind.no/s/splitimg/sailboat.gif);
    width:  300px;
    height: 400px;
}
</style>
.
.
.
<table id="splitimg"> 

Or, if you don't like to use CSS:

<table background="http://soderlind.no/s/splitimg/sailboat.gif" <BR>    width="300" height="400">

Next,  place a grid on top of the image using table rows and colums.

<tr>
    <td class="transp"> </td>
</tr>
<tr>
    <td class="hide"></td>
</tr>
<tr>
    <td class="transp"> </td>
</tr>
<tr>
    <td class="hide"></td>
</tr>
<tr>
    <td class="transp"> </td>
</tr>

A TD with a background color will hide that part of the image:

.hide {
    background-color:  #FFFFFF;
    width:  10px;
    height: 10px;
}
A TD without background color will be transparent:
.transp {
    border: 2px solid #000000;
    width:  300px;
    height: 113px;
}

Complete sample code:

<!-- Insert the STYLE code into the <HEAD> section of your page -->

<style>
#splitimg {
    background:url(http://soderlind.no/s/splitimg/sailboat.gif);
    width:  300px;
    height: 400px;
}

.hide {
    background-color:  #FFFFFF;
    width:  10px;
    height: 10px;
}

.transp {
    border: 2px solid #000000;
    width:  300px;
    height: 113px;
}

</style>

<!-- Insert the TABLE code into the <BODY> section of your page -->

<table id="splitimg" cellspacing="0" cellpadding="0" border="0">
<tr>
	<td class="transp"> </td>
</tr>
<tr>
	<td class="hide"></td>
</tr>
<tr>
	<td class="transp"> </td>
</tr>
<tr>
	<td class="hide"></td>
</tr>
<tr>
	<td class="transp"> </td>
</tr>
</table>

Split image tool

Doing this by hand isn't easy, so I created a tool you can use - http://soderlind.no/s/splitimg/default.asp

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Per S
Web Developer
Norway Norway
No Biography provided

You may also be interested in...

Comments and Discussions

 
Generalhaha,I know what's your meaning Pin
TommyWOo.cn7-Sep-03 16:47
sussTommyWOo.cn7-Sep-03 16:47 
QuestionPurpose? Pin
chong_lim30-Aug-03 17:15
memberchong_lim30-Aug-03 17:15 
AnswerRe: Purpose? Pin
Per Soderlind31-Aug-03 2:23
memberPer Soderlind31-Aug-03 2:23 
QuestionHow does the other side look like... Pin
Uwe Keim29-Aug-03 23:15
sitebuilderUwe Keim29-Aug-03 23:15 
GeneralI like the idea ... Pin
Sébastien Lorion29-Aug-03 22:49
memberSébastien Lorion29-Aug-03 22:49 
Generaltable tag Pin
Rui Dias Lopes29-Aug-03 9:16
memberRui Dias Lopes29-Aug-03 9:16 
GeneralRe: table tag Pin
Sven Axelsson29-Aug-03 13:52
memberSven Axelsson29-Aug-03 13:52 
GeneralRe: table tag Pin
Rui Dias Lopes30-Aug-03 0:54
memberRui Dias Lopes30-Aug-03 0:54 
GeneralRe: table tag Pin
Sven Axelsson30-Aug-03 1:34
memberSven Axelsson30-Aug-03 1:34 
GeneralRe: table tag Pin
Per Soderlind31-Aug-03 8:31
memberPer Soderlind31-Aug-03 8:31 
GeneralRe: table tag Pin
Stephane Rodriguez.29-Aug-03 21:12
memberStephane Rodriguez.29-Aug-03 21:12 
GeneralInteresting idea... Pin
Ryan Binns29-Aug-03 5:17
memberRyan Binns29-Aug-03 5:17 
GeneralRe: Interesting idea... Pin
Per Soderlind29-Aug-03 6:03
memberPer Soderlind29-Aug-03 6:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.161208.2 | Last Updated 29 Aug 2003
Article Copyright 2003 by Per S
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid