gpt4 book ai didi

html - 使 td 大小适合图像大小 CSS

转载 作者:行者123 更新时间:2023-11-28 11:00:48 26 4
gpt4 key购买 nike

我有一个问题。我试图找到这个,但我不能那样做。我有<td>在空表中。但是在将图片加载为 <td> 之后大小为 800x600 的背景 <td>也需要是 800X600。我想要动态的。

我尝试以几种方式使用 CSS,但它无法正常工作。它适合我的形象 <td>

<td class="plan"></td>

.plan{
border: 1px solid black;
background: url(../graphics/plan.png) no-repeat ;
background-size: 100% 100%;
}

最佳答案

你可以试试这个http://jsfiddle.net/aamir/TTGS9/2/

$(function(){
var bgImg = $('<img src="'+$('td').css('background-image').replace('url(','').replace(')','')+'" />');
bgImg.hide().bind('load', function(){
var $this = $(this);
$('td').width($this.width()).height($this.height());
$this.remove(); //not needed
});
$('body').append(bgImg);
});

关于html - 使 td 大小适合图像大小 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22456551/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com