1.使用外部web组件,以Bootstrap为例
<head>
<link rel='stylesheet' href='bootstrap-3.3.0-dist/dist/css/bootstrap.css' / > 导入主要的css文件
<link rel='stylesheet' href='bootstrap-3.3.0-dist/dist/css/bootstrap-theme.css' / > 导入主题文件,里面是一些颜色
<style>
.ss{
color:red; !important; 如果对某个样式做些修改,在这里定义自己的样式,并加上!important,表示该样式优先
}
</style>
</head>
<body>
<div >
bootstrap代码{class='ss'#添加的自己的样式
}
</div>
<script src='jQuery-1.12.4.js'></script> 导入jQuery文件,Bootstrap依赖于jQuery
<script src='bootstrap-3.3.0-dist/dist/js/bootstrap.js'></script> 导入js文件
</body>
2.响应式布局,当页面最小宽度小于900px时,背景色变为红色
<style>
@media (min-width:900px) {
.c1{只需要在下边body中class=‘c1即可’
background-color:red;
}
}
</style>
3.web框架原理 http://www.cnblogs.com/wupeiqi/articles/5237672.html
import socket def handle_request(client): buf = client.recv(1024) client.send('HTTP/1.1 200 ok\r\n\r\n') client.send('hello,world') def main(): sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) sock.bind(('localhost',8000)) sock.listen(5) while True: conn, addr = sock.accept() handle_request(conn) conn.close() if __name__ == 'main': main()
Python封装的web服务器
#coding:utf-8 from wsgiref.simple_server import make_server def RunServer(environ, start_response): #envision:客户端发来的所有数据 #start_response:封装要韩会给用户的所有数据,包括响应头、状态码等 start_response('200 OK', [('Content-Type', 'text/html')]) url = environ['PATH_INFO'] #获取客户端发来的数据中的url return ['<h1>Hello, web!</h1>'.encode('utf-8'),] if __name__ == '__main__': httpd = make_server('', 8000, RunServer) print("Serving HTTP on port 8000...") httpd.serve_forever()
MVC
Model View Controller
数据库 模板文件 业务处理
MTV
Model Template View
数据库 模板文件 业务处理
############## WEB:MVC、MTV
3.js正则表达式
test - 判断字符串是否符合规定的正则 rep = /\d+/; rep.test("asdfoiklfasdf89asdfasdf") # true rep = /^\d+$/; rep.test("asdfoiklfasdf89asdfasdf") # true exec - 获取匹配的数据 rep = /\d+/; str = "wangshen_67_houyafa_20" rep.exec(str) # ["67"] JavaScript is more fun than Java or JavaBeans! var pattern = /\bJava(\w*)\b/; # ["JavaScript", "Script"] JavaScript is more fun than Java or JavaBeans! var pattern = /\bJava\w*\b/g; # ["JavaScript"] # ["Java"] # ["JavaBeans"] # null JavaScript is more fun than Java or JavaBeans! var pattern = /\bJava(\w*)\b/g; # ["JavaScript",'Script'] # ["Java", ""] # ["JavaBeans", "Beans"] # null 多行匹配: 默认就是多行匹配 ^$ - 登录注册验证 默认事件先执行: checkbox 自定义先执行 a submit ... <form> <input type='type' /> <input type='password' /> <input type='submit' /> </form> $(':submit').click(function(){ $(':text,:password').each(function(){ ... return false; }) return false; }) input,checbox ================================== 验证 ================================ JS: 验证 各种验证 $(':submit').click(function(){ $(':text,:password').each(function(){ ... return false; }) return false; }) 后端:python实现 业务处理 ....