简体   繁体   English

如何在Ruby on Rails中仅使用CSS来悬停图像?

[英]How to enlarge images on hover using only CSS in Ruby on Rails?

Right now, a user could download and see images using Ruby on Rails. 现在,用户可以使用Ruby on Rails下载和查看图像。 I would like that those images be enlarged on hover. 我希望那些图像在悬停时放大。

The similar question was asked (link below) without the answer on it. 问题类似的问题(链接如下)没有答案。

In bootstrap, how to enlarge one of these images when mouse is hovered? 在bootstrap中,如何在鼠标悬停时放大其中一个图像? And IE8 shall be compatible IE8应兼容

To implement this functionality, I've added :hover to custom.scss(see below) but the pictures want not being enlarged on hover. 为了实现这个功能,我添加了:hover to custom.scss(见下文),但图片不希望在悬停时放大。

span.picture {
    margin-top: 10px;
    input {
      border: 0;
    }
  }
   span.picture:hover {
     transform: scale(1.5);
}

//The files related are similar as below: //相关文件类似如下:

'''from source/bootstrap''' '''来自source / bootstrap'''

    <span class="content">
        pic
        <img src="https://example.s3.amazonaws.com/uploads/micropost/picture/124/1.JPG" alt="B1" />
      </span>

'''from custom.scss''' 来自custom.scss的''''''

.content {
    display: block;
    margin-left: 60px;
    img {
      display: block;
      padding: 5px 0;
    }
  }


span.picture {
  margin-top: 10px;
  input {
    border: 0;
  }
}

'''from Gemfile''' '''来自Gemfile'''

gem 'bootstrap-will_paginate', '1.0.0'
gem 'bootstrap-sass', '3.3.7'
gem 'puma',         '3.9.1'

From the code you are showing the CSS should be: 从显示CSS的代码应该是:

.content {
  display: block;
  margin-left: 60px;
  img {
    display: block;
    padding: 5px 0;
  }
}
.content:hover img {
  transform: scale(1.5);
}

I have no idea what's that span.picture selector for, at least there's no span element with class picture on the HTML you are showing. 我不知道span.picture选择器是什么,至少在你正在显示的HTML上没有带有类图片的span元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM