javascript - Help with auto-resize of background image -


is there way automatically resize background image of element. example, in html, links have background image. image has slanted left , right border , round top corners.

one specify width of anchor element accommodate background image. problem width should dynamic , background image should adjust if link's width smaller width of image.. kinda doing other way around..

do solutions this? thanks!

there standard way of achieving using 2 elements.

<a href="foo.html" class="button"><span>button text</span></a> 

as can see put span inside link going have button. image using need split 2 pieces 1 left side , middle portion of button , on right side. set contained span have wide left side of button image. link contain right side of button. css should this

a{  background: url("rightimg.png") right no-repeat;  display:block;  padding-right: [width of image];  width:auto;  height:[height of image];  line-height:[height of image] } span{  background: url("leftimg.png") left no-repeat;  display:block;  width:auto;  height:[height of image];  line-height:[height of image] } a{  background: url("righthover.png") right no-repeat; } span{  background: url("lefthover.png") left no-repeat; } 

yo need tweak around in css make fit particular layout.

the reason left image in span if have transparency on button not have overlap images. keep in mind when cutting image.

i recommend making left image above 200px wide allow large amount of expansion space.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -