当前位置: 首页 > article >正文

CSS综合案例4

CSS综合案例4

1. 综合案例

我们来做一个静态的轮播图。

image-20240204165511757

2. 分析思路

  1. 首先需要加载一张背景图进去
  2. 需要4个小圆点,设置样式,并用定位和平移调整位置
  3. 添加两个箭头,也是需要用定位和位移进行调整位置

image-20240204165851160

3. 代码演示

html文件

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>静态轮播图</title>
		<link rel="stylesheet" href="./style.css" />
	</head>
	<body>
		<div class="box">
			<img src="./R-C.jpg" alt="穿越火线" />
			<div class="arrow1">
				<p><</p>
			</div>
			<div class="arrow2">
				<p>></p>
			</div>
			<div class="Carousel"></div>
			<div class="wrapper">
				<div class="point"></div>
				<div class="point"></div>
				<div class="point"></div>
				<div class="point"></div>
			</div>
		</div>
	</body>
</html>

css文件

* {
	box-sizing: border-box;
}
.box {
	width: 1024px;
	height: 729px;
	position: absolute;
	left: 50%;
	top: 50%;
	/*translateX x轴位移,单位百分比或者px */
	transform: translate(-50%, -50%);
}

.arrow1 {
	width: 30px;
	height: 40px;
	background-color: #3e3f43;
	border-radius: 0 70% 60% 0;
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	opacity: 0.5;
	cursor: pointer;
}
.arrow2 {
	width: 30px;
	height: 40px;
	background-color: #3e3f43;
	border-radius: 70% 0 0 60%;
	position: absolute;
	top: 50%;
	left: 994px;
	transform: translateY(-50%);
	opacity: 0.5;
	cursor: pointer;
}

.arrow1 > p {
	position: absolute;
	left: 6px;
	top: -13px;
	font-size: 20px;
	color: #fff;
}
.arrow2 > p {
	position: absolute;
	left: 9px;
	top: -13px;
	font-size: 20px;
	color: #fff;
}
.Carousel {
	position: absolute;
	left: 50%;
	bottom: 20px;
	transform: translateX(-50%);
	width: 120px;
	height: 20px;
	border: 1px solid #ccc;
	background-color: #fff;
	border-radius: 20px;
	display: flex;
	align-items: center;
	justify-content: space-around;
	opacity: 0.1;
}

.point {
	left: 50%;
	bottom: 20px;
	transform: translateX(-50%);
	width: 10px;
	height: 10px;
	background-color: #fafafa;
	border-radius: 50%;
	cursor: pointer;
}
.wrapper {
	position: absolute;
	left: 50%;
	bottom: 20px;
	transform: translateX(-50%);
	width: 120px;
	height: 20px;
	border-radius: 20px;
	display: flex;
	align-items: center;
	justify-content: space-around;
}

.point:hover {
	background-color: #f55719;
}


http://www.kler.cn/news/233140.html

相关文章:

  • Vue ElementUI中el-table表格嵌套样式问题
  • github和gitee
  • Excel+VBA处理高斯光束
  • 全网最快2024刘谦春晚魔术揭秘
  • ssh和sftp服务分离
  • 关于LLaMA Tokenizer的一些坑...
  • 【征稿已开启】第五大数据、人工智能与软件工程国际研讨会(ICBASE 2024)
  • Elasticsearch中的动态DSL解决方案
  • Android 自定义BaseActivity
  • ES实战-book笔记1
  • OCP使用web console创建和构建应用
  • .gitlab-ci.yml文件参数
  • 极狐GitLab 与钉钉的集成实践
  • C++的学习记录
  • [office] excel求乘积的公式和方法 #媒体#笔记#经验分享
  • H12-821_74
  • 贵金属交易包括哪些?香港有哪些贵金属交易平台?
  • 力扣热题100_双指针_11_盛最多水的容器
  • 2022美国大学生数学建模(优秀获奖论文)-A题:Power Planning Model: Magic Weapon for Cyclists
  • Linux time命令教程:如何测量命令的执行时间(附案例详解和注意事项)
  • 【PyQt】08 - 编辑Tab顺序
  • 编译器选择:VSCode安装MarkDown插件
  • mysql RR、RC隔离级别实现原理
  • Node.js之npm单独与批量升级依赖包的方式
  • Android14音频进阶:MediaPlayerService如何启动AudioTrack 上篇(五十五)
  • 有关网络安全的课程学习网页
  • Nginx全面配置
  • 【Java EE初阶十】多线程进阶二(CAS等)
  • 从0开始图形学(光栅化)
  • 【Python】使用 requirements.txt 与 pytorch 相关配置