使用引导卡作为超链接

编程入门 行业动态 更新时间:2024-10-10 10:23:08
本文介绍了使用引导卡作为超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个用作链接的引导卡.

I have a bootstrap card Which is used as a link.

尝试用< a> 包装它会更改卡的所有样式.

Trying to wrap it with <a> changes all of the styling of the card.

<link rel="stylesheet" href="maxcdn.bootstrapcdn/bootstrap/4.0.0/css/bootstrap.min.css"> <div class="card" style="width: 15rem; display: inline-block"> <img class="card-img-top" src="placeholdit.imgix/~text?txtsize=33&txt=318%C3%97180&w=318&h=180" alt="Card image cap"> <div class="card-body"> <h5 class="card-title">Normal card</h5> <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> </div> </div> <a href=""> <div class="card" style="width: 15rem; display: inline-block"> <img class="card-img-top" src="placeholdit.imgix/~text?txtsize=33&txt=318%C3%97180&w=318&h=180" alt="Card image cap"> <div class="card-body"> <h5 class="card-title">Wrapped with a tag</h5> <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> </div> </div> </a>

我应该如何包装卡片以保留其外观并将其用作链接?

How should I wrap the card in order to preserve its looks and use it as a link?

推荐答案

这是因为< a> 标签在用户代理浏览器中具有默认的蓝色.尝试将一个类添加到链接中,然后将 color:inherit 设置为该类

Its because <a> tags has a default blue color from user agent browser. Try to add a class to the link and set color:inherit to that class

a.custom-card, a.custom-card:hover { color: inherit; }

<link rel="stylesheet" href="maxcdn.bootstrapcdn/bootstrap/4.0.0/css/bootstrap.min.css"> <div class="card" style="width: 15rem; display: inline-block"> <img class="card-img-top" src="placeholdit.imgix/~text?txtsize=33&txt=318%C3%97180&w=318&h=180" alt="Card image cap"> <div class="card-body"> <h5 class="card-title">Normal card</h5> <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> </div> </div> <a href="" class="custom-card"> <div class="card" style="width: 15rem; display: inline-block"> <img class="card-img-top" src="placeholdit.imgix/~text?txtsize=33&txt=318%C3%97180&w=318&h=180" alt="Card image cap"> <div class="card-body"> <h5 class="card-title">Wrapped with a tag</h5> <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> </div> </div> </a>

更多推荐

使用引导卡作为超链接

本文发布于:2023-11-28 08:39:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641699.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:超链接

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!