html - HTML 图像不会链接到页面
问题描述
有一种愚蠢的问题,即我的 HTML 图像不会链接到页面并且不会显示为可点击。我有一个购物车和一个购物车图标,显示购物车中的商品数量。图像包含在 CSS 中。我尝试z-index
一直设置,但什么也没发生。不确定我是否遗漏了一些明显的东西。对此相当新,因此感谢您的帮助!以下是我的代码:
.cart {
background-color: #E55F5F;
background-image: url(images/shoppingcart.png);
background-size: contain;
color: white;
height: 60px;
width: 60px;
line-height: 60px;
text-align: center;
margin-top: -20px;
border-radius: 50%;
position: fixed;
z-index: 1000;
overflow: hidden;
}
<li>
<div class="cart">
<a href="/homework_6/cart.html"></a>
</div>
<div id="quantityCount">0</div>
</li>
解决方案
你的标签没有任何价值,所以它可以被点击。
你可以像下面这样使用它:
<li>
<div class="cart"><a href="/homework_6/cart.html">cart</a></div>
< id="quantityCount">0</div>
</li>
否则,如果您想将计数显示为 clicable
<li>
<div class="cart"><a href="/homework_6/cart.html"><span id="quantityCount">0</span></a></div>
</li>
推荐阅读
- java - 无法使用 Apache POI 读取 Excel
- java - 配置 maven 打包 fat jar 而无需在 vertx 项目中解包依赖项,就像 spring boot 一样
- php - 我想从表中选择所有记录,分组计数大于 5
- javascript - 使用 Array 使用 Memoize 函数比较符号
- c - 我可以编译一个依赖于库的 C 程序,但是这个库不是 .h 文件是二进制文件,因为它是先编译的?
- matlab - googlent/Resnet50/Resnet101/inception v2 和 v3 中的全连接层是什么
- vb.net - SAPI SPEAK 如何做一个后台工作人员
- python - 如何在 scipy.optimize.minimize 中传递一组输入参数?
- xamarin - xamarin ios中的相机和图库
- javascript - 如何使用 findOneAndUpdate 在数组中添加信息而不删除先前包含的信息