在屏幕中央显示图像 CSS jQuery
showing image in center of screen css jquery
我试图在jquery和CSS中悬停缩略图时显示一个大图像。我有 2 张图片作为
<td>
<% if camera["is_public"] == "t" %>
<img src="https://media.evercam.io/v1/cameras/<%= camera["exid"] %>/thumbnail?" height="32" class="thumbnails">
<img src="https://media.evercam.io/v1/cameras/<%= camera["exid"] %>/thumbnail?" height="600" class="full-image">
<% else %>
<img src="https://media.evercam.io/v1/cameras/<%= camera["exid"] %>/thumbnail?api_id=<%= camera["api_id"] %>&api_key=<%= camera["api_key"] %>" height="32" class="thumbnails">
<img src="https://media.evercam.io/v1/cameras/<%= camera["exid"] %>/thumbnail?api_id=<%= camera["api_id"] %>&api_key=<%= camera["api_key"] %>" height="600" class="full-image">
<% end %>
</td>
和 CSS 作为
.full-image {
display: none;
z-index: 99999;
top: 10%;
width: 600px;
height: auto;
right: 34%;
}
悬停.thumbnail
触发此功能
onImageHover = ->
$("#snapshots_datatables").on "mouseover", ".thumbnails", ->
nextImage = $(this).siblings(".full-image")
$(nextImage).css({"top": "10%"})
nextImage.show()
$("#snapshots_datatables").on "mouseout", ".thumbnails", ->
nextImage.hide()
我所有的问题是我想在屏幕中央悬停.thumbnail
但是显示height: 600
图像,关于屏幕尺寸和滚动。即使我向下滚动图像也应该在屏幕中央显示。任何帮助将不胜感激。我自己添加CSS的运气为零。
编辑:与引导模型相同,即使它在屏幕中单击非常下方,但它出现在屏幕中间。
你真的不需要javascript。我认为 css 可以解决问题。
首先,您要确保 .full-image 始终位于屏幕中央。
.full-image {
position: fixed;
width: 600px;
height: 600px;
left: 50%;
top: 50%;
margin-left: -300px;
margin-top: -300px;
background: red;
display: none;
}
然后,您希望在将鼠标悬停在 .thumbnail 上时使其显示
.thumbnail:hover .full-image {
display: block;
}
这是工作演示
http://codepen.io/Jeffersonvdh/pen/GZBMBQ
相关文章:
- 如何使用css动画/javascript使具有背景图像的元素出现
- css停止图像在滚动中移动
- 浮动图像左作为背景-css
- 使用css()设置背景图像;不起作用
- 在屏幕中央显示图像 CSS jQuery
- 确定body's背景图像(css)已加载
- 如何设置DIV背景图像css jquery
- JQuery 如何仅添加带有第 n 个子级的点击图像 CSS 类
- 如何防止谷歌浏览器在设置背景图像 css 时击中服务器
- 如何使用nodejs获取我网站上所有图像/ css / js的所有文件大小
- jquery背景图像css
- JQuery切换图像CSS
- 用文本交换图像(CSS或jQuery?).
- 背景图像CSS不显示
- Nav背景以匹配身体背景图像Css
- 更改基于屏幕的不同背景图像:-css HTML5 Gallery
- 动态创建图像/CSS到画布
- 仅浮动图像 css
- 图像 CSS 样式上不需要的边框
- 如何在图像 CSS 上放置一个思想气泡