iframe标签:<iframe>。iframe标签是框架的一种形式,iframe一般用来包含别的页面。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>内联框架标签</title> </head> <body> <!-- 内联框架:在当前页面中,加载另一个页面 --> <h2>内联框架演示</h2> <ul> <li><a href="https://baidu.com" target="main">百度</a></li> <li><a href="https://sina.com.cn" target="main">新浪</a></li> <li><a href="https://taobao.com" target="main">淘宝</a></li> </ul> <p> <iframe frameborder="1" width="500" height="500" name="main"> </body> </html>
点击 "运行实例" 按钮查看在线实例

css样式设置的优先级
元素属性 (内联样式)<p style="color:red"></p>
元素标签(内部样式)<style>p {color:red;}></style>
外部资源<link ref stylesheet href="style.css">
ID选择器 对应页面中唯一的元素 用 # 来表示,比如
<style> #red{ color:red;}</style>
class 类选择器 对应页面中的多个元素 用 .来表示 比如
<style>.red{ color:red;}</style>
标签选择器 针对页面中的标签
<style> p{ color:red;}</style>
ID>CLASS>标签 (优先级别)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="style" href="../9.2/static/css/style1.css">
<style>
p {
color: aqua;
}
</style>
<title>css</title>
</head>
<body>
<ol>
<li>
<p style="color: red">
内联样式,我优先级最高
</p>
</li>
<li>
<p>内部样式,我的优先级比较高</p>
</li>
<li>
<p>外部样式表,我的优先级最低</p>
</li>
</ol>
</body>
</html>点击 "运行实例" 按钮查看在线实例
盒模型
盒模型是布局的基础,页面上的一切可见元素皆可看做盒子
盒子模型可以设置6个样式:宽高背景内外边距与边框
(1):width:宽度(水平方向)
(2):height:高度(垂直方向)
(3):background-color:背景(默认透明)
(4):padding:内边距,内容与边框之间的填充区域
(5):margin:外边距,决定当前盒子与其它盒子之间的位置与关系
(6):border:边框,位于内外边距之间,是可见元素,允许设置宽度,样式和颜色
根据是可见性可以分为二类:
(1).可见的:width,height,border
(2).透明的:background,padding,margin
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<style>
.box1 {
width: 500px;
height: 500px;
background-color: rgb(46, 179, 212);
margin: 50px;
}
.box2 {
width: 100px;
height: 100px;
background-color: lightcoral;
/* padding 四个方向边距不同的写法 */
padding-top: 50px;
padding-right: 100px;
padding-bottom: 100px;
padding-left: 50px;
/* 边框写法 */
border: 5px dashed green;
}
</style>
<title>盒子模型</title>
</head>
<body>
<div class="box1">
<div class="box2"></div>
</div>
</div>
</body>
</html>点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号