hmzone 发表于 2017-6-22 08:41:41

python【第十四篇】HTML与CSS初遇

概述
  HTML是英文Hyper Text Mark-up Language(超文本标记语言)的缩写,他是一种制作万维网页面标准语言(标记)。相当于定义统一的一套规则,大家都来遵守他,这样就可以让浏览器根据标记语言的规则去解释它。
  浏览器负责将标签翻译成用户“看得懂”的格式,呈现给用户!(例:djangomoan模版引擎)

http://www.googletagservices.com/tag/js/gpt.js

[*]写js代码

  < script type="text/javascript" > ... </script >



常用标签
  标签一般分为两种:块级标签 和 行内标签


[*]a、span、select 等
[*]div、h1、p 等



各种符号
http://www.cnblogs.com/web-d/archive/2010/04/16/1713298.html


p 和 br
  p表示段落,默认段落之间是有间隔的!
  br 是换行



a标签
  < a href="http://www.autohome.com.cn"> </a>
  1、target属性,_black表示在新的页面打开
  2、锚



H 标签

H1

H2

H3

H4

H5

H6



select 标签


上海
北京
广州   
上海
北京
广州
广州   
上海
北京
广州
广州   

石家庄
邯郸

太原
平遥


Checkbox



redio
男 女 保密

男 女 保密


password



button



file
  提交文件时: enctype='multipart/form-data' method='POST'



textarea



label

姓名: 婚否:
姓名: 婚否:


ul ol dl
  ul


[*]ul.li
[*]ul.li
[*]ul.li
  ol


[*]ol.li
[*]ol.li
[*]ol.li
  dl

河北省邯郸石家庄山西省太原平遥


table




1
2
3

1
2
3

1
2
3


1
123


1
2
3

1
2
3

1
2
3

1
3
3

3
3

3
3

3
3
3


fieldset

登录  用户名:
  密码:



form 表单




  文件:enctype='multipart/form-data' method='POST'



作业
要求:
第一个页面:协议,选择【我同意】进入注册页面
第二个页面:用户名、密码、重复密码、省份(下拉菜单)、性别、爱好(多选),使用label来修饰。  对于路径:


[*]/网站根目录
[*]./当前目录(相当于什么也不加)
[*]../父母路
[*]../../ 父目录的父目录




CSS
  css是英文Cascading Style Sheets的缩写,称为层叠样式表,用于对页面进行美化。
  存在方式有三种:元素内联、页面嵌入和外部引入,比较三种方式的优缺点。
  语法:style = 'key1:value1;key2:value2;'


[*]在标签中使用 style='xx:xxx;'
[*]在页面中嵌入 < style type="text/css"> </style > 块
[*]引入外部css文件
  必要性:美工会对页面的色彩搭配和图片的美化负责,开发人员则必须知道是如何实现的。





标签选择器
  div{}
<div > </div>



class选择器
  .bd{ background-color:red; }
<div class='bd'> </div>



id选择器
  #idselect{ background-color:red; }
<div id='idselect' > </div>



关联选择器
  #idselect p{ background-color:red; }
<div id='idselect' > <p> </p> </div>



组合选择器
  input,div,p{ background-color:red; }



属性选择器
  input{ width:100px; height:200px; }





background



[*]background-color






[*]background-image






[*]background-repeat(no-repeat;repeat-x;repeat-y)






[*]background-position






border











margin





padding





display
  display:none


original  display:block
contentcontent  display:inline


content

content


cursor
autohome老衲


[*]css提供的cursor值

  pointer || help || wait || move || crosshair



[*]伪造超链接

  pointer



[*]自定义(一般不用)

  mine



浮动




left

right






left

right




position
http://www.cnblogs.com/canuseethat/archive/2010/09/16/1827804.html


透明度



默认样式改造


[*]首页
[*]菜单1
[*]菜单2


HTML
1、一套规则,浏览器认识的规则。
2、开发者:
学习Html规则
开发后台程序:
- 写Html文件(充当模板的作用) ******
- 数据库获取数据,然后替换到html文件的指定位置(Web框架)
3、本地测试
- 找到文件路径,直接浏览器打开
- pycharm打开测试
4、编写Html文件
- doctype对应关系
- html标签,标签内部可以写属性 ====> 只能有一个
- 注释:<!--注释的内容-->
5、标签分类
- 自闭合标签
<meta charset="UTF-8">
- 主动闭合标签
title>老男孩</title>
6、
head标签中
- <meta-> 编码,跳转,刷新,关键字,描述,IE兼容
<meta http-equiv="X-UA-Compatible" content="IE=IE9;IE=IE8;" />
- title标签
- <link /> 搞图标,欠
- <style />欠
- <script> 欠
7、body标签
- 图标,&nbsp;&gt;   &lt;
- p标签,段落
- br,换行
======== 小总结=====
所有标签分为:
块级标签: div(白板),H系列(加大加粗),p标签(段落和段落之间有间距)
行内标签: span(白板)
标签之间可以嵌套
标签存在的意义,css操作,js操作
ps:chorme审查元素的使用
- 定位
- 查看样式
- h系列
- div
- span
- input系列 + form标签
input type='text'   - name属性,value="赵凡"
input type='password' - name属性,value="赵凡"
input type='submit'   - value='提交' 提交按钮,表单
input type='button'   - value='登录' 按钮
input type='radio'    - 单选框 value,checked="checked",name属性(name相同则互斥)
input type='checkbox' - 复选框 value, checked="checked",name属性(批量获取数据)
input type='file'   - 依赖form表单的一个属性 enctype="multipart/form-data"
input type='reset'   - 重置
<textarea >默认值</textarea>- name属性
select标签            - name,内部option value, 提交到后台,size,multiple
- a标签
- 跳转
- 锚   href='#某个标签的ID'    标签的ID不允许重复
- img
src
alt
title
- 列表
ul
li
ol
li
dl
dt
dd
- 表格
table
thead
tr
th
tbody
tr
td
colspan = ''
rowspan = ''
- label
用于点击文件,使得关联的标签获取光标
<label for="username">用户名:</label>
<input id="username" type="text" name="user" />
- fieldset
legend
- 20个标签
CSS
在标签上设置style属性:
background-color: #2459a2;
height: 48px;
...
编写css样式:
1. 标签的style属性
2. 写在head里面 style标签中写样式
- id选择区
#i1{
background-color: #2459a2;
height: 48px;
}
- class选择器 ******
.名称{
...
}
<标签 class='名称'> </标签>
- 标签选择器
div{
...
}

所有div设置上此样式
- 层级选择器(空格) ******
.c1 .c2 div{
}
- 组合选择器(逗号) ******
#c1,.c2,div{
}
- 属性选择器 ******
对选择到的标签再通过属性再进行一次筛选
.c1{ width:100px; height:200px; }
PS:
- 优先级,标签上style优先,编写顺序,就近原则
2.5 css样式也可以写在单独文件中
<link rel="stylesheet" href="commons.css" />
3、注释
/*   */
4、边框
- 宽度,样式,颜色(border: 4px dotted red;)
- border-left
5、
height,         高度 百分比
width,          宽度 像素,百分比
text-align:center, 水平方向居中
line-height,垂直方向根据标签高度
color   字体颜色
font-size、 字体大小
font-weight 字体加粗
6、float
让标签浪起来,块级标签也可以堆叠
老子管不住:
<div style="clear: both;"></div>
7、display
display: none; -- 让标签消失
display: inline;
display: block;
display: inline-block;
具有inline,默认自己有多少占多少
具有block,可以设置无法设置高度,宽度,paddingmargin
******
行内标签:无法设置高度,宽度,paddingmargin
块级标签:设置高度,宽度,paddingmargin

8、paddingmargin(0,auto)

页: [1]
查看完整版本: python【第十四篇】HTML与CSS初遇