[英]JQuery .width() doesn't change the width
I have got two divs, one img and one video, which adjusts to the size of the screen automatically.我有两个 div,一个 img 和一个视频,它们会自动调整到屏幕大小。 I want my image to be the same width with the video and found this code on the web ( .you
is the video and .santa
is the image):我想我的形象是相同的宽度与视频,发现这个代码在网络上( .you
是视频和.santa
是图像):
<script>
$( window ).resize(function() {
$(".santa").width($(".you").width());
});
</script>
It does not change the width though.虽然它不会改变宽度。
It changes the width I wrote an example here for you, to check it just resize the page splitter它改变了我在这里为你写的一个例子的宽度,检查它只是调整页面拆分器的大小
<div class="santa" style="width:100px;background-color:red">
santa
<div class="you" style="width:200px;background-color:green">
you
</div>
</div>
$( window ).resize(function() {
$(".santa").width($(".you").width());
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.