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

  • 相关阅读:
    机器学习到深度学习资料
    安装CentOS 6停在selinux-policy-targeted卡住的问题解决
    U盘安装Ubuntu 16.04出现:Failed to load ldlinux.c32
    Ubuntu 16.04下使用UNetbootin制作的ISO镜像为U盘启动出现:Missing Operating System (mbr.bin)
    为什么Linux的Fdisk分区时First Sector为2048?
    Windows下将ISO镜像制作成U盘启动的工具(U盘启动工具/UltraISO/Rufus/Universal-USB)
    CentOS 6.9安装类型选择(Basic Server/Web Server)
    Java中String与byte[]的转换
    IntelliJ IDEA插件-翻译插件
    Mycat查询时出现:Error Code: 1064. can't find any valid datanode
  • 原文地址:https://www.cnblogs.com/python-abc/p/11729935.html
Copyright © 2011-2022 走看看