开发者

Dynamically calculate padding-left

Here's a sample division:

<div style="padding:0 0 0 30px; background:url(http://www.google.com/hel开发者_Go百科p/hc/images/sidewiki_157505_comment_bubble.gif) left center no-repeat;">some text</div>

I wonder how I can calculate the padding-left:30px dynamically so that any icon I choose the padding-left value changes according to the image width.

Any help is appreciated!


I would use jQuery:

$('div#id').css('padding-left');

You would need to have a way to select the DIV, hence my artificial #id.

Examples: http://jsfiddle.net/userdude/LvPH6/1/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜