<meta charset="UTF-8">
<head>
<meta charset="UTF-8">
<title>我的联通title>
head>
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>我的联通title>
head>
<body>
<h1>1级标题h1>
<h2>2级标题h2>
<h3>3级标题h3>
<h4>4级标题h4>
<h5>5级标题h5>
<h6>6级标题h6>
body>
html>
<div>内容div>
<span>asdfaspan>
div,一个人占一整行。【块级标签】
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>我的联通title>
head>
<body>
<div>山东蓝翔div>
<div>挖掘机哪家强div>
body>
html>
span,自己多大占多少。【行内标签、内联标签】
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>我的联通title>
head>
<body>
<span>山东蓝翔span>
<span>挖掘机哪家强span>
body>
html>
注意:这两个标签比较素 + CSS样式。
跳转到其他网站
<a href="http://www.chinaunicom.com.cn/about/about.html">点击跳转a>
跳转到自己网站其他的地址
<a href="http://127.0.0.1:5000/get/news">点击跳转a>
<a href="/get/news">点击跳转a>
# 当前页面打开
<a href="/get/news">点击跳转a>
# 新的Tab页面打开
<a href="/get/news" target="_blank">点击跳转a>
<img src="图片地址" />
直接显示别人的图片地址(防盗链):
<img src="https://pic4.zhimg.com/v2-b23f984c2aeaa7bed12e890b4338d499_720w.jpg" />
<img src="自己图片的地址" />
显示自己的图片:
- 自己项目中创建:static目录,图片要放在static
- 在页面上引入图片
<img src="/static/wbq.png" />
关于设置图片的高度和宽度
<img src="图片地址" style="height:100px; width:200px;" />
<img src="图片地址" style="height:10%; width:20%;" />
学习的标签
<h1>h1>
<div>div>
<span>span>
<a>a>
<img />
划分
- 块级标签
- 行内标签
嵌套
<div>
<span>xxxspan>
<img />
<a>a>
div>
案例:商品列表
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Titletitle>
head>
<body>
<h1>商品列表h1>
<a href="https://www.mi.com/redmiwatch2" target="_blank">
<img src="/static/a1.jpeg" style="width: 150px">
a>
<a href="https://www.mi.com/shouhuan6/nfc" target="_blank">
<img src="/static/a2.jpeg" style="width: 150px">
a>
<a href="https://www.mi.com/xiaomibuds3pro" target="_blank">
<img src="/static/a3.jpeg" style="width: 150px">
a>
body>
html>
<ul>
<li>中国移动li>
<li>中国联通li>
<li>中国电信li>
ul>
<ol>
<li>中国移动li>
<li>中国联通li>
<li>中国电信li>
ol>
<table>
<thead>
<tr> <th>IDth> <th>姓名th> <th>年龄th> tr>
thead>
<tbody>
<tr> <td>10td> <td>武沛齐td> <td>19td> tr>
<tr> <td>11td> <td>吴阳军td> <td>19td> tr>
<tr> <td>12td> <td>刘东td> <td>19td> tr>
<tr> <td>13td> <td>郭智td> <td>19td> tr>
<tr> <td>14td> <td>电摩td> <td>19td> tr>
tbody>
table>
<input type="text" />
<input type="password">
<input type="file">
<input type="radio" name="n1">男
<input type="radio" name="n1">女
<input type="checkbox">篮球
<input type="checkbox">足球
<input type="checkbox">乒乓球
<input type="checkbox">棒球
<input type="button" value="提交"> -->普通的按钮
<input type="submit" value="提交"> -->提交表单
<select>
<option>北京option>
<option>上海option>
<option>深圳option>
select>
<select multiple>
<option>北京option>
<option>上海option>
<option>深圳option>
select>
<textarea>textarea>
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Titletitle>
head>
<body>
<h1>用户注册h1>
<div>
用户名:<input type="text"/>
div>
<div>
密码:<input type="password"/>
div>
<div>
性别:
<input type="radio">男
<input type="radio">女
div>
<div>
爱好:
<input type="checkbox">篮球
<input type="checkbox">足球
<input type="checkbox">乒乓球
div>
<div>
城市:
<select>
<option>北京option>
<option>上海option>
<option>深圳option>
select>
div>
<div>
擅长领域:
<select multiple>
<option>打游戏option>
<option>睡觉option>
<option>吃饭option>
<option>刷抖音option>
select>
div>
<div>
备注:<textarea>textarea>
div>
<div>
<input type="button" value="button按钮">
<input type="submit" value="submit按钮">
div>
body>
html>
新创建项目
创建Flask代码
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/register', methods=['GET', "POST"])
def register():
if request.method == "GET":
return render_template('register.html')
else:
user = request.form.get("user")
pwd = request.form.get("pwd")
gender = request.form.get("gender")
hobby_list = request.form.getlist("hobby")
city = request.form.get("city")
skill_list = request.form.getlist("skill")
more = request.form.get("more")
print(user, pwd, gender, hobby_list, city, skill_list, more)
# 将用户信息写入文件中实现注册、写入到excel中实现注册、写入数据库中实现注册
# 2.给用户再返回结果
return "注册成功"
if __name__ == '__main__':
app.run()
HTML代码
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Titletitle>
head>
<body>
<h1>用户注册h1>
<form method="post" action="/register">
<div>
用户名:<input type="text" name="user"/>
div>
<div>
密码:<input type="password" name="pwd"/>
div>
<div>
性别:
<input type="radio" name="gender" value="1">男
<input type="radio" name="gender" value="2">女
div>
<div>
爱好:
<input type="checkbox" name="hobby" value="10">篮球
<input type="checkbox" name="hobby" value="20">足球
<input type="checkbox" name="hobby" value="30">乒乓球
<input type="checkbox" name="hobby" value="40">棒球
div>
<div>
城市:
<select name="city">
<option value="bj">北京option>
<option value="sh">上海option>
<option value="sz">深圳option>
select>
div>
<div>
擅长领域:
<select name="skill" multiple>
<option value="100">吃饭option>
<option value="101">睡觉option>
<option value="102">打球option>
select>
div>
<div>
备注:<textarea name="more">textarea>
div>
<input type="submit" value="submit按钮">
form>
body>
html>
见代码示例。
页面上的数据,想要提交到后台:
method="get"
action="/xxx/xxx/xx"
css,专门用来“美化”标签。
<img src="..." style="height:100px" />
<div style="color:red;">中国联通div>
<img src="..." style="height:100px" />
<div style="color:red;">中国联通div>
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Titletitle>
<style>
.c1{
color:red;
}
style>
head>
<body>
<h1 class='c1'>用户登录h1>
<h1 class='c1'>用户登录h1>
<h1 class='c1'>用户登录h1>
<h1 class='c1'>用户登录h1>
body>
html>
.c1{
height:100px;
}
.c2{
color:red;
}
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Titletitle>
<link rel="stylesheet" href="common.css" />
head>
<body>
<h1 class='c1'>用户登录h1>
<h1 class='c2'>用户登录h1>
<h1 class='c2'>用户登录h1>
<h1 class='c1'>用户登录h1>
body>
html>
ID选择器
#c1{
}
'c1'>
类选择器(最多)
.c1{
}
'c1'>
标签选择器
div{
}
xxx
属性选择器
input[type='text']{
border: 1px solid red;
}
.v1[xx="456"]{
color: gold;
}
<input type="text">
<input type="password">
<div class="v1" xx="123">sdiv>
<div class="v1" xx="456">fdiv>
<div class="v1" xx="999">adiv>
后代选择器
.yy li{
color: pink;
}
.yy > a{
color: dodgerblue;
}
<div class="yy">
<a>百度a>
<div>
<a>谷歌a>
div>
<ul>
<li>美国li>
<li>日本li>
<li>韩国li>
ul>
div>
关于选择器:
多:类选择器、标签选择器、后代选择器
少:属性选择器、ID选择器
.c1{
height: 300px;
width: 500px;
}
注意事项:
display:inline-block
示例:行内&块级特性
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Titletitle>
<style>
.c1{
display: inline-block;
height: 100px;
width: 300px;
border: 1px solid red;
}
style>
head>
<body>
<span class="c1">中国span>
<span class="c1">联通span>
<span class="c1">联通span>
<span class="c1">联通span>
body>
html>
示例:块级和行内标签的设置
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Titletitle>
<style>
style>
head>
<body>
<div style="display: inline;">中国div>
<span style="display: block;">联通span>
body>
html>
注意:块级 + 块级&行内。
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Titletitle>
<style>
.c1{
color: #00FF7F;
font-size: 58px;
font-weight: 600;
font-family: Microsoft Yahei;
}
style>
head>
<body>
<div class="c1">中国联通div>
<div>中国移动div>
body>
html>
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Titletitle>
<style>
.c1{
height: 59px;
width: 300px;
border: 1px solid red;
text-align: center; /* 水平方向居中 */
line-height: 59px; /* 垂直方向居中 */
}
style>
head>
<body>
<div class="c1">郭智div>
body>
html>
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Titletitle>
head>
<body>
<div>
<span>左边span>
<span style="float: right">右边span>
div>
body>
html>
内边距,我自己的内部设置一点距离。
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Titletitle>
<style>
.outer{
border: 1px solid red;
height: 200px;
width: 200px;
padding-top: 20px;
padding-left: 20px;
padding-right: 20px;
padding-bottom: 20px;
}
style>
head>
<body>
<div class="outer">
<div style="background-color: gold;">听妈妈的话div>
<div>
小朋友你是否下水道发
div>
div>
body>
html>
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Titletitle>
<style>
.outer{
border: 1px solid red;
height: 200px;
width: 200px;
padding: 20px;
}
style>
head>
<body>
<div class="outer">
<div style="background-color: gold;">听妈妈的话div>
<div>
小朋友你是否下水道发
div>
div>
body>
html>
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Titletitle>
<style>
.outer{
border: 1px solid red;
height: 200px;
width: 200px;
padding: 20px 10px 5px 20px;
}
style>
head>
<body>
<div class="outer">
<div style="background-color: gold;">听妈妈的话div>
<div>
小朋友你是否下水道发
div>
div>
body>
html>
外边距,我与别人加点距离。
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Titletitle>
head>
<body>
<div style="height: 200px;background-color: dodgerblue;">div>
<div style="background-color: red;height: 100px;margin-top: 20px;">div>
body>
html>