块级标签: div(白板)
标签之间可以嵌套
为什么要有标签?
标签存在的意义: 定位操作, css操作, js操作
chrome审查元素的使用
- 定位
- 查看样式
用id定位
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<p id="p1">hello world</p>
<div id="i1">qwert</div>
</body>
</html>
打开页面->Inspect->Console,
document.getElementById('i1').innerText
"qwert"
document.getElementById('i1').innerText="asdfg"
"asdfg"
定义位置: 右上角
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<p id="p1">hello world</p>
<div id="i1" style="position: fixed;top: 0;right: 0;">qwert</div>
</body>
</html>
定义位置: 右下角
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<p id="p1">hello world</p>
<div id="i1" style="position: fixed;bottom: 0;right: 0;">qwert</div>
</body>
</html>
提交表单
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form action="http://localhost:8888/index">
<input type="text" />
<input type="password" />
<input type="button" value="登录1" />
<input type="submit" value="登录2" />
</form>
</body>
</html>
#pip3 install tornado
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
print(111)
self.write('GET')
def post(self, *args, **kwargs):
print(123)
self.write('POST')
application = tornado.web.Application([
(r'/index', MainHandler),
])
if __name__ == "__main__":
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
浏览器打开http://localhost:8888/index会返回get方法
浏览器post到http://localhost:8888/index会返回post方法
浏览器打开html页面,输入内容,点击登录2,数据就提交给http://localhost:8888/index
获取表单内容
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form action="http://localhost:8080/index">
<input type="text" name="user" />
<input type="text" name="email" />
<input type="password" name="pwd" />
<input type="button" value="登录1" />
<input type="submit" value="登录2" />
</form>
</body>
</html>
用户输入会打包成字典提交到后台
{'user':'输入的用户', 'email':'xx', 'pwd':'xx'}
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
print(111)
u = self.get_argument('user')
e = self.get_argument('email')
p = self.get_argument('pwd')
if u == 'alex' and e == 'alex@126.com' and p == '123':
self.write("OK")
else:
self.write("滚")
def post(self, *args, **kwargs):
print(123)
self.write('POST')
application = tornado.web.Application([
(r'/index', MainHandler),
])
if __name__ == "__main__":
application.listen(8080)
tornado.ioloop.IOLoop.instance().start()
POST方法提交表单数据
GET, POST
GET提交在URL里
POST提交在body里, URL里看不到
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form action="http://localhost:8080/index" method="POST">
<input type="text" name="user" />
<input type="text" name="email" />
<input type="password" name="pwd" />
<input type="button" value="登录1" />
<input type="submit" value="登录2" />
</form>
</body>
</html>
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
print(111)
u = self.get_argument('user')
e = self.get_argument('email')
p = self.get_argument('pwd')
if u == 'alex' and e == 'alex@126.com' and p == '123':
self.write("OK")
else:
self.write("滚")
def post(self, *args, **kwargs):
u = self.get_argument('user')
e = self.get_argument('email')
p = self.get_argument('pwd')
print(u, e, p)
self.write('POST')
application = tornado.web.Application([
(r'/index', MainHandler),
])
if __name__ == "__main__":
application.listen(8080)
tornado.ioloop.IOLoop.instance().start()
浏览器打开html页面,输入内容,点击登录2,数据就提交给http://localhost:8080/index