开发者

In CSS, a way to say, if the TD element has IMG in it, then "text-align: center"?

开发者 https://www.devze.com 2023-01-11 20:28 出处:网络
The line td img { text-align: center } won\'t work.It has to target the td instead: the td h开发者_JS百科aving an img element will have text-align: center.Can it be done in CSS 2.1?Can you use jQue

The line

td img { text-align: center }

won't work. It has to target the td instead: the td h开发者_JS百科aving an img element will have text-align: center. Can it be done in CSS 2.1?


Can you use jQuery? If you can then you can use a jquery selector to add a class to the td that will center it.

something like this untested code;

$('td img').parent().addclass('center');


Cannot be done without the help of JS or...

Add a class to the td:

<td class="img"><img .../></td>

0

精彩评论

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