Django学习_day2

若settings中的'DIRS'未定义默认优先在注册的app目录下的templates寻找html文件,若定义为[os.path.join(BASE_DIR,'templates')](需要提前配置)则默认在根目录下寻找
静态文件
开发过程中称图片、css、js..为静态文件,放在static文件夹内并进行分类
遇见的问题:
-
图片无法显示
在settings最后加入
STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static').replace('\\', '/'), ) -
报TemplateDoesNotExist错误
产生原因:移动图片时错将html文件移动...
在html文件中使用{% load static %}
使用案例

虽然在编译器没有高亮(而且会报错),但是运行出来是没有问题的
BootStrap
使用
-
下载BootStrap
网址:Bootstrap · The most popular HTML, CSS, and JS library in the world. (getbootstrap.com)
-
引入BootStrap
<head> <link rel="stylesheet" type="text/css" href="style.css"> </head> -
应用案例
Navbar · Bootstrap v5 中文文档 v5.3 | Bootstrap 中文网 (bootcss.com)
可以在中进行微调,例如:
<style> .btn{ width: 80px; } </style>调整了该html文件中按钮的宽度
-
导航栏navbar
-
栅格系统columns
-
响应式
.col-lg- 1170px .sol-md- 970px .col-sm- 780px -
非响应式
<div class="col-xs-6" style="background-color: red">1<div> <div class="col-xs-6" style="background-color: blue">1<div>
-
-
- 容器container
- 面板panel
- 媒体对象mediaa
浙公网安备 33010602011771号