473,396 Members | 1,804 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,396 software developers and data experts.

stretching the background image instead of tiling

Hi,

I have created a user control which has the html code as follows
<TABLE id="ToolBarTable" cellSpacing="0" cellPadding="0" width="100%"
border="0">
<tr>
<td align="right" bgColor="#000000"><IMG src="../Images/image1">
</td>
</tr>
<TR>
<TD id="mastHead" runat="server">
<asp:Label id="lHeading" runat="server" CssClass="header"></asp:Label></TD>
</TR>
</TABLE>

In the Page_Load method I am setting the properties of mastHead column like
this

Me.mastHead.Attributes.Add("background",
"../images/mastheads/masthomedefault.jpg")
Me.mastHead.Attributes.Add("height", "101")
Me.mastHead.Attributes.Add("width", "100%")

'* Handles the Heading label
Me.lHeading.Text = "This could be the Company Name"

Now the problem is if the width of a table is larger than the image width,
it is tiling the background image. I would like the background image to be
stretched instead of tiling it? Is there a property to do that? Or is there
any other way to do this?

Thanks,
Sridhar.
Nov 23 '05 #1
3 9373
You should try CSS to set the background image. Then you can tell the
browser whether to tile, stretch, or use fixed placement for the image
without modifying your code.

Here's an example of tiling horizontally:

TD
{
background-image: url(someimage);
background-repeat: repeat-x;
}

Nov 23 '05 #2
Hi,

I have tried that. If the size of a table cell exceeds the size of image,
then it is repeating(tiling) the image. I need to stretch the image instead
of repeating it like in <img> tag if the width of image is 1000 and if I set
the width to 1300 it will stretch the image. Is there a css property to do
that?

Thanks,
Sridhar.

"yubyub" wrote:
You should try CSS to set the background image. Then you can tell the
browser whether to tile, stretch, or use fixed placement for the image
without modifying your code.

Here's an example of tiling horizontally:

TD
{
background-image: url(someimage);
background-repeat: repeat-x;
}

Nov 23 '05 #3
I'm afraid there isn't one that does that.
One way to do it is to use absolute position to put an image behind the
table and resize it.
A probably better solution is to center the background image in the table.
Use the following css rules to center the image and stop if from repeating:

background-position: center;
background-attachment: fixed;
background-repeat: no-repeat;

Best regards,
Mats

Sridhar wrote:
Hi,

I have tried that. If the size of a table cell exceeds the size of image,
then it is repeating(tiling) the image. I need to stretch the image instead
of repeating it like in <img> tag if the width of image is 1000 and if I set
the width to 1300 it will stretch the image. Is there a css property to do
that?

Thanks,
Sridhar.

"yubyub" wrote:

You should try CSS to set the background image. Then you can tell the
browser whether to tile, stretch, or use fixed placement for the image
without modifying your code.

Here's an example of tiling horizontally:

TD
{
background-image: url(someimage);
background-repeat: repeat-x;
}

Nov 30 '05 #4

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

Similar topics

2
by: lorelei | last post by:
Hey all, I have found two seperate HTML codes which claim to stop background images from being tiled. Neither of them seem to be working. I'm writing my codes in Textpad, and use Internet...
27
by: Kevin Yu | last post by:
When I declare on HTML page <LINK href="mycss.css" type="text/css" rel=stylesheet /> .... <BODY class=myclass> in mycss.css BODY { FONT-WEIGHT: bold; FONT-SIZE: 12px; FONT-FAMILY:...
8
by: Ron Holmes | last post by:
I want to place a background image on a windows form. Is there a way to prevent the image from Tiling without using an image box resized to the size of the form? I am using Visual Studio 2003...
6
by: John Ortt | last post by:
Hi there everyone, I have a part info form which has a faded image of our company logo as a background. I want to replace the faded image with a bright red warning image on items which have run...
3
by: Viken Karaguesian | last post by:
Hello all, I need somehelp with background tiling. I have a sneaking suspicion that what I want to do is not possible, but I'll ask anyway. :>) First some background: Here's the site in...
16
by: Walker | last post by:
I have a span containing two words. Eg. <span>Avant Garde</span> Using CSS, I pad the text to the right and assign a background-image. Eg. span { padding: 0 3px 0 11px; background:...
4
by: Arthur Dent | last post by:
Hello all... i have a really frsutrating problem here... This is only happening in IE (6 & 7b2), Mozilla and Netscape are both OK. I have a top-level table with a width of 760px, so it should be...
4
by: Steve Dambrowski | last post by:
How do I make my background image fit the screen so no one has to scroll, and at the same time it's not tiled looking?? I have one that is 800x600 and one that is 1084x768. The small one...
4
by: Bob Altman | last post by:
Hi all, I posted an earlier question to the microsoft.public.inetserver.asp.general newsgroup asking how to set the background of a client-side table cell to a gradient, and I received this...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
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
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...

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.