在IE中使用元素的初始宽度不起作用 [英] use initial width for element not working in IE

查看:96
本文介绍了在IE中使用元素的初始宽度不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个图形插件,它插入画布和一个图例< table> 到它的容器。在这个插件中,没有定义 width ,在我的CSS中,插件插入。



所以,新的div继承了 table {width:100%} 我试图使用 width:initial; ,在Chrome上看起来不错,但 https://developer.mozilla.org/en-US/docs/Web/CSS/initial?redirectlocale=en-US&redirectslug=CSS/initial\">IE不喜欢 检查浏览器兼容性



我承认在脚本/插件中更改/强制嵌入CSS,因为它必须在任何环境中工作。 / p>

这里最好的解决方案是什么?

解决方案

一般 width:auto 会有类似的效果。有规则:

  .my-selector {
width:auto;
width:initial;
}

应该使用初始如果支持, auto


I have a graph plugin that inserts canvas and a legend <table> to its container. In this plugin the table has no width defined and in my CSS there is a width for tables inside that container were my plugin gets inserted.

So, the new div is inheriting table{ width: 100%} from the CSS and rendering wrong.

I tried to use width: initial;, looks good on Chrome but IE doesn't like it check browser compatibility

I admit changing/forcing a inline CSS in the script/plugin since it has to work in any enviroment.

What is the best solution here?

解决方案

Like you said, generally width: auto will have a similar effect. Having the rules:

.my-selector {
    width: auto;
    width: initial;
}

Should cause it to use initial if it's supported and auto otherwise.

这篇关于在IE中使用元素的初始宽度不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆