Stretching the baclground image in panel

Hello experts,

I am using a panel whose background image is set. Though I dont want the background image to get tiled but it should stretch inside the panel. How much ever small the image is, it should get stretched and fit to panel according to the size of panel.

How do I get this functionality??

Please note that there is a specific reason that I want to stretch the panel background image and I cannot use any <img> tag.

Please do let me know the suggestions.

Thanks

Regards,
Baz
baz86Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ramkisan JagtapLead DeveloperCommented:
I think, the image will need to be of the correct width. You can't get a css background image to stretch to fit a panel. The only other way is to have an image <img> sitting inside the DIV, but with a lower z-index than everything else. It's somewhat of a hack.

Please check following link :

http://www.vbforums.com/showthread.php?t=538438

Regards,
Ram
0
hehdaddyCommented:
This is probably what @ramkisan was saying, but you can easily do this using CSS.

Instead of using a CSS background image, use a standard IMG, and set its class properties to something like this:

#img.source-image {
      width: 100%;
        height: 100%;
      position: absolute;
      top: 0;
      left: 0;
}

Height will only work if all the parents up the chain have height set to 100%.

Another alternative is to use jQuery and a jQuery plugin that will do it for you. I saw a few in the jQuery plugins directory at the site. http://www.jquery.com
0
baz86Author Commented:
Actually there is a specific reason because of which I cannot use  tag inside the panel. It has to be the background image of the panel.
So isnt there any way by which I can change stretch the background image?

Hope there is. :(

Thanks

Baz
0
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Ramkisan JagtapLead DeveloperCommented:
@Baz : Can you please share that reason? If possible we can give you aa another solution.

Regards,
Ram
0
baz86Author Commented:
Ok
I am creating a map for several countries for which I need a blank map template of that country so that I can label cities on that blank template.(Label cities means creating labels at run time of cities and displaying it on the template.)

I also have a functionality of image panning wherein user can drag the image in a parent panel.(all this is inside a parent panel.)

So if I place a image tag inside the panel(child) to be my blank map template..labels would be visible on the image. But when I move(drag) the image, only image would move and city labels wouldnt because labels are actually placed on panel(child) and not on image. As far as I know, we cant place labels on the image(control on control) can we?

So that is the reason if I set background image of the panel to that of empty map template then even the labels along with the template can be dragged. (since panel is a container and can hold controls like labels).So that background should fit(stretch according) to the size of panel otherwise city labels are moved.
And I cant even keep the size of image equal to size of the panel(manually using some photo editor) because there are various levels of zooming so I cant have those me pictures of different sizes.(and that too for each country! :(.....nah..)

Hopefully I have not confused you all.

Do let me know if you havent understood any part of whtever I wrote and also if there is any alternative to my problem.

Thanks.

Baz
0
Ramkisan JagtapLead DeveloperCommented:
Hi Baz,
You can use Image mapping concept in this situation.
Please try for it. If I got somthing I will definitely Inform you.

Regards,
Ram
0
baz86Author Commented:
Can you elaborate on wht is image mapping concept?

Is there any way by which I can make Image(tag) act as a container so that it can hold labels?

Regards,
0
Ramkisan JagtapLead DeveloperCommented:
Have you Checked above links?
You can use following features.
Hot spots features
There is no limit on number of hotspots each image may contain.
Each hotspot is characterized by various attributes like shape, location and size.
Overlapping hotspots are perfectly valid.
Hot spots are defined using x and y coordinates.
Hot spots can be assigned Image URL's and are capable of postback.

Different types of hot spots
There are three different types of hot spots offered by ImageMap control. They are:
CircleHotspot
RectangleHotspot
PolygonHotspot

0
baz86Author Commented:
@Ramkisan: Oh oks. Thanks for your suggestion. I ll go through and let you knw. Thanks.
0
baz86Author Commented:
Just found out that in any case you cant place text or labels on those hot spots. Imagemap control(i think) only defines the clickable regions on the imagemap, isnt it?
0
raaziqCommented:
if u r using image mapping u can only use tooltips for the hotspots instead of placing labels on it. anyway try ur luck.
0
baz86Author Commented:
@ raaziq: i am cant use image maps since i cannot add text on the map or on the hotspots. Along with tooltip even text should be visible. Thanks for ur suggestion.

0
baz86Author Commented:
Hello experts,

Since there was no other way by which I could find a way to stretch the background image of the panel, I used an external photo editor and manually increased dimensions of the background image. I know this is not a feasible solution in all cases but as a last resort I decided to go for this in my case.

@Ramkisan:- Thank you for all the comments

Regards,
Baz
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
baz86Author Commented:
This was the last but best possible solution I could think for my case. Though this may not be the ideal solution in all the cases.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.