四个现实中的商品样例,帮助你理解如何使用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>
 
 
相关推荐
wordbaby5 分钟前
一行看懂高阶函数:用 handleConfirm 拿下 DatePicker 回调
前端·react.js
卿·静11 分钟前
Node.js对接即梦AI实现“千军万马”视频
前端·javascript·人工智能·后端·node.js
Mintopia25 分钟前
🚀 Next.js 全栈 Web Vitals 监测与 Lighthouse 分析
前端·javascript·全栈
Mintopia27 分钟前
🤖 AIGC + CMS:内容管理系统智能化的核心技术支撑
前端·javascript·aigc
HelloGitHub30 分钟前
这款开源调研系统越来越“懂事”了
前端·开源·github
whysqwhw33 分钟前
hippy的主要原理
前端
子兮曰36 分钟前
🚀95%的前端开发者都踩过坑:JavaScript循环全解析,从基础到高阶异步迭代
前端·javascript·性能优化
2401_8534068836 分钟前
Tdesign-React 组件 Card 实现头部固定,内容区单独可滚动
前端·react.js·tdesign
蓝倾97639 分钟前
小红书获取用户作品列表API接口操作指南
java·服务器·前端·python·电商开放平台·开放api接口
小桥风满袖39 分钟前
极简三分钟ES6 - 数值的扩展
前端·javascript