【发布时间】:2016-01-19 16:11:20
【问题描述】:
我在一个复杂的 webapp 中有代码 - 就像这样创建代码
<img src="foobar.png" style="width:369px;height:200px;">
如何插入 css(通过 .css 文件包含)以覆盖宽度和高度?
谢谢
【问题讨论】:
我在一个复杂的 webapp 中有代码 - 就像这样创建代码
<img src="foobar.png" style="width:369px;height:200px;">
如何插入 css(通过 .css 文件包含)以覆盖宽度和高度?
谢谢
【问题讨论】:
您可以像下面的方法一样覆盖此图像样式
img[style]{
height:100px !important;
width:200px !important;
}
<img src="http://www.keenthemes.com/preview/conquer/assets/plugins/jcrop/demos/demo_files/image1.jpg" style="width:369px;height:200px">
【讨论】:
习惯于!important,并在你的img标签中定义一个class,就像这样
.imgClass{
width:400px !important;
height:400px !important
}
【讨论】:
【讨论】:
您应该像这样将!important 添加到您的样式中。
img {
height: 200px !important;
width: 369px !important;
}
然后我总是建议你不要做内联样式。
【讨论】: