logo图案的切换

<body>
	<div class="box">
		<a href="#"></a>
		
	</div>
</body>

先写好主体

* {
			padding: 0;
			margin: 0;
}
		
.box {
			
			width: 55px;
			height: 55px;
			background-color: tomato;
			margin: 100px auto;
			
}

写上取消内外边距

给盒子大小,以及颜色,并居中

a {

            
			display:black;
			width: 110px;
			height: 55px;
			
        }

给a 大小

a::before {
			position: absolute;
			content:'';
			top: 0;
			left: 0;
			width: 55px;
			height: 55px;
			color: #fff;
			font-size: 20px;
			line-height: 55px;
			text-align: center;
			
		}
a::after {
			position: absolute;
			content: '';
			top:0 ;
			right: 0;
			width: 55px;
			height: 55px;
			color: #FFFDEF;
			font-size: 20px;
			line-height: 55px;
			text-align: center;
		}

用伪元素添加图标,并且定位

.box {
			position: relative;
			width: 55px;
			height: 55px;
			background-color: tomato;
			margin: 100px auto;
			overflow: hidden;
		}
 a {
			display: inline-block;
            font-family: 'icomoon';
			position: absolute;
			top:0;
			left: 0;
			width: 110px;
			height: 55px;
			
        }

子绝父相

a:hover {
			left: -55px;
		}
a {
			display: inline-block;
            font-family: 'icomoon';
			position: absolute;
			top:0;
			left: 0;
			width: 110px;
			height: 55px;
			transition: all .5s;
        }

给logo添加图标切换,transition 使切换更为丝滑。

content:'';
这个可以保留空值
转用url()的方法也可以
但是 content:''; 加载的图标,是具有字体属性,调试更为方便
url(), 加载的图标仅是图片属性。

全程序图

<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>小米logo</title>
	
	<style type="text/css">
//这是图标加载必须要写 , 用url()不写
 @font-face {
            font-family: 'icomoon';
            src: url('fonts/icomoon.eot?lmfbsv');
            src: url('fonts/icomoon.eot?lmfbsv#iefix') format('embedded-opentype'),
                url('fonts/icomoon.ttf?lmfbsv') format('truetype'),
                url('fonts/icomoon.woff?lmfbsv') format('woff'),
                url('fonts/icomoon.svg?lmfbsv#icomoon') format('svg');
            font-weight: normal;
            font-style: normal;
            font-display: block;
        }

        a {
			display: inline-block;
            font-family: 'icomoon';
			position: absolute;
			top:0;
			left: 0;
			width: 110px;
			height: 55px;
			transition: all .5s;
        }


		* {
			padding: 0;
			margin: 0;
		}
		
		.box {
			position: relative;
			width: 55px;
			height: 55px;
			background-color: tomato;
			margin: 100px auto;
			overflow: hidden;
		}
		a::before {
			position: absolute;
			content:'';
			top: 0;
			left: 0;
			width: 55px;
			height: 55px;
			color: #fff;
			font-size: 20px;
			line-height: 55px;
			text-align: center;
			
		}
		a::after {
			position: absolute;
			content: '';
			top:0 ;
			right: 0;
			width: 55px;
			height: 55px;
			color: #FFFDEF;
			font-size: 20px;
			line-height: 55px;
			text-align: center;
		}
		a:hover {
			left: -55px;
		}
	</style>
</head>
<body>
	<div class="box">
		<a href="#"></a>
		
	</div>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
为了实现HTML页面的背景图片轮播效果,你可以采用以下步骤: 1. 首先,确保你有多张需要进行轮播的背景图片。这些图片可以是存储在本地文件夹中的文件,或者是通过链接引用的在线图片。 2. 在HTML文件中,创建一个容器元素来承载背景图片,例如一个`<div>`元素。给这个容器元素设置一个唯一的`id`属性,以便于在JavaScript中引用。 3. 使用CSS来设置容器元素的样式,包括宽度、高度和背景图片等。你可以通过设置`background-image`属性来指定背景图片,在这个属性值中可以使用多个图片地址,并用逗号分隔。 4. 在JavaScript中,使用`setInterval`函数来设置定时器,以便在一定时间间隔后切换背景图片。在定时器函数中,可以通过修改容器元素的样式来切换背景图片。你可以使用`style`属性的`backgroundImage`属性来修改背景图片。 5. 在页面加载完成后,调用JavaScript函数来启动定时器,开始背景图片的轮播效果。 请注意,以上所述的步骤只是一种实现背景图片轮播的一种方法,还有其他的方法可以实现类似的效果。具体的实现方式还会根据你的具体需求和项目使用的框架或库而有所不同。<span class="em">1</span><span class="em">2</span> #### 引用[.reference_title] - *1* [HTML图片轮播](https://blog.csdn.net/m0_45329584/article/details/104853908)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [用node开发应用程序,对nodejs+express工程打包封装,通常公司产品化的软件系统,需要标识为公司的logo和...](https://download.csdn.net/download/Thor027/88284823)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值