【CSS学习笔记五】列表和表格

一.列表

使用CSS,主要是可以列出进一步的样式,并可用图像作列表项标记。

不同的列表项标记

使用list-style-type属性指定列表项标记的类型

参考值:

  • disc:默认,实心圆
  • circle:空心圆
  • square:实心方块
  • decimal:数字
  • upper-roman:大写罗马数字(I, II, III, IV, V等)
  • lower-roman:小写罗马数字(i, ii, iii, iv, v等)
  • upper-alpha:大写英文字母The marker is upper-alpha (A, B, C, D, E等)
  • lower-alpha:小写英文字母The marker is upper-alpha (a, b, c, d, e等)

图像作为列表项标记

使用list-style-image属性指定列表项标记的图像
语法:

ul
{
    list-style-image: url('图片路径');
}

简写

使用list-style属性
按照

  • list-style-type
  • list-style-position (属性指示如何相对于对象的内容绘制列表项标记,参考值有:inside outside)
  • list-style-image

的顺序填写

实例:

<!DOCTYPE html>
<html>
	<head>
		<style>
			ul.sai{list-style:square url('sai.jpg');}
			ul.circle{list-style:circle;}
			ol.upper-roman{list-style:upper-roman inside;}
			ol.upper-alpha{list-style:upper-alpha outside;}
		</style>
		<meta charset = "utf-8"/>
		<title>列表</title>
	</head>
	<body>
		<ul class = "sai">
			<li>可乐</li>
			<li>雪碧</li>
			<li>芬达</li>
		</ul>
		<ul class = "circle">
			<li>可乐</li>
			<li>雪碧</li>
			<li>芬达</li>
		</ul>
		<ol class = "upper-alpha">
			<li>可乐</li>
			<li>雪碧</li>
			<li>芬达</li>
		</ol>
		<ol class = "upper-roman">
			<li>可乐</li>
			<li>雪碧</li>
			<li>芬达</li>
		</ol>
	</body>
</html>

结果:
在这里插入图片描述

二.表格

1.表格边框

指定CSS表格边框,使用border属性。
宽度和高度也是由width和height设置
border-collapse 属性设置表格的边框是否被折叠成一个单一的边框或隔开

table,th,td
{
	border:5px solid red;
	border-collapse:collapse;
	height:50px;
	width:20%;
}

2.文字对齐

与文本设置一样
text-align属性设置水平对齐方式
同理,
背景background属性设置,
填充padding
字体颜色color

table
{
	color:blue;
	text-align:center;
}
td
{
	padding:15px;
}

实例:

<!DOCTYPE html>
<html>
	<head>
		<style>
			table,th,td
			{
				border:5px solid red;
				border-collapse:collapse;
				background:yellow;
				width:20%;
				height:50px;
				text-align:center;
			}
			th
			{
				color:blue;
			}
			td
			{
				padding:15px;
			}
		</style>
		<meta charset = "utf-8"/>
		<title>表格</title>
	</head>
	<body>
		<table>
			<tr>
				<th>主食</th><th>饮料</th>
			</tr>
			<tr>
				<td>汉堡</td><td>可乐</td>
			</tr>
			<tr>
				<td>薯条</td><td>芬达</td>
			</tr>
		</table>
	</body>
</html>

结果:
在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值