首页 > 解决方案 > 如何设置jQuery中图像的宽度?

问题描述

我正在尝试添加具有 Webgl 悬停效果的图像。效果 id 工作但是,我现在正在尝试为 jQuery 内部的图像设置宽度,

new hoverEffect({
  parent: document.querySelector('.ticket'),
  intensity1: 0.1,
  intensity2: 0.1,
  angle2: Math.PI / 2,
  image1: 'https://source.unsplash.com/Le7_qK9JaLU/500x500',
  image2: 'https://source.unsplash.com/XAqaeyzj3NM/500x500',
  displacementImage: 'https://cdn.rawgit.com/robin-dela/hover-effect/b6c6fd26/images/stripe1mul.png?raw=true'
});

.ticket{
  width: 100%;
  height: 100%;
  position: absolute;
  background: black;
}

标签: javascriptjqueryhtmlcss

解决方案


如果想使用 jquery 设置图像的宽度。只需添加这一行

例子

$(".img1").css({ 'height': '200px', 'width': '210px' });

推荐阅读