本专栏记录的是经常使用的CSS示例与技巧,主要包含CSS布局,CSS特效,CSS花边信息三部分内容。其中CSS布局主要是列出一些常用的CSS布局信息点,CSS特效主要是一些动画示例,CSS花边是描述了一些CSS相关的库、知识点、理论篇章等。 因为常用所以记录、展示、分享,希望能给您带来帮助。
css实战中,怎么绘制菜单hover后的不同效果呢?主要利用了transition: all 0.3s ease 0s;功能和:after前后的触发变化,hover时候,背景颜色变换,长度有变化。
效果图
源代码
/*
* @Author: 大剑师兰特(xiaozhuanlan),还是大剑师兰特(优快云)
* @此源代码版权归大剑师兰特所有,可供学习或商业项目中借鉴,未经授权,不得重复地发表到博客、论坛,问答,git等公共空间或网站中。
* @Email: 2909222303@qq.com
* @weixin: gis-dajianshi
* @First published in 优快云
* @First published time: 2023-11-27
*/
<template>
<div class="container">
<div class="top">
<h3>菜单的hover不同动画背景</h3>
<div class="author">大剑师兰特, 还是大剑师兰特,gis-dajianshi</div>
</div>
<div class="dajianshi">
<nav>
<ul>
<li><a href="http://www.cuclife.com" target="_blank">大剑师的海鸟网</a></li>
<li><a href="http://www.cuclife.cn" target="_blank">大剑师的001生活网</a></li>
<li><a href="https://dajianshi.blog.youkuaiyun.com/" target="_blank">大剑师的优快云博客</a></li>
</ul>
</nav>
</div>
</div>
</template>
<style scoped>
.container {
width: 1000px;
height: 580px;
margin: 50px auto;
border: 1px solid green;
position: relative;
}
.top {
margin: 0 auto 0px;
padding: 10px 0;
background: black;
color: #fff;
}
.dajianshi {
width: 300px;
height: 300px;
margin: 100px auto;
}
nav {
float: none;
clear: both;
width: 300px;
background: #eee;
}
nav ul {
list-style: none;
margin: 0px;
padding: 0px;
}
nav li {
float: none;
width: 100%;
}
nav li a {
display: block;
width: 100%;
padding: 20px;
border-left: 5px solid;
border-bottom: 1px solid #fff;
position: relative;
z-index: 2;
text-decoration: none;
color: #444;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
nav li a:hover {
border-bottom: 0px;
color: #fff;
}
nav li:first-child a {
border-left: 10px solid red;
}
nav li:nth-child(2) a {
border-left: 10px solid orange;
}
nav li:nth-child(3) a {
border-left: 10px solid green;
}
nav li a:after {
content: "";
height: 100%;
left: 0;
top: 0;
width: 0px;
position: absolute;
transition: all 0.3s ease 0s;
-webkit-transition: all 0.3s ease 0s;
z-index: -1;
}
nav li a:hover:after {
width: 100%;
}
nav li:first-child a:after {
background: red;
}
nav li:nth-child(2) a:after {
background: orange;
}
nav li:nth-child(3) a:after {
background: green;
}
</style>
No. | 大剑师精品GIS教程推荐 |
---|---|
0 | 地图渲染基础- 【WebGL 教程】 - 【Canvas 教程】 - 【SVG 教程】 |
1 | Openlayers 【入门教程】 - 【源代码+示例 300+】 |
2 | Leaflet 【入门教程】 - 【源代码+图文示例 150+】 |
3 | MapboxGL 【入门教程】 - 【源代码+图文示例150+】 |
4 | Cesium 【入门教程】 - 【源代码+综合教程 200+】 |
5 | threejs 【中文API】 - 【源代码+图文示例200+】 |
6 | Shader 编程 【图文示例 100+】 |
7 | Geoserver 【配置教程 100+】 |
8 | 卫星应用开发教程 【配置+应用教程 100+】 |
9 | GIS数字孪生与大模型 【应用实战 100+】 |
10 | 报表与数字大屏 【Echarts 实战示例】 - 【D3 综合教程】 - 【其他大屏】 |