html - 边框悬停后如何停止图像移动?

标签 html image css

<分区>

我有 3 张图像,我通过 css 编码使边框悬停。 它既简单又漂亮,但悬停时图像会继续移动。

http://coreneto.com/rental/static/dist/img/cam.jpg http://coreneto.com/rental/static/dist/img/car.jpg http://coreneto.com/rental/static/dist/img/phone.jpg

现场直播: JSfiddle

代码如下:

<center>
  <a class="round" href="http://coreneto.com/rental/cars"><img src="http://coreneto.com/rental/static/dist/img/cam.jpg" width="200" height="200"></a>&nbsp;&nbsp;
  <a class="round" href="http://coreneto.com/rental/cars"><img src="http://coreneto.com/rental/static/dist/img/car.jpg" width="200" height="200"></a>&nbsp;&nbsp;
  <a class="round" href="http://coreneto.com/rental/tickets"><img src="http://coreneto.com/rental/static/dist/img/phone.jpg" width="200" height="200"></a>
</center>

这是CSS:

a.round:hover {border: 5px solid #005FD0; display: inline-block; position: static;
    cursor: pointer;  }

我需要使用什么正确的 css 方法来使它们在悬停时保持在​​原位?

最佳答案

给非悬停状态一个透明边框:

a.round {
    border: 5px solid transparent;
    display: inline-block;
    position: static;
    cursor: pointer;
}

jsFiddle example

另请注意,您可能希望给图像一个 vertical-align:top;规则以消除它们下方的间隙。并且请不要使用 <center>元素。

关于html - 边框悬停后如何停止图像移动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36184650/

上一篇:css - 扩展 Firefox 中的外部元素以包含内部元素

下一篇:html - 右侧的纯 css3 slider 无法正常工作

相关文章:

php - 在不使用 FormData() 的情况下使用 ajax 将图像发送到 php 文件

javascript - 使用 CSS 裁剪/调整图像大小以更改纵横比

jquery - 绝对 div 停止重叠 - 让它们相对移动

java - 我如何使用我的日期格式 yyyy-mm-dd 在我的选择框中列出月份值

image - 输出电影太快了如何控制

html - 将两个相邻的 div 与左向文本水平对齐

html - 带有渐变和箭头的 CSS 动态大小按钮的最佳实践

html - 调整 Web 浏览器 HTML 大小时文本被压扁 | CSS

javascript - 检测函数何时在 JavaScript 中被调用

html - 如何将 div 的动态列表排列成 2 列