【发布时间】:2016-09-20 05:09:04
【问题描述】:
我希望当分辨率小于 980px 时,应该执行下面的代码(从img 中删除宽度和高度)。代码将如何?谢谢
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function($){
$('img').each(function(){
$(this).removeAttr('width')
$(this).removeAttr('height');
});
});
</script>
【问题讨论】:
-
我在这里看不到任何表示
@media查询的代码。此外,@media查询只会更改 CSS ...如果您在 img 标签上硬编码了高度和宽度属性,我相信这些属性将优先于 CSS 实现的高度和宽度,或者至少会导致渲染问题因为在加载过程中会出现一种尺寸,并且在 CSS 完成标记样式后可能会突然改变。
标签: jquery image media-queries