【CSS 06】图标 icons 链接 link 光标 cursor

这篇具有很好参考价值的文章主要介绍了【CSS 06】图标 icons 链接 link 光标 cursor。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

图标 icons

向 HTML 页面添加图标的最简单方法是使用图标库,比如 Font Awesome

将指定的图标类的名称添加到任何行内 HTML 元素(如 <i><span>)

下面的图标库中的所有图标都是可缩放矢量,可以使用 CSS进行自定义(大小、颜色、阴影等)

如需使用 Font Awesome 图标,请访问 fontawesome.com,登录并获取代码添加到 HTML 页面的 <head> 部分
<script src="https://kit.fontawesome.com/yourcode.js"></script>(此方式可能已经不可用)

如需使用 Bootstrap glyphicons,请在 HTML 页面的 <head> 部分内添加这行:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<body class="container">

<p>一些 Bootstrap 图标:</p>
<i class="glyphicon glyphicon-cloud"></i>
<i class="glyphicon glyphicon-remove"></i>
<i class="glyphicon glyphicon-user"></i>
<i class="glyphicon glyphicon-envelope"></i>
<i class="glyphicon glyphicon-thumbs-up"></i>
<br><br>

<p>有样式的 Bootstrap 图标(尺寸和颜色):</p>
<i class="glyphicon glyphicon-cloud" style="font-size:24px;"></i>
<i class="glyphicon glyphicon-cloud" style="font-size:36px;"></i>
<i class="glyphicon glyphicon-cloud" style="font-size:48px;color:red;"></i>
<i class="glyphicon glyphicon-cloud" style="font-size:60px;color:lightblue;"></i>

</body>

如需使用 Google 图标,请在HTML页面的 <head> 部分中添加以下行:
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">

<body>

<p>一些 Google 图标:</p>
<i class="material-icons">cloud</i>
<i class="material-icons">favorite</i>
<i class="material-icons">attachment</i>
<i class="material-icons">computer</i>
<i class="material-icons">traffic</i>
<br><br>

<p>有样式的 Google 图标(尺寸和颜色):</p>
<i class="material-icons" style="font-size:24px;">cloud</i>
<i class="material-icons" style="font-size:36px;">cloud</i>
<i class="material-icons" style="font-size:48px;color:red;">cloud</i>
<i class="material-icons" style="font-size:60px;color:lightblue;">cloud</i>

</body>

链接 link

通过CSS可以用不同的方式设置链接的样式文章来源地址https://www.toymoban.com/news/detail-480194.html

链接可以使用任何 CSS 属性(例如 color、font-family、background 等)来设置样式
a {
	color: hotpink;
}

此外可以根据链接处于什么状态来设置链接的不同样式
四种链接状态分别是:
1. a:link
2. a:visited
3. a:hover
4. a:active

/* 未被访问的链接 */
a:link {
  color: red;
}
/* 已被访问的链接 */
a:visited {
  color: green;
}
/* 将鼠标悬停在链接上 */
a:hover {
  color: hotpink;
}
/* 被选择的链接 */
a:active {
  color: blue;
}

a:hover 必须 a:link 和 a:visited 之后
a:active 必须在 a:hover 之后

text-decoration 属性主要用于从链接中删除下划线
a:link {
  text-decoration: none;
}
a:visited {
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
a:active {
  text-decoration: underline;
}

background-color 属性可用于指定链接的背景色
a:link {
	background-color: yellow;
}

a:visited {
	background-color: cyan;
}

a:hover {
	background-color: lightgreen;
}

a:active {
	background-color: hotpink;
}

本例演示了一个更高级的例子,其中我们组合了多个 CSS 属性,将链接显示为框/按钮
a:link, a:visited {
  background-color: #f44336;
  color: white;
  padding: 14px 25px;
  text-align: center; 
  text-decoration: none;
  display: inline-block;
}

a:hover, a:active {
  background-color: red;
}

<a href="/index.html" target="_blank">这是一个链接</a>

更多有趣的链接样式

1 为超链接添加不同的样式
<!DOCTYPE html>
<html>
<head>
<style>
a.one:link {color:#ff0000;}
a.one:visited {color:#0000ff;}
a.one:hover {color:#ffcc00;}

a.two:link {color:#ff0000;}
a.two:visited {color:#0000ff;}
a.two:hover {font-size:150%;}

a.three:link {color:#ff0000;}
a.three:visited {color:#0000ff;}
a.three:hover {background:#66ff66;}

a.four:link {color:#ff0000;}
a.four:visited {color:#0000ff;}
a.four:hover {font-family:monospace;}

a.five:link {color:#ff0000;text-decoration:none;}
a.five:visited {color:#0000ff;text-decoration:none;}
a.five:hover {text-decoration:underline;}
</style>
</head>
<body>

<p>请把鼠标移到链接上并观察样式的变化:</p>

<p><b><a class="one" href="/index.html" target="_blank">此链接改变颜色</a></b></p>
<p><b><a class="two" href="/index.html" target="_blank">此链接改变字体大小</a></b></p>
<p><b><a class="three" href="/index.html" target="_blank">此链接改变背景色</a></b></p>
<p><b><a class="four" href="/index.html" target="_blank">此链接改变字体族</a></b></p>
<p><b><a class="five" href="/index.html" target="_blank">此链接改变文本装饰</a></b></p>

</body>
</html>

2 创建带有边框的链接按钮
<!DOCTYPE html>
<html>
<head>
<style>
a:link, a:visited {
  background-color: white;
  color: black;
  border: 2px solid green;
  padding: 10px 20px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}

a:hover, a:active {
  background-color: green;
  color: white;
}
</style>
</head>
<body>

<a href="/index.html" target="_blank">这是一个链接</a>

</body>
</html>

3 改变光标
cursor 属性指定要显示的光标类型
<!DOCTYPE html>
<html>
<body>

<p>请把鼠标移动到单词上,以查看指针效果:</p>
<span style="cursor:auto">auto</span><br>
<span style="cursor:crosshair">crosshair</span><br>
<span style="cursor:default">default</span><br>
<span style="cursor:e-resize">e-resize</span><br>
<span style="cursor:help">help</span><br>
<span style="cursor:move">move</span><br>
<span style="cursor:n-resize">n-resize</span><br>
<span style="cursor:ne-resize">ne-resize</span><br>
<span style="cursor:nw-resize">nw-resize</span><br>
<span style="cursor:pointer">pointer</span><br>
<span style="cursor:progress">progress</span><br>
<span style="cursor:s-resize">s-resize</span><br>
<span style="cursor:se-resize">se-resize</span><br>
<span style="cursor:sw-resize">sw-resize</span><br>
<span style="cursor:text">text</span><br>
<span style="cursor:w-resize">w-resize</span><br>
<span style="cursor:wait">wait</span><br>

</body>
</html>

到了这里,关于【CSS 06】图标 icons 链接 link 光标 cursor的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【Unity】Cursor类——隐藏鼠标、锁定鼠标、设置鼠标图标

    把导入的光标图片资源设置成Cursor类型 注意:想要图片不变形,要使用宽高一样的图片

    2024年02月11日
    浏览(36)
  • element icon图标用法

    1.基础用法:  2.直接使用 SVG 图标 3.下载成PNG使用                  

    2024年04月09日
    浏览(30)
  • html+css+js制作LOL官网,web前端大作业(3个页面+模拟登录+链接)

    index.html index.css introduce.html introduce.css shop.html shop.css 链接:https://pan.baidu.com/s/1VtaAMts5TnKk8CJtaL750Q 提取码:LDL6

    2024年02月02日
    浏览(46)
  • windows应用程序icon缓存、查看图标、icon制作方法

    在vs中替换c++程序的图标后,需要重新编译,但是很多情况下都不会刷新,还是看到老的图标,只能重启电脑才能看到新的图标。 通过ChatGPT得到相关的回答如下: 如果在 Windows 上更换了可执行文件 (.exe) 的图标,但是在图标文件已经更改的情况下仍然显示旧的图标,可能是因

    2024年02月14日
    浏览(34)
  • 如何给网页添加icon图标?

    做一些小页面或者项目的时候,我们会发现每个网站都有自己的小图标,下面我就告诉你怎么弄这个,超简单的!💜💜 网页图标favicon.ico小简介 favicon.ico一般用于作为缩略的网站标志,它显示在浏览器的地址栏、浏览器标签上或者在收藏夹上,是展示网站个性的缩略logo标志

    2024年02月05日
    浏览(23)
  • 菜单管理中icon图标回显

    2024年02月07日
    浏览(29)
  • 什么是字体图标(Icon Font)?如何在网页中使用字体图标?

    前端入门之旅:探索Web开发的奇妙世界 记得点击上方或者右侧链接订阅本专栏哦 几何带你启航前端之旅 欢迎来到前端入门之旅!这个专栏是为那些对Web开发感兴趣、刚刚踏入前端领域的朋友们量身打造的。无论你是完全的新手还是有一些基础的开发者,这里都将为你提供一

    2024年02月11日
    浏览(34)
  • vue 页签图标 icon 修改设置

    最近在写 Vue 项目时,有一个需求是替换页签的图标,不过在网上查了好久,发现没有一个是生效的 最后结合了两篇文章里的内容,才将这个需求实现,现在来记录一下   在 vue.config.js文件中添加以下代码:   然后在 public/index.html文件中修改原 icon 代码,将 link rel=\\\"icon\\\" hre

    2024年02月19日
    浏览(23)
  • Element Plus Icon图标自动引入

    安装Icon 图标   自动导入 首先你需要安装 unplugin-icons 和 unplugin-auto-import 这两款插件 修改配置文件 按需引入后发现 https://www.yyyi1.cn/detail?id=63e65183982003a0a19bbe23

    2024年02月12日
    浏览(23)
  • 微信小程序项目中使用icon图标

    效果: 步骤: 1、先让ui负责人把你的账号加入到项目中,加入到项目中后就可以在icon图标库中看到该项目 2、在小程序中使用 新建一个view,在上面加一个class,复制icon名字上去即可,注意格式,格式为iconfont icon名。 iconfont这个前缀不是固定的,根据icon名字来,icon的前缀为

    2024年02月11日
    浏览(45)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包