CSS训练

1:

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .box1{
        display: flex;
        border: 1px solid blue;
        border-radius: 5px;
        width: 800px;
    }
    .bin{
        background-color: blue;
        color: white;
        border: none;
        padding: 10px 20px;
        font-size: 12px;
        cursor: pointer;
    }
    .bin:hover{
        background-color: darkblue;
    }
    .input{
        width: 630px;
        border: none;
        padding: 10px;
        font-size: 10px; 
    }
    .input:focus{
        outline: none;
    }
    .img:hover{
        opacity: 0.5;
    }
</style>
<body>
    <div class="box1">
        <input type="text" class="input">
        <img src="./img/相机.jpeg" class="img" style="height: 60px; cursor: pointer">
        <button class="bin">百度一下</button>
    </div>
</body>
</html>

效果图:

2:

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .zhuti{
        display: flex;
        flex-direction: column;
        align-items: center;
        border: 2px dashed black;
        border-radius: 8px;
        width: 1000px;
    }
    .span{
        display: flex;
        justify-content: center;
        align-items: center;
        height: 180px;
        cursor: pointer;
        position: relative;
    }
    .touch{
        position: relative;
        width: 150px;
        height: 100px;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .touch::before{
        content: '';
        position: absolute;
        top: 50%;
        left: 0%;
        width: 100%;
        height: 1px;
        background-color: gainsboro;
    }
    .touch::after{
        content: '';
        position: absolute;
        top: 0%;
        left: 50%;
        height: 100%;
        width: 1px;
        background-color: gainsboro;
    }
    .btn{
        border: none;
        border-radius: 4px;
        padding: 10px 20px;
        cursor: pointer;
        font-size: medium;
        position: relative;
        top: 70px;
        color: white;
        background-color: blue;
    }
    .btn:hover{
        background-color: darkblue;
    }
</style>
<body>
    <div class="zhuti">
        <input type="file" id="file-upload" class="input">
        <span for="file-upload" class="span">
            <div class="touch"></div>
        </span>
        <button class="btn">选择文件</button>
    </div>
</body>
</html>

效果图:

3:

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>number_3</title>
    <style>
        .search {
            width: 800px;
            display: flex;
            align-items: center;
            border: 2px solid orange;
            border-radius: 4px;
            background-color: white;
        }
 
        .drop-btn {
            background-color: white;
            color: gray;
            font-size: 16px;
            border: none;
            cursor: pointer;
        }
 
        .content {
            display: none;
            position: absolute;
            background-color: white;
        }
 
        .content a {
            color: #7c7c7c;
            padding: 12px 16px;
            display: block;
        }
 
        .dropdown:hover .content {
            display: block;
        }
 
        .input {
            flex-grow: 1;
            border: none;
            padding: 10px;
        }
 
        .btn {
            background-color: orange;
            color: white;
            border: none;
            border-radius: 0 4px 4px 0;
            padding: 10px 20px;
            cursor: pointer;
        }
 
        .input:focus {
            outline: none;
        }
 
        .btn:hover {
            background-color: darkorange;
        }
 
    </style>
</head>
<body>
 
<div class="search">
    <div class="dropdown">
        <button class="drop-btn">宝贝</button>
        <div class="content">
            <a href="#" style="text-decoration:none">图片</a>
            <a href="#" style="text-decoration:none">视频</a>
        </div>
    </div>
    <input type="text" class="input" placeholder="手机壳">
    <button class="btn">搜索</button>
</div>
 
</body>
</html>

效果图:

4:

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>number_4</title>
    <style>
        .fixed {
            position: fixed;
            top: 0;
            left: 0;
            width: 85px;
            background-color: white;
            color: black;
            border-right: 2px solid gray;
            border-radius: 10px;
            text-align: center;
        }
 
        .menu {
            padding: 10px;
            display: block;
        }
 
        .icon {
            width: 40px;
            display: flex;
            position: relative;
            left: 10px;
        }
    </style>
</head>
 
<body>
<div class="fixed">
    <div class="menu"><img src="./img/联系.png" class="icon">联系客服</div>
    <div class="menu"><img src="./img/购物车.png" class="icon">购物车</div>
    <div class="menu"><img src="./img/官方.png" class="icon">官方客服</div>
    <div class="menu"><img src="./img/反馈.png" class="icon">反馈</div>
    <div class="menu"><img src="./img/举报.png" class="icon">举报</div>
    <div class="menu"><img src="./img/回顶部.png" class="icon">回顶部</div>
</div>
</body>
</html>

效果图:

5:

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
    <style>
        .image-slider {
            position: relative;
            width: 300px;
            height: 500px;
            margin: 50px auto;
            border-radius: 10px;
            overflow: hidden;
        }
 
        .image-container img {
            width: 300px;
            height: 500px;
            display: block;
        }
 
        .points {
            position: absolute;
            bottom: 15px;
            left: 40%;
            display: flex;
        }
 
        .point {
            height: 10px;
            width: 10px;
            background: #ddd;
            border-radius: 50%;
            margin: 0 5px;
            cursor: pointer;
        }
 
        .point.active {
            background: orange;
        }
 
    </style>
</head>
<body>
<div class="image-slider">
    <div class="image-container">
        <img src="./img/蝙蝠侠.png" alt="image"/>
    </div>
    <div class="points">
        <span class="point"></span>
        <span class="point active"></span>
        <span class="point"></span>
    </div>
</div>
</body>
</html>

效果图:

6:

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
     .poster {
            width: 450px;
            height: 600px;
            margin: 0 auto;
            background-image: url('./img/2.png');
        }
 
        .header-cell {
            width: 150px;
            background-color: #dc1d1d;
            color: #FFF;
            text-align: center;
            font-size: 20px;
            padding: 10px;
            border: 0px;
            border-radius: 30px;
            position: relative;
            top: -20px;
        }
 
        td {
            width: 200px;
            text-align: center;
        }
 
        .link {
            width: 100px;
            height: 30px;
            display: inline-block;
            padding: 10px 20px;
            background-color: #FFF;
            border: 1px solid #ff7d7d;
            color: #ff4a4a;
            border-radius: 4px;
            text-decoration: none;
        }
 
        .link:hover {
            background: #bdbdbd;
        }
        .content {
        position: relative;
        top: -50px;
    }
 
    .content-left {
        position: relative;
        left: 30px;
    }
 
        .content-right {
            position: relative;
            left: -30px;
        }
</style>
<body>
    <table class="poster">
        <tr>
            <td colspan="2"><button class="header-cell">精选商品</button></td>
        </tr>
        <tr class="content">
            <td class="content-left"><a href="#link1" class="link">热点商品</a></td>
            <td class="content-right"><a href="#link2" class="link">热点商品</a></td>
        </tr>
        <tr>
            <td class="content-left"><a href="#link3" class="link">热点商品</a></td>
            <td class="content-right"><a href="#link4" class="link">热点商品</a></td>
        </tr>
        <tr>
            <td class="content-left"><a href="#link5" class="link">热点商品</a></td>
            <td class="content-right"><a href="#link6" class="link">热点商品</a></td>
        </tr>
    </table>
</body>
</html>

效果图:

7:

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=
    , initial-scale=1.0">
    <title>Document</title>
 <head>
	<style>
		.box-2{
			background-color: aliceblue;
		}
		.box-3{
			background-color: aliceblue;
		}
	</style>
</head>
	<body>
		<table>
			<tr>
                <td>
			    <div class="box-2">
				    <table>
					    <tr>
						    <td>淘工厂.良心工厂货</td>
					    </tr>
					    <tr>
						    <td rowspan="2"><img src="./img/胶带.png"></td>
						    <td>纳米魔力双面胶1卷</td>
						    <td rowspan="2"><img src="./img/风扇.png"></td>
						    <td> 75pvc排气风口防风罩110不...和风行机械..</td>
					    </tr>
					    <tr>
                            <td>¥6.05</td>
					        <td>¥13.5</td>
                        </tr>
				    </table>
			    </div>
			<tr>
				<table class="box-3">
					<tr><td>拍卖捡漏</td></tr>
					<tr>
						<td><img src="./img/手表.png"></td>
					    <td><img src="./img/酒.png"></td>
					</tr>
					<tr>
						<td>¥1起</td>
					    <td>¥200起</td>
					</tr>
				</table>
			</tr>
		</table>
	</body>
</html>

效果图:

相关推荐
90后的晨仔21 分钟前
在macOS上无缝整合:为Claude Code配置魔搭社区免费API完全指南
前端
沿着路走到底1 小时前
JS事件循环
java·前端·javascript
子春一21 小时前
Flutter 2025 可访问性(Accessibility)工程体系:从合规达标到包容设计,打造人人可用的数字产品
前端·javascript·flutter
白兰地空瓶1 小时前
别再只会调 API 了!LangChain.js 才是前端 AI 工程化的真正起点
前端·langchain
jlspcsdn2 小时前
20251222项目练习
前端·javascript·html
行走的陀螺仪3 小时前
Sass 详细指南
前端·css·rust·sass
爱吃土豆的马铃薯ㅤㅤㅤㅤㅤㅤㅤㅤㅤ3 小时前
React 怎么区分导入的是组件还是函数,或者是对象
前端·react.js·前端框架
LYFlied3 小时前
【每日算法】LeetCode 136. 只出现一次的数字
前端·算法·leetcode·面试·职场和发展
子春一23 小时前
Flutter 2025 国际化与本地化工程体系:从多语言支持到文化适配,打造真正全球化的应用
前端·flutter
QT 小鲜肉3 小时前
【Linux命令大全】001.文件管理之file命令(实操篇)
linux·运维·前端·网络·chrome·笔记