批改状态:合格
老师批语:各种样式表, 要结合着用
样式表:
<div style="background-color:red;color:green;">(2)使用html的一个标签实现 <style>标签,写在head里面
<style type="text/css">css代码;</style><style type="text/css">div {background-color:blue;color: red;}</style>
(3)在style标签里面 使用语句(在某些浏览器下不起作用)
(4)使用头标签 link,引入外部css文件
<link rel="stylesheet" type="text/css" href="css文件的路径" />style="display:type控制它的显示类型,即生成什么样的”元素框”display属性常用值| 序号 | 属性值 | 描述 |
|---|---|---|
| 1 | inline默认 |
行内元素,<span>, <a> |
| 2 | block |
块级元素,<div>,<p> |
| 3 | inline-block |
行内块级元素,<img> |
| 4 | list-item |
块级: 列表元素,<li> |
| 5 | table |
块级: 表格元素,<table> |
| 6 | flex |
弹性元素 |
| 7 | grid |
网格元素 |
<link media="screen,print">
<style media="screen,print">
@import url(...) screen,print;
@media screen,print {...}
媒体类型是不同媒体的标识符
| 序号 | 类型 | 描述 |
|---|---|---|
| 1 | all |
所有媒体类型,即不限制 |
| 2 | print |
打印机,预打印预览使用 |
| 3 | screen |
屏幕,如浏览器等用户代理 |
| 4 | projection |
幻灯片 |
多种媒体类型之间使用逗号分隔:
@media screen, print
min-width: 500pxprint and (color)and 和 notand表示多个”媒体描述符”必须同时满足, not则是整个查询取反,且必须写在and前面常用 “媒体描述符”(显示区域相关)
| 序号 | 媒体描述符 | 描述 |
|---|---|---|
| 1 | width |
显示区域宽度 |
| 2 | min-width |
显示区域最小宽度 |
| 3 | max-width |
显示区域最大宽度 |
| 4 | device-width |
设备显示区域宽度 |
| 5 | min-device-width |
设备显示区域最小宽度 |
| 6 | max-device-width |
设备显示区域最大宽度 |
| 7 | height |
显示区域高度 |
| 8 | min-height |
显示区域最小高度 |
| 9 | max-height |
显示区域最大高度 |
| 10 | device-height |
设备显示区域高度 |
| 11 | min-device-height |
设备显示区域最小高度 |
| 12 | max-device-height |
设备显示区域最大高度 |
h1 {height: 50px;background-color: #eee;display: flex;align-items: center;}ul {list-style: none;border: 1px solid #ccc;background-color: #efefef;padding: 15px 30px 15px;display: flex;}ul>li {color: #666;text-decoration: none;padding: 0 15px;display: inline;}ul>li>a {color: green;text-decoration: none;padding: 0 15px;}/* 局部媒体查询,当屏幕宽度大500px,才显示标题,并更改列表布局 */@media screen and (max-width: 500px) {h1 {display: none;}ul {list-style: none;background-color: #efefef;display: block;padding: 50px, 80px, 50px;}ul>li {color: #666;text-decoration: none;padding: 50px 50px;}ul>li>a {color: red;}}


Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号