html - 怪异事件处理

标签 html css web

我制作了一个简单的网站,其中包含左右固定位置的箭头 (png) 图像,链接到下一页。
问题是光标无法选择包含图像的 anchor 元素,如下所示:

GIF .

这是元素的代码:

<a class="arrow-left" href="previousPage.php"><img src="img/left.png"></a>
<a class="arrow-right" href="nextPage.php"><img src="img/right.png"></a>

如您所见,它是纯 html 代码,.arrow-left.arrow-right 类使用 scss 设置样式:

.arrow-right {
  position: fixed;
  max-width: 3%;
  z-index: 10;
  right: 1%;
  top: 50%; }

.arrow-left {
  position: fixed;
  max-width: 3%;
  z-index: 10;
  left: 1%;
  top: 50%; }

最佳答案

您可以在 .arrow-right.arrow-left 上尝试 display: block

提示:
如果您将以更紧凑的方式编写代码,那么将来修改起来会更容易:

.arrow-right,
.arrow-left {
  display: block;
  position: fixed;
  max-width: 3%;
  z-index: 10;
  top: 50%;
}

.arrow-right {
  right: 1%;
}
.arrow-left {
  left: 1%;
}

然后你只需要在一个地方编辑代码来添加display: block;

关于html - 怪异事件处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53154602/

相关文章:

reactjs - 仅在有内容时才使 flex-item 荣誉宽度

css - 处理界面咏叹调间距的问题

javascript - 检查字符串是否是数组的一部分 - javascript

python - 如何在 HTML 中运行 Python 脚本?

html - 如何将HTML中的具体内容解析到我的App中

javascript - 使用 jQuery 鼠标拖动时垂直滚动页面并水平滚动 div 内的大图像

css - 适用于手机/小屏幕的响应式 CSS

javascript - 如何使用javascript更改html选择器的宽度

javascript - 如何动态设置工具提示宽度?

php - 无法检查登录错误(空白)