473,397 Members | 2,084 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Multiple images making up a single image

I have 3 images that I want to make look like a single image as a background to some text. I have looked at a lot of "rounding" techniques, basically this will look like a box with rounded corners, but I don't like the amount of css and/or html involved in all the techniques I have seen. My next attempt was to put 3 cells together to make up the image, this is okay except that I need it to span the entire width, so the first cell is the width of the image, the second repeats for the width of the page minus the width of the left image minus the width of the right image, the last cell is the width of the image. I will be using this in multiple places on multiple pages, so I need an elegant solution that puts as much work in one place for reuse.
May 18 '07 #1
19 4046
PS This needs to work in IE, but we might support firefox as well, still deciding, so preferrably something that works in both.
May 18 '07 #2
jhardman
3,406 Expert 2GB
I think it makes most sense to use css to position your images:
Expand|Select|Wrap|Line Numbers
  1. <img src="leftSide.gif" alt="" style="position: absolute; top: 100px; left: 20px; z-index: -1;" height="75" width="12"><img src="middle.gif" alt="" style="position: absolute; top: 100px; left: 32px; z-index: -1;" height="75" width="100"><img src="rightSide.gif" alt="" style="position: absolute; top: 100px; left: 132px; z-index: -1;" height="75" width="12"><div style="position: absolute; top: 115px; left: 30px; z-index: 1;">Button</div>
Some browsers might have different interpretations when positioning is absolute, so make sure you test it well.

Or is that what you meant by using too much css? You don't need all the code to be inline:
Expand|Select|Wrap|Line Numbers
  1. .left {
  2.    position: absolute;
  3.    left: 20px;
  4.    z-index: -1;
  5.    }
  6.  
Jared
May 18 '07 #3
I really need something that is more generic. Assume all you know is the heigth of your images. You don't know how wide it will be on the page, this is the biggest problem I'm having, you just want the 3 images to take up 100% of that space so the middle image you are assuming goes for 100px but I don't know how wide it really will be.

Another goal is to make it so the coder has as little code to write as possible, because we will use this in a lot of situations written on various pages by different programmers. If the solution has a fair amount of html, that is okay because we are using jsf and I can make a tag to generate that html.

So really my 2 biggest problems are, how to take up 100% of the width when you don't know what that width is, and make it flexible enough to be used in multiple places with out writing a large amount of code over and over again.

BTW thanks for your quick response.
May 18 '07 #4
This is kind of what I have been playing with, but like I said I'm having trouble with the width. The center image is taking up too much space. So it doesn't look like I want it to. Something along these lines also means that I can make this into a simple tag for programmers to use that is flexible enough for what we need.

Expand|Select|Wrap|Line Numbers
  1. <table width="100%" cellspacing="0" cellpadding="0">
  2.   <tr height="49px">
  3.     <td style="height: 100%; background-image: url(images/backgrounds/titleBarLeft.gif);">
  4.       &nbsp
  5.     </td>
  6.     <td style="width: 100%; height: 100%; background-image: url(images/backgrounds/titleBarCenter.gif); background-repeat: repeat-x;">
  7.       Your Title Goes Here
  8.     </td>
  9.     <td style="height: 100%; background-image: url(images/backgrounds/titleBarRight.gif);">
  10.       &nbsp
  11.     </td>
  12.   </tr>
  13. </table>
Attached Images
   
May 18 '07 #5
drhowarddrfine
7,435 Expert 4TB
My brain is fried right now but I'll probably have a simple css solution by tomorrow. Do not use a table. Are these images to go along the bottom only?
PS This needs to work in IE, but we might support firefox as well, still deciding, so preferrably something that works in both.
Depending on where you are in the world, 16% to 40% of your users use Firefox (parts of Europe and Australia) and up to half or more don't use IE. If you write standards compliant code, it will work in all browsers including old, buggy, non-standard IE.
May 18 '07 #6
drhowarddrfine
7,435 Expert 4TB
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2.    "http://www.w3.org/TR/html4/strict.dtd">
  3. <html>
  4. <head>
  5. <title></title>
  6. <style type="text/css">
  7. html,body{
  8.     height:100%;
  9.     width:100%;
  10.     margin:0;
  11.     padding:0
  12.     }
  13.  
  14. div{
  15.     height:100%;width:100%;
  16.     background-image: url("titleBarCenter.gif");
  17.     background-repeat: repeat-x;
  18. }
  19. </style>
  20. </head>
  21. <body>
  22.  
  23. <div>
  24.     <img src="titleBarLeft.gif" style="float:left">
  25.     <img src="titleBarRight.gif" style="float:right">
  26. </div>
  27.  
  28. </body>
  29. </html>
  30.  
May 19 '07 #7
Well, that looks okay in IE, but in Firefox the center image doesn't even show up. And the biggest problem comes when I try to put in text, this is supposed to be like a header, so I need text that is centered vertically, the text makes the right image shift down, which makes sense. So I don't know how you can do this without putting it in a table.
May 21 '07 #8
drhowarddrfine
7,435 Expert 4TB
Well, that looks okay in IE, but in Firefox the center image doesn't even show up.
Looks fine to me in FF and IE. I'll look at the text thing in a minute.
May 21 '07 #9
drhowarddrfine
7,435 Expert 4TB
I don't see any problem:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2.    "http://www.w3.org/TR/html4/strict.dtd">
  3. <html>
  4. <head>
  5. <title></title>
  6. <style type="text/css">
  7. html,body{
  8.     height:100%;
  9.     width:100%;
  10.     margin:0;
  11.     padding:0
  12.     }
  13.  
  14. div{
  15.     height:100%;width:100%;
  16.     background-image: url("titleBarCenter.gif");
  17.     background-repeat: repeat-x;
  18. }
  19. </style>
  20. </head>
  21. <body>
  22.  
  23. <p>hello</p>
  24. <div>
  25.     <img src="titleBarLeft.gif" style="float:left">
  26.     <img src="titleBarRight.gif" style="float:right">
  27. </div>
  28.  
  29. </body>
  30. </html>
  31.  
May 21 '07 #10
Hmm.. I don't know what I did before but you're right it seems to be fine in FF and IE. I don't know if that last post you expected that the hello showed up on the image, if so it doesn't but the title bar looks good now.
May 21 '07 #11
drhowarddrfine
7,435 Expert 4TB
No, hello should not be on the image. Which browser?
May 21 '07 #12
I was just making sure you didn't expect that hello to be showing up because it isn't. It looks the same on both browsers now, the three images are showing up like I expect, but I can't put text in there. So if you figure out how to get that text to show up that would be great.
May 21 '07 #13
drhowarddrfine
7,435 Expert 4TB
I'm confused. I don't understand where the text is supposed to go.
May 21 '07 #14
The images are making up a title bar. So I need to put a title on it. The text will go on top of the center image.
May 21 '07 #15
eragon
431 256MB
you tried making a table, like, say, this one:

Expand|Select|Wrap|Line Numbers
  1. <table height="150px">
  2. <tr>
  3. <td width="30px" background="img1.gif"></td>
  4. <td width="75%" background="img2.gif><strong>Title</strong></td>
  5. <td width="30px" background="img3.gif></td>
  6. </tr>
  7. </table>
Sorry my html isnt fancy and indentented and colored, i use notepad...

this might work, you may need to mess with the percentage in the middle cell, but this will always fit the width of any screen, and text will go on it. The text may be pushed to the right a little cuz the fact its not writing in the left column, but this should look pretty decent, especially with a centered title. another thing, im not sure if the center background will repeat, if not theres probly another attribute you can add on.

anyways, im glad i can try and help...

Eraogn
May 27 '07 #16
eragon
431 256MB
Thats cool, i didnt know this site colores my scripts...


i misspelled my own name, ain't that something?

Sincerely,

Eragon
May 27 '07 #17
drhowarddrfine
7,435 Expert 4TB
[HTML]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<style type="text/css">
html,body{
height:100%;
width:100%;
margin:0;
padding:0
}

div{
height:100%;width:100%;
background-image: url("titleBarCenter.gif");
background-repeat: repeat-x;
}
</style>
</head>
<body>

<div>
<p style="position:absolute;left:20px;">hello</p>
<img src="titleBarLeft.gif" style="float:left">
<img src="titleBarRight.gif" style="float:right">
</div>

</body>
</html>
[/HTML]
Eragon,
We stay away from using tables for layout.
May 27 '07 #18
eragon
431 256MB
an see why, well, your method works, ive seen it on alot of sites. in fact, im gonna change my sites to divs, cuz tables dtont work right on my friend's mac. thx for the tips. =p

sincerely,

Eragon
May 27 '07 #19
[HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>website.title</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<style type="text/css">
html, body {
margin : 0px;
padding : 0px;
font-family : Verdana, Arial;
font-size : 12px;
background : #f2f2f2;
}
.body {
background : #ffffff;
margin-left : 10%;
margin-right : 10%;
border : 1px solid #c0c0c0;
}
.nav {
color : #000000;
padding-top : 6px;
padding-bottom : 6px;
padding-left : 4px;
padding-right : 4px;
font-size : 11px;
border-bottom : 1px solid #c0c0c0;
background-color: #f9f9f9;
margin-bottom: 2px;
}
a.nav-link:link {
color : #000000;
text-decoration : none;
padding-right : 4px;
padding-left : 4px;
}
a.nav-link:visited {
color : #000000;
text-decoration : none;
padding-right : 4px;
padding-left : 4px;
}
a.nav-link:hover {
text-decoration : none;
padding-right : 4px;
padding-left : 4px;
background : #ffffff;
padding-top : 6px;
padding-bottom : 6px;
color : #85add6;
border-bottom : 1px solid #6d92b9;
}
.content {
padding-left : 4px;
padding-right : 4px;
padding-bottom : 4px;
padding-top : 2px;
}
.edge-top-right {
background : url(images/layout.png) 0px -27px;
height : 5px;
width : 5px;
float : right;
margin-right : -1px;
margin-top : -1px;
}
.edge-top-left {
background : url(images/layout.png) 0px -32px;
height : 5px;
width : 5px;
float : left;
margin-left : -1px;
margin-top : -1px;
}
.edge-bottom-right {
background : url(images/layout.png) 0px -17px;
height : 5px;
width : 5px;
float : right;
margin-right : -1px;
margin-top : -4px;
}
.edge-bottom-left {
background : url(images/layout.png) 0px -22px;
height : 5px;
width : 5px;
float : left;
margin-left : -1px;
margin-top : -4px;
}
.title {
font-family : Arial;
font-size : 22px;
color : #6d92b9;
}
.header {
font-family : Arial;
font-size : 16px;
color : #a5a5a5;
}
.footer {
text-align : right;
font-size : 11px;
margin-top : 4px;
padding-right : 5px;
height : 17px;
background : url(images/layout.png) 0px 0px;
}
a:link, a:visited {
color : #6d92b9;
}
a:hover {
color : #85add6;
text-decoration : none;
}
.body span {
margin-left : 16px;
line-height : 1.5em;
}
</style>
</head>
<body>

<div class="body">
<div class="edge-top-left"><!-- --></div>
<div class="edge-top-right"><!-- --></div>
<div class="nav">
<a href="/welcome" class="nav-link">Home</a>
<a href="/projects" class="nav-link">Projects</a>
<a href="/tutorials" class="nav-link">Tutorials</a>
<a href="/articles" class="nav-link">Articles</a>
<a href="board/" class="nav-link">Community</a>
</div>
<div class="content">
<div class="title">website.title</div>
<div class="header">header</div>
<span>Nunc nobis videntur parum clari. Parum claram anteposuerit litterarum formas. Mutationem consuetudium lectorum Mirum est notare quam littera gothica quam nunc putamus parum claram anteposuerit.</span>
</div>

<div class="footer">Copyright © 2006 <a href="http://www.quate.net/" target="_blank">Quate</a> Development.</div>
<div class="edge-bottom-left"><!-- --></div>
<div class="edge-bottom-right"><!-- --></div>
</div>

</body>
</html>[/HTML]


http://www.quate.net/newsnet/read.php?id=48
Aug 22 '07 #20

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

Similar topics

4
by: seven | last post by:
This might be a newbie question or otherwise easy stuff for some of you, but it's tweaking me ... can't seem to get it to work right. I am working with a script that basically creates two arrays,...
9
by: amitavabardhan | last post by:
How Can I extract multiple tiff images into single images through asp programming? Is there any free dll's that I can use in ASP to split multiple tiffs into single tiffs? Any suggestion...
1
by: Alec MacLean | last post by:
Hi, I'm trying to write a set of charts (as bitmap objects) out to a memory stream so that a variable number of charts can be displayed using just one html <img> tag in a holder page. I have...
1
by: Larry Marburger | last post by:
I've built an XSLT that is used to generate a simple TreeView-type, web-based control (ASP.NET / C#). When the tree is fully transformed (client-side, JavaScript transformation), there are about 5...
3
by: Arun | last post by:
Hi, I have simple question to ask. How to write multiple Binary files to the Browser using Asp.Net and Visual C#.net I have seen examples where single binary file is written to browser. ...
6
by: Steve Mauldin | last post by:
I have three websites that were developed by using the same code in .net. They are all located under wwwroot on my desktop running windows 2000 pro.because Windows 2000 pro only supports a single...
6
by: NutsAboutVB | last post by:
Hello, I am a .NET programmer and I have a JPEG image file (from digital camera) of about 109 KB's in size, when I open it and save it (without making any alterations at all, just going to File...
2
by: Kuldeep | last post by:
Hi All I have a Base64 encoded string as a resultant parameter of a specific webservice call. This string is converted into a byte array and through this, I am saving it as an image. Now, even...
6
by: Rob | last post by:
Hello, I'm sure this has come up before. I have need for a collection of all elements/objects in an HTML document that have any kind of an attribute (HTML or CSS) that is making use of a URL to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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
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,...
0
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...

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.