为什么用CSS

• CSS 指层叠样式表 (Cascading Style Sheets);
• 样式定义如何显示 HTML 元素;
• 样式通常存储在样式表中;
• 外部样式表可以极大提高工作效率;
提高效率
• 外部样式表通常存储在 CSS 文件中;

CSS 规则由两个主要的部分构成:选择器,以及一条或多条声明。

CSS语法规则

• 值的不同写法和单位;(eg:设置颜色)
• 如果值为若干单词,则要给值加引号;
• 多重声明,需要用分号将每个声明分开

CSS样式优先级

• 浏览器缺省设置
• 外部样式表
• 内部样式表(位于 标签内部)
• 内联样式(在 HTML 元素内部)

选择器范例

• h1 { … } 标签选择器
• h1 i { … } 标签选择器
• #my { … } id选择器(唯一)
• #my p { … } id选择器
• .my { … } 类选择器(可不唯一)
• p .my { … } 类选择器
• .my p { … } 类选择器
• [title] { … } 属性选择器
• [title=westos] { … } 属性选择器
• [title~=hello] { … } • input[type=“text”] { … }

css背景

• 背景色:
background
• 背景图像: background-image
• 背景重复: background-repeat
• 背景定位: background-position
• 背景关联: background-attachment

main.css

h1{color: red;font-size: 24px;
}
<!DOCTYPE html>
<html lang="en">
<head><!--** 设置样式表的三种分类:1). 行内氧样式表;2). 内部样式表;3). 外部样式表;--><meta charset="UTF-8"><title>Title</title><!--内部样式表--><!--<style>--><!--h1{--><!--color: red;--><!--font-size: 24px;--><!--}--><!--</style>--><!--<!-外部样式表&ndash;&gt;--><link  rel="stylesheet"  href="css/main.css">
</head>
<body><!--内联样式表-->
<!--<h1 style="color: red; font-size: 24px">CSS样式</h1>-->
<h1 style="color: green">CSS样式表</h1></body>
</html>

案例——水平导航栏加css样式

nav.css

ul {list-style-type: none;text-align: center
}
ul li {display: inline-block;width: 20%;height: 30px;background: green;padding-top: 15px;font-size: 18px;/*text-decoration: none;*/
}ul li a {text-decoration: none;color: white;
}
/*鼠标经过时产生的变化*/
li:hover {background: #4CAF50;font-size: 20px;
}
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Title</title><link rel="stylesheet" type="text/css" href="css/nav.css">
</head>
<body><!--
行内元素: 占多少用多少
块级元素: 一个标签占一整行
-->
<ul><li><a href="http://www.baidu.com">博客</a></li><li><a href="#">学院</a></li><li><a href="#">技术</a></li><li><a href="#">编程</a></li>
</ul></body>
</html>

登录界面

main01.css

body {margin: 0; /*去掉默认的外边距*/padding: 0; /*去掉默认的内边距*/
}.content {background-color: pink;margin-top: 200px;height: 400px;}.main {/*border: 1px solid red;*/width: 600px;height: 400px;margin: 0 auto; /*块级标签居中的方式*/padding-top: 30px;text-align: center;}.main h1 {font-size: 60px;color: white;
}input[type='text'], input[type='password'] {width: 400px;height: 46px;border-radius: 25px;border: 0;margin-top: 15px;text-align: center;}
input[type='submit'] {background: #f31239;border-radius: 25px;margin-top: 15px;width: 200px;height: 46px;border: 0;color: white;}input:hover {background: deeppink;
}
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Title</title><link rel="stylesheet" href="css/main01.css"></head>
<body><div class="content"><div class="main"><h1>Welcome</h1><form action="#"><input type="text" placeholder="请输入帐号"><br/><input type="password" placeholder="请输入密码"><br/><input type="submit" value="登&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;陆"></form></div>
</div></body>
</html>

模拟唯品会注册界面

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Title</title><style>body {padding: 0;margin: 0;}/*div {*//*border: 1px solid red;*//*}*/.header {width: 1920px;height: 100px;margin: 0 auto;}.logo{background: url("img/logo.png");width: 174px;height: 79px;float: left;margin-left: 200px;margin-top: 10px;}.service{margin-top: 20px;background: url("img/service.png");width: 321px;height: 55px;float: right;margin-right: 200px;}.content {width: 1920px;height: 600px;background: url("https://img.vipstatic.com/upload/flow/2018/06/15/157/15290438491111.jpg");background-repeat: no-repeat; /*图片不能让嗯填充满的时候, 不重复显示*/margin: 0 auto;}.main {width: 360px;height: 450px;float: right; /*将div标签向右对齐*/margin-right: 150px;margin-top: 50px;padding: 20px 20px 30px 20px; /*内边距: 上右下左*/background: white;text-align: center;}#registerText {font-size: 20px;font-weight: bold;}#loginText {float: right; /*div向右偏移*/display: inline; /*块级元素变为行内元素*/}.main input {margin-top: 20px;height: 40px;width: 300px;border: 1px solid darkgray;border-radius: 10px;text-align: left;padding-left: 20px;}.main .code {width: 140px;}.main input[type='checkbox'] {width: 2px;height: 2px;}.main input[type='submit'] {background: #f10180;color: white;border: 1px solid #f10180;text-align: center;}.main a {text-decoration: none;color: #1d94d1;font-size: 13px;}.main #loginText a{color: #f10180;font-size: 15px;}.footer {width: 1920px;height: 100px;text-align: center;padding-top: 50px;margin: 0 auto;}</style></head>
<body>
<!--导航栏部分(logo/图标)-->
<div class="header"><div class="logo"></div><div class="service"></div></div>
<!--页面主体-->
<div class="content"><!--注册表单界面--><div class="main"><span id="registerText">会员注册</span><div id="loginText">已注册可<a href="#">直接登录</a></div><hr/><input type="text" placeholder="请输入电话号码"><br/><input type="text" class="code" placeholder="请输入验证码"> &nbsp;&nbsp;<input type="button" class="code" value="获取验证码"><br/><input type="password" placeholder="请输入密码"><br/><input type="password" placeholder="请重新输入密码"><br/><input type="checkbox">我已阅读并接受以下条款:<a href="#">《唯品会服务条款》 </a><a href="#">《隐私条款》 </a><a href="#">《唯品支付用户服务协议》 </a><a href="#">《唯品信用服务协议》 </a><br/><input type="submit" value="立即注册"><br/></div></div><!--脚标-底部设置(商标/备案信息)-->
<div class="footer">Copyright 2008-2018 vip.com,All Rights Reserved ICP证:粤 B2-20080329</div></body>
</html>

模拟唯品会登录界面

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Title</title><style>body {padding: 0;margin: 0;}/*div {*//*border: 1px solid red;*//*}*/.header {width: 100%;height: 100px;}.logo {background: url("img/logo.png");width: 174px;height: 79px;float: left;margin-left: 200px;margin-top: 10px;}.service {margin-top: 20px;background: url("img/service.png");width: 321px;height: 55px;float: right;margin-right: 200px;}.content {width: 100%;height: 600px;background: url("https://img.vipstatic.com/upload/flow/2018/06/15/157/15290438491111.jpg");background-repeat: no-repeat; /*图片不能让嗯填充满的时候, 不重复显示*/}.main {width: 360px;height: 300px;float: right; /*将div标签向右对齐*/margin-right: 150px;margin-top: 100px;padding: 20px 20px 30px 20px; /*内边距: 上右下左*/background: white;text-align: center;}#registerText {font-size: 20px;font-weight: bold;}#loginText {float: right; /*div向右偏移*/display: inline; /*块级元素变为行内元素*/}.main input {margin-top: 20px;height: 40px;width: 300px;border: 1px solid darkgray;border-radius: 10px;text-align: left;padding-left: 20px;}.main .code {width: 140px;}.main input[type='checkbox'] {width: 2px;height: 2px;}.main input[type='submit'] {background: #f10180;color: white;border: 1px solid #f10180;margin-top: 30px;text-align: center;}.main a {text-decoration: none;color: #1d94d1;font-size: 13px;}.main #loginText a {color: #f10180;font-size: 15px;}.footer {width: 100%;height: 100px;text-align: center;padding-top: 50px;}</style></head>
<body>
<!--导航栏部分(logo/图标)-->
<div class="header"><div class="logo"></div><div class="service"></div></div>
<!--页面主体-->
<div class="content"><!--注册表单界面--><div class="main"><span id="registerText">会员登录</span><div id="loginText"><a href="#">直接注册</a></div><hr/><input type="text" placeholder="请输入电话号码"><br/><input type="password" placeholder="请输入密码"><br/><input type="submit" value="立即登录"><br/></div></div><!--脚标-底部设置(商标/备案信息)-->
<div class="footer">Copyright 2008-2018 vip.com,All Rights Reserved ICP证:粤 B2-20080329</div></body>
</html>

分页的设计

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Title</title><style>div {margin: 0 auto;width: 50%;height: 100px;/*border: 1px solid red;*/text-align: center;margin-top: 300px;}ul.pagination li {list-style-type: none;display: inline;}ul.pagination li a {text-decoration: none;color: black;padding: 8px 10px; /*10px左右内边距, 8px上下内边距*/border: 1px solid darkgray;border-radius: 20px;}ul.pagination li a.active {background: green;color: white;}/*如果类名不为active并且鼠标经过才显示的样式*/ul.pagination li a:hover:not(.active) {background: darkseagreen;border: 1px solid green;font-size: 19px;}</style></head>
<body><div><ul class="pagination"><li><a href="#">上一页</a></li><li><a href="#">1</a></li><li><a class="active" href="#">2</a></li><li><a href="#">3</a></li><li>....</li><li><a href="#">20</a></li><li><a href="#">21</a></li><li><a href="#">下一页</a></li></ul></div></body>
</html>

python学习笔记(CSS)相关推荐

  1. python学习笔记目录

    人生苦短,我学python学习笔记目录: week1 python入门week2 python基础week3 python进阶week4 python模块week5 python高阶week6 数据结 ...

  2. Python学习笔记:Day11 编写日志创建页

    前言 最近在学习深度学习,已经跑出了几个模型,但Pyhton的基础不够扎实,因此,开始补习Python了,大家都推荐廖雪峰的课程,因此,开始了学习,但光学有没有用,还要和大家讨论一下,因此,写下这些帖 ...

  3. Python学习笔记:web开发3

    前言 最近在学习深度学习,已经跑出了几个模型,但Pyhton的基础不够扎实,因此,开始补习Python了,大家都推荐廖雪峰的课程,因此,开始了学习,但光学有没有用,还要和大家讨论一下,因此,写下这些帖 ...

  4. Python学习笔记:web开发2

    前言 最近在学习深度学习,已经跑出了几个模型,但Pyhton的基础不够扎实,因此,开始补习Python了,大家都推荐廖雪峰的课程,因此,开始了学习,但光学有没有用,还要和大家讨论一下,因此,写下这些帖 ...

  5. Python学习笔记:web开发1

    前言 最近在学习深度学习,已经跑出了几个模型,但Pyhton的基础不够扎实,因此,开始补习Python了,大家都推荐廖雪峰的课程,因此,开始了学习,但光学有没有用,还要和大家讨论一下,因此,写下这些帖 ...

  6. python学习笔记_week14

    python学习笔记_week14 Web框架本质 众所周知,对于所有的Web应用,本质上其实就是一个socket服务端,用户的浏览器其实就是一个socket客户端. s1 1 import sock ...

  7. python学习笔记_week22

    python学习笔记_week22 note 知识点概要- Session- CSRF- Model操作- Form验证(ModelForm)- 中间件- 缓存- 信号 内容详细: 1. Sessio ...

  8. [python教程入门学习]python学习笔记(CMD执行文件并传入参数)

    本文章向大家介绍python学习笔记(CMD执行文件并传入参数),主要包括python学习笔记(CMD执行文件并传入参数)使用实例.应用技巧.基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋 ...

  9. python学习笔记之编写readConfig读写配置文件

    python学习笔记之编写readConfig读写配置文件_weixin_34055910的博客-CSDN博客

最新文章

  1. 2.使用windows下的client连接虚拟机上的oracle连不上的时候的解决方式
  2. tomcat 启动项目 页面文字乱码_eclipse启动tomcat项目乱码而终端启动tomcat正常的解决办法...
  3. rabbitmq常用的五种模型
  4. 用Excel VBA连接SQL Server数据库并将表中的数据显示到Excel中
  5. 【UI/UX】深度解析模态窗口
  6. 【洛谷1341】无序字母对(欧拉回路)
  7. 免費玩雲端運算,Amazon Web Service 雲端運算平台攻略 【1】
  8. uci数据集_有关葡萄酒质量的数据分析
  9. IOS MenuController的部分操作
  10. html游戏脚本,网页游戏脚本软件道
  11. java学校信息管理系统 论文设计与实现
  12. 【2020年】CRISPR基因编辑技术最新进展盘点解读
  13. 单元测试报告软件测试,软件单元测试报告-模板
  14. 可以获得高排名的B2B平台大全
  15. 沈阳工业大学计算机专业排名,中国的大学计算机专业排名。
  16. Ubuntu使用小教程02——服务器上安装ubuntu桌面版(新手向)
  17. 为每天节省两小时-华芸AS4004T万兆NAS搭建测试
  18. uni app 零基础小白到项目实战-1
  19. 编写程序描述影视歌三栖艺人
  20. msvcr100.dll丢失的解决方法

热门文章

  1. 使用Matplotlib绘制3D图形
  2. ORACLE数据库日期更新到时分秒格式
  3. 我的2007-高开低走,无甚成就
  4. 清华大学交叉信息研究院弋力老师课题组招收科研实习生
  5. android studio 编译Telegram源码
  6. Unity中TextMeshPro显示中文
  7. Eclipse中怎样将java项目转化为web项目?
  8. PCB图纸太小元件放不下怎么办
  9. 九年级计算机课程教案,九年级信息技术 5.2.3《计算机网络》教案
  10. 2019全国大众点评数据更新