[英]class name in Rails helper
I added a 'map' class to a Rails image_tag helper like this 我像这样向Rails image_tag帮助器添加了一个“地图”类
<%= image_tag "http://maps.google.com/maps/api/staticmap?size=300x200&sensor=false&zoom=16&markers={{ latitude }}%2C{{ longitude }}", :class => "map" %>
I tried to set styles specific to that image with the map class, so that the image wouldn't be visible by default: 我尝试通过map类设置特定于该图像的样式,以使该图像在默认情况下不可见:
img {
border: solid 0px black;
}
img .map { visibility: hidden
}
However, the map class image is visible by default 但是,默认情况下,地图类图像可见
The 'map' class is visible in the html. 'map'类在html中可见。
<img alt="Staticmap?size=300x200&sensor=false&zoom=16&markers=40.6891947%2c-74.0444169" class="map" src="http://maps.google.com/maps/api/staticmap?size=300x200&sensor=false&zoom=16&markers=40.6891947%2C-74.0444169">
When I inspect the element, Chrome console shows that its only the styles from img
that are registering, not img .map
当我检查元素时,Chrome控制台显示它仅是正在注册的
img
中的样式,而不是img .map
Can you see what I might be doing wrong? 可以看到我可能做错了吗?
Your CSS should say 您的CSS应该说
img.map {
visibility: hidden
}
With the space it is the CSS element element selector. 带有空格的是CSS 元素元素选择器。 It selects elements inside elements.
它在元素内部选择元素。 You are looking to use the class selector .
您正在寻找使用类选择器 。
Remove the gap between IMG & .map class . 消除IMG和.map类之间的差距。 Write like this:
这样写:
img.map { visibility: hidden}
because with space the terminology is changed img .map
it's said class .map within the img tag & img.map
it's said class .map with img tag. 因为空间的术语改变
img .map
有人说img标签与类内.MAP img.map
有人说类.MAP与img标签。
Read this for more What does a space mean in a CSS selector? 阅读更多内容CSS选择器中的空格是什么意思? ie What is the difference between .classA.classB and .classA .classB?
即.classA.classB和.classA .classB有什么区别?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.