javascript - JQuery .width() 不会改变宽度
问题描述
我有两个 div,一个 img 和一个 video,它们会自动调整到屏幕的大小。我希望我的图像与视频的宽度相同,并在网上找到了这段代码(.you
是视频,.santa
也是图像):
<script>
$( window ).resize(function() {
$(".santa").width($(".you").width());
});
</script>
它不会改变宽度。
解决方案
它改变了我在这里为你写了一个例子的宽度,检查它只是调整页面拆分器的大小
<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());
});
推荐阅读
- php - 修改字符串的第一次和第二次出现和重置
- python - 如何计算按相同特定属性分组的两个卷中两个单元格之间的日期时间差异?
- javascript - 嵌套循环是否总是在最后一次迭代后重置?
- image - 图像塑造问题:三维图像
- angular - Homestead .htaccess 使用 Angular 7 重写规则
- bash - 如何将sha1sum总和与文件进行比较
- c# - 从应用程序和程序中删除注册表项
- javascript - 使用 Object.freeze 和 object.unfreeze 减少具有大量表数据行的反应性页面中的内存膨胀
- c++ - POSIX 信号量函数 sem_post() 不唤醒 sem_wait() 问题
- java - 如何并行运行 EJB 调度程序