我正在尝试创建一个 jQuery 函数,该函数会自动将特定图像的大小调整为其父级的宽度。如果相关,则适用于 vbulletin 4.2.0
这是相关的(简化的)代码:
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var newWidth = $('.floatcontainer.doc_header').css("width");
$('.logo-image').css("width", newWidth);
});
</script>
</head>
<div class="floatcontainer.doc_header" style="width: 90%; height: 200px;">
<img class=".logo-image" src="/img/headerimg.jpg"/> //the image is naturally 1092x200
</div>
解决了!我终于想出了在哪里编辑这张图片的css,所以我不需要用jQuery来做。不完全是我正在寻找的解决方案,但是嘿 - 谁在抱怨!
谢谢你的帮助!