zoukankan      html  css  js  c++  java
  • 14-2

    块级标签: 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

  • 相关阅读:
    收藏:详解交换机基础知识
    Linux Used内存到底哪里去了?
    TCP三次握手和四次挥手以及11种状态
    操作系统深度研究(75页PPT)
    命令行版的斗地主你玩过没?
    10大黑客专用的 Linux 操作系统
    (四)Linux命令大全:帮助命令
    (三)Linux命令大全:文件搜索命令
    (二)Linux命令大全:权限管理命令
    (一)Linux命令大全:文件处理命令
  • 原文地址:https://www.cnblogs.com/python-abc/p/11729935.html
Copyright © 2011-2022 走看看