四个现实中的商品样例,帮助你理解如何使用css【前端CSS入门样例】

实现商品列表
html 复制代码
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>商品列表图片</title>
		<style>
			.row > img {
				width: 15%;
			}
		</style>
	</head>
	<body>
		<div class="row">
			<img src="image/00001.jpg" alt="">
			<img src="image/00002.jpg" alt="">
			<img src="image/00003.jpg" alt="">
			<img src="image/00004.jpg" alt="">
			<img src="image/00005.jpg" alt="">
			<img src="image/00006.jpg" alt="">
		</div>
		<div class="row">
			<img src="image/00007.jpg" alt="">
			<img src="image/00008.jpg" alt="">
			<img src="image/00009.jpg" alt="">
			<img src="image/00010.jpg" alt="">
			<img src="image/00011.jpg" alt="">
			<img src="image/00012.jpg" alt="">
		</div>
	</body>
</html>
 
 
实现排行榜效果
html 复制代码
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>排行榜</title>
		<style>
			#rank-list td {
				font-size: 1.1em;
				padding-top: 3px;
				padding-bottom: 3px;
			}
			
			a {
				text-decoration: none;
				color: blue;
			}
			
			.num > span{
				color: darkgray;
			}
			
			.boil {
				background-color: red;
				color: white;
				border-radius: 5px;
				font-size: 0.85em;
				padding: 1px 2px 1px 2px;
			}
			
			.hot {
				background-color: coral;
				color: white;
				border-radius: 5px;
				font-size: 0.85em;
				padding: 1px 2px 1px 2px;
			}
			
			.new {
				background-color: orange;
				color: white;
				border-radius: 5px;
				font-size: 0.85em;
				padding: 1px 2px 1px 2px;
			}
			
			
			
		</style>
	</head>
	<body>
		<div class="container">
			<table id="rank-list">
				<tr>
					<td><span><img src="image/top-one.png" alt="" width="20px"></span></td>
					<td><a href="#">中国空间站第三棒全力开跑</a></td>
				</tr>
				<tr>
					<td class="num"><span style="color: red;">1</span></td>
					<td><a href="#">#2022高考作文来了# <span class="boil">沸</span></a></td>
				</tr>
				<tr>
					<td class="num"><span style="color: coral;">2</span></td>
					<td><a href="#">深圳回应"50辆宾利堵车位"纠纷 <span class="hot">热</span></a></td>
				</tr>
				<tr>
					<td class="num"><span style="color: orange;">3</span></td>
					<td><a href="#">回头看高考青春永不老 <span class="hot">热</span></a></td>
				</tr>
				<tr>
					<td class="num"><span>4</span></td>
					<td><a href="#">不出意外今年高考又出现了这些意外</a></td>
				</tr>
				<tr>
					<td class="num"><span>5</span></td>
					<td><a href="#">考生忘带准考证家长又送错考场  <span class="new">新</span></a></td>
				</tr>
				<tr>
					<td class="num"><span>6</span></td>
					<td><a href="#">苹果用3分钟正式宣战新行业</a></td>
				</tr>
				<tr>
					<td class="num"><span>7</span></td>
					<td><a href="#">5名考生"组团"跑错考点交警转送  <span class="new">新</span></a></td>
				</tr>
				<tr>
					<td class="num"><span>8</span></td>
					<td><a href="#">俄罗斯卢布如何做到"惊天逆转"  <span class="new">新</span></a></td>
				</tr>
				<tr>
					<td class="num"><span>9</span></td>
					<td><a href="#">美国最大水库因干涸发现多具藏尸</td>
				</tr>
				<tr>
					<td class="num"><span>10</span></td>
					<td><a href="#">60秒看各地家长花式送考</td>
				</tr>

			</table>
		</div>
	</body>
</html>
实现棋盘效果
html 复制代码
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>作业2591实现棋盘效果</title>
		<style>
			.container {
				width: 600px;
				height: 600px;				
				border: 5px solid black;
				margin: auto;
				display: flex;
			}
			
			.black {
				background-color: black;
				width: 200px;
				height: 200px;
			}
			.white {
				background-color: white;
				width: 200px;
				height: 200px;
			}
		</style>
	</head>
	<body>
		<div class="container">
			<div>
				<div class="black"></div>
				<div class="white"></div>
				<div class="black"></div>
			</div>
			<div>
				<div class="white"></div>
				<div class="black"></div>
				<div class="white"></div>
			</div>
			<div>
				<div class="black"></div>
				<div class="white"></div>
				<div class="black"></div>
			</div>
		</div>
	</body>
</html>
电话按键
html 复制代码
    <table width="400px" border="1px" cellspacing=0>
        <tr class="one">
            <td>1</td>
            <td>2</td>
            <td>3</td>
        </tr>
        <tr class="two">
            <td>4</td>
            <td>5</td>
            <td>6</td>
        </tr>
        <tr class="three">
            <td>7</td>
            <td>8</td>
            <td>9</td>
        </tr>
    </table>


    <style>
        table, td {
            text-align: center;
        }


        .one {
            color:red;
            text-decoration: underline;
        }


        .two {
            color: green;
            text-decoration: line-through;
        }


        .three {
            color: blue;
            font-weight: 900;
        }
      </style>
 
 
相关推荐
范文杰11 分钟前
AI 时代如何更高效开发前端组件?21st.dev 给了一种答案
前端·ai编程
拉不动的猪19 分钟前
刷刷题50(常见的js数据通信与渲染问题)
前端·javascript·面试
拉不动的猪27 分钟前
JS多线程Webworks中的几种实战场景演示
前端·javascript·面试
FreeCultureBoy1 小时前
macOS 命令行 原生挂载 webdav 方法
前端
uhakadotcom2 小时前
Astro 框架:快速构建内容驱动型网站的利器
前端·javascript·面试
uhakadotcom2 小时前
了解Nest.js和Next.js:如何选择合适的框架
前端·javascript·面试
uhakadotcom2 小时前
React与Next.js:基础知识及应用场景
前端·面试·github
uhakadotcom2 小时前
Remix 框架:性能与易用性的完美结合
前端·javascript·面试
uhakadotcom2 小时前
Node.js 包管理器:npm vs pnpm
前端·javascript·面试
LaoZhangAI3 小时前
2025最全GPT-4o图像生成API指南:官方接口配置+15个实用提示词【保姆级教程】
前端