########################总结###############

块级标签能够嵌套某些块级标签和内敛标签

内敛标签不能块级标签,只能嵌套内敛标签

嵌套就是:

  1. <div>
  2. <span>
  3. ffff
  4. </span>
  5. </div>

  6. ####p标签比较特殊,不能包含块级标签,p标签也不能包含p标签
  1. <p>
  2. <div>xxxxxxxxxxx</div>
  3. </p>

字体

  1. .c2{
  2. font-family: '华文楷体';
  3. font-size: 100px;#默认大小是16
  4. Font-weight:bold;#自重 bold加粗
  5. Color:red;rgb(255,255,255) rgba(255,255,255,0.3) 0.3是色彩透明度
  6. }
  7.  
  8. <span class="c2">
  9. 小泽玛利亚
  10. </span>

文字对齐方式  文字装饰

  1. .c3{
  2. text-align: left; #center,right,left
  3. line-height: 50px; #行高
  4. }
  5.  
  6. <!--字体对齐-->
  7. <div class="c3">
  8. 从前车马很慢,书信很远,一生只够爱一人
  9. </div>

.c4 a{
text-decoration: line-through; #使用中划线

/*text-decoration: none;*/ #去掉a标签默认的下划线
}

<!--文字装饰-->
<div class="c4">
<a href="">德玛西亚</a>

</div>

首行缩进

  1. text-indent:32px;缩进两个字符

背景属性

  1. .c1{
  2. width: 900px;
  3. height: 900px;
  4. /*background-color: green;*/ #背景颜色
  5. /*background-image: url("gdg.png");*/#图片路径
  6. /*background-repeat: no-repeat;*/#不进行多图拉伸
  7. /*background-position: center top;*/ #把图片给居中
  8.  
  9. background:green url("gdg.png") no-repeat 500px 200px; #写一起效果 第一个200是左边 第二个是往下
  10.  
  11. background-attachment: fixed; #下拉的时候不会替换
  12.  
  13. border: 1px solid red; #边框
  14. }

边框

  1. .c1{
  2. /* 200*200是正方形 */
  3. width: 200px;
  4. height: 200px;
  5. border-left: 10px dashed green;#虚线左半圈绿色
  6. border-right: 10px dashed red;#右半圈绿色
  7. border-bottom: 10px dashed yellow;#下黄色
  8. border-top: 10px solid purple; #实线 紫色
  9. border-radius: 50%; #50%拉
  10. <div class="c1">
  11. <img src="xyjy.png" alt="">
  12. </div>

.c1 img{
/*按照父级标签的宽度来展示,并且进行等比缩放*/
max-width: 100%;
}

/*溢出的部分隐藏*/
overflow: hidden;

<div class="c1">
<img src="xyjy.png" alt="">
</div>

  1. .c1{
  2. width: 200px;
  3. height: 100px;
  4. border: 1px solid black;
  5.  
  6. }
  7.  
  8. .c2{
  9. background-color: red;
  10. /*display: none;*/ #隐藏标签
  11. /*visibility: hidden;*/#隐藏标签,但是保留标签所占位置
  12. }
  13.  
  14. .c3{
  15. background-color: blue;
  16. }
  17. .c3,.c4{ #挨着c3
  18. display: inline-block; #将块级标签或者内敛标签,改成块级标签和内敛标签的
  19. }
  20.  
  21. 还有2个不常用
  22. Display:block;将内敛标签改为块级标签
  23. Display:inline;将块级标签改为内敛标签
  24.  
  25. ####################
  26. <div class="c1">
  27.  
  28. </div>
  29. <div class="c1 c2">
  30.  
  31. </div>
  32. <div class="c1 c3"> #注意这里的class c1的样式也有c3的样式 类似继承
  33. 我是c3标签
  34. </div>
  35. <div class="c1 c4">
  36. 我是c4标签
  37. </div>

盒子模型

1(盒子型的属性)

width:内容的宽度

height:内容的宽度

margin:外边距,盒子边框到附近最近盒子的距离

border:边距,就是指定的盒子的宽度

padding:内边距,边框到内容的距离

content:内容

  1. ###常用
  2. body{
  3. margin: 0;
  4. padding: 0;
  5. }
  6. #####演示效果########
  7. <!DOCTYPE html>
  8. <html lang="en">
  9. <head>
  10. <meta charset="UTF-8">
  11. <title>哈哈哈哈</title>
  12. <style>
  13. .box{
  14. width: 200px;
  15. height: 200px;
  16. padding: 50px;
  17. /* padding 分上 右 下 左 10px 20px 30px 50px*/
  18. background-color: red;
  19. border: 1px solid yellow;
  20. margin: 30px;
  21. }
  22. </style>
  23. </head>
  24. <body>
  25. <div class="box">哈哈哈哈哈哈我是曹宝宝</div>
  26. </body>
  27. </html>

#############总结##########

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. <style>
  7. body{
  8. margin: 0;
  9. /*外边距*/
  10. padding: 0;
  11. /*内边距*/
  12. }
  13. .c1,.c2{
  14. width: 100px;
  15. height: 100px;
  16. background-color: red;
  17. border: 1px solid black;
  18. }
  19.  
  20. .c3{
  21. width: 100%;
  22. height: 100px;
  23. background-color: yellow;
  24. }
  25.  
  26. .c2{
  27. float: right;
  28. /*把c2放右边*/
  29. }
  30. .c1{
  31. float: left;
  32. }
  33. /*c3默认会盖过c1 c2 设置伪类选择器,设立给他加空白 设置成block 让他占位子 清除浮动*/
  34. .cc:after{
  35. content: '';
  36. display: block;
  37. clear: both;
  38. }
  39. .cc:before{
  40. /*清除浮动的标识 可不写*/
  41. }
  42. </style>
  43.  
  44. </head>
  45. <body>
  46.  
  47. <div class="cc">
  48. <div class="c1"></div>
  49. <div class="c2"></div>
  50.  
  51. </div>
  52. <div class="c3" >
  53. </div>
  54.  
  55. </body>
  56. </html>
    #############################如果不加浮动c3黄色会上去 变成一行#############################################

定位

relative(相对定位)

absolute(绝对定位)

  1. #div1{
  2. position: absolute;
  3. width: 200px;
  4. height: 200px;
  5. background-color: blueviolet;
  6. margin-left: 100px;
  7. }
    这个位置两个div都能占

fixed(固定)不管页面怎么动,都在整个屏幕的某个位置

相对路径

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6. <style>
  7. body {
  8. border: 1px solid green;
  9. }
  10.  
  11. div {
  12. width: 200px;
  13. height: 200px;
  14. background-color: red;
  15. /*margin-top: 50px;*/
  16. /*如果想让红色方块下移50px,我们首先想到的是使用margin-top 50px*/
  17. /*打开代码注释的部分,刷新页面。会发现,body被撑开了。这不是我们想要的,这个时候,需要用到相对定位。*/
  18. /*它不会撑开body*/
  19.  
  20. /*相对定位,相对自己原来的位置,跟父级没有任何关系*/
  21. position: relative;
  22. /*移动50px*/
  23. top: 50px;
  24. }
  25. </style>
  26. </head>
  27. <body>
  28. <div class="wrap">
  29.  
  30. </div>
  31.  
  32. </body>
  33. </html>

老家留坑

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6. <style>
  7. .box1{
  8. width: 100px;
  9. height: 100px;
  10. background-color: red;
  11. }
  12. .box2{
  13. width: 100px;
  14. height: 100px;
  15. background-color: green;
  16. /*老家留坑*/
  17. position: relative;
  18. left: 100px;
  19. }
  20. .box3{
  21. width: 100px;
  22. height: 100px;
  23. background-color: yellow;
  24. }
  25. </style>
  26. </head>
  27. <body>
  28. <div class="box1">
  29. </div>
  30. <div class="box2">
  31. </div>
  32. <div class="box3">
  33. </div>
  34. </body>
  35. </html>

相对路径:让搜索框和提交按钮在一条水平线显示

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6. <style>
  7. .where{
  8. font-size: 30px;
  9. }
  10. .search{
  11. width: 100px;
  12. height: 40px;
  13. position: relative;
  14. top: -4px;
  15. }
  16. </style>
  17. </head>
  18. <body>
  19.  
  20. <div>
  21. <form action="" method="post">
  22. <input type="text" class="where">
  23. <input type="submit" class="search" value="搜索">
  24. </form>
  25. </div>
  26.  
  27. </body>
  28. </html>

绝对路径 制作导航栏 不会随着鼠标的拉取而变化

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title></title>
  6. <style>
  7. *{
  8. padding: 0;
  9. margin: 0;
  10. }
  11. ul{
  12. list-style: none;
  13. }
  14. .nav{
  15. width: 960px;
  16. overflow: hidden;
  17. /*margin: 0px auto;*/
  18. background-color: purple;
  19. border-radius: 5px;
  20. position: fixed;
  21. left: 50%;
  22. margin-left: -480px;
  23. }
  24. .nav ul li{
  25. float: left;
  26. width: 160px;
  27. height: 40px;
  28. line-height: 40px;
  29. text-align: center;
  30.  
  31. }
  32. .nav ul li a{
  33. width: 160px;
  34. height: 40px;
  35. display: block;
  36. color: white;
  37. font-size: 14px;
  38. text-decoration: none;
  39.  
  40. }
  41. .nav ul li a:hover{
  42. background: yellow;
  43. color: green;
  44. text-decoration: underline;
  45. }
  46.  
  47. .wrap{
  48. width: 100%;
  49. height: 400px;
  50. background-color: #666;
  51. }
  52.  
  53. </style>
  54. </head>
  55. <body style="height: 3000px">
  56. <div class="nav">
  57. <ul>
  58. <li>
  59. <a href="#">网站导航</a>
  60. </li>
  61. <li>
  62. <a href="#">网站导航</a>
  63. </li>
  64. <li>
  65. <a href="#">网站导航</a>
  66. </li>
  67. <li>
  68. <a href="#">网站导航</a>
  69. </li>
  70. <li>
  71. <a href="#">网站导航</a>
  72. </li>
  73. <li>
  74. <a href="#">网站导航</a>
  75. </li>
  76. </ul>
  77. </div>
  78.  
  79. <div class="wrap"></div>
  80.  
  81. </body>
  82. </html>

z-index

  • z-index 值表示谁压着谁,数值大的压盖住数值小的,
  • 只有定位了的元素,才能有z-index,也就是说,不管相对定位,绝对定位,固定定位,都可以使用z-index,而浮动元素不能使用z-index
  • z-index值没有单位,就是一个正整数,默认的z-index值为0如果大家都没有z-index值,或者z-index值一样,那么谁写在HTML后面,谁在上面压着别人,定位了元素,永远压住没有定位的元素。
  • 从父现象:父亲怂了,儿子再牛逼也没用

只要又定位的盒子,一定大于标准流的盒子

从父现象

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6. <style>
  7. .lzy{
  8. width: 300px;
  9. height: 300px;
  10. background-color: black;
  11. position: absolute;
  12. z-index: 14;
  13. }
  14. .tl{
  15. width: 300px;
  16. height: 300px;
  17. background-color: yellow;
  18. position: absolute;
  19. z-index: 11;
  20.  
  21. }
  22. .kimi{
  23. width: 100px;
  24. height: 100px;
  25. background-color: green;
  26. position: absolute;
  27. top: 400px;
  28. left: 400px;
  29. }
  30. .sd{
  31. width: 100px;
  32. height: 100px;
  33. background-color: pink;
  34. position: absolute;
  35. top: 450px;
  36. left: 350px;
  37. z-index: 1000;
  38. /*优先级最高不是最前面*/
  39. }
  40. </style>
  41. </head>
  42. <body>
  43. <div class="lzy">
  44. <div class="kimi"></div>
  45. </div>
  46. <div class="tl">
  47. <div class="sd"></div>
  48. </div>
  49. </body>
  50. </html>

python css盒子型 浮动的更多相关文章

  1. CSS盒子的浮动

    web前端学习笔记(CSS盒子的浮动) 在标准流中,一个块级元素在水平方向会自动伸展,直到包含它的元素的边界:而在竖直方向和兄弟元素依次排列,不能并排.使用“浮动”方式后,块级元素的表现就会有所不同. ...

  2. web前端学习笔记(CSS盒子的浮动)

    在标准流中,一个块级元素在水平方向会自动伸展,直到包含它的元素的边界:而在竖直方向和兄弟元素依次排列,不能并排.使用“浮动”方式后,块级元素的表现就会有所不同.      CSS中有一个float属性 ...

  3. 前端开发—CSS 盒子、浮动、定位

    盒子模型 margin padding border content margin:            用于控制元素与元素之间的距离:body自带 8 像素的margin 需要手动去除.(快递盒之 ...

  4. css盒子布局,浮动布局以及显影与简单的动画

    08.05自我总结 一.盒子布局 1.盒子布局的组成 margin border padding content 2.margin margin是外边距,控制盒子的显示位置相对于他的上一级 left. ...

  5. 前端之CSS——盒子模型和浮动

    一.CSS盒子模型 HTML文档中的每个元素都被描绘成矩形盒子,这些矩形盒子通过一个模型来描述其占用空间,这个模型称为盒子模型. 盒子模型通过四个边界来描述:margin(外边距),border(边框 ...

  6. CSS系列:CSS中盒子的浮动与定位

    1. 盒子的浮动 在标准流中,一个块级元素在水平方向会自动伸展,知道包含它的元素的边接:而在竖直方向与相邻元素依次排列,不能并排. CSS中float属性,默认为none.将float属性的值设置为l ...

  7. html/css 盒子布局 Margin 、Padding 、border 以及 清除浮动的知识 (学习HTML过程中的小记录)

    html/css  盒子布局 Margin .Padding .border 以及 清除浮动的知识 (学习HTML过程中的小记录) 作者:王可利(Star·星星) width     是"宽 ...

  8. css盒子模型、文档流、相对与绝对定位、浮动与清除模型

    一.CSS中的盒子模型 标准模式和混杂模式(IE).在标准模式下浏览器按照规范呈现页面:在混杂模式下,页面以一种比较宽松的向后兼容的方式显示.混杂模式通常模拟老式浏览器的行为以防止老站点无法工作. h ...

  9. CSS 设计彻底研究(四)盒子的浮动与定位

    第四章 盒子的浮动与定位 本章的重点和难点是深刻地理解”浮动“和”定位“这两个重要的性质,对于复杂页面的排版至关重要. 4.1 盒子的浮动 在标准流中,一个块级元素在水平方向会自动伸张,直到包含它的元 ...

随机推荐

  1. P1508 Likecloud-吃、吃、吃

    数字金字塔3条路 f[i][j]=max(max(f[i-1][j],f[i-1][j-1]),f[i-1][j+1])+a[i][j]; #include<bits/stdc++.h> ...

  2. 安卓Android基础第五天

    使用HttpUrlConnection方式提交到服务器2 Get方式:组拼url地址把数据组拼到url上,有大小限制1kb(浏览器)或4kb(http协议) Post方式:post方式提交安全,没有大 ...

  3. ram自己写?用IP?

    前言 ram这种东西,可以用ip方便,也可以自己写代码描述它. 以下讨论单口ram:8bit*256 流程 1.IP: 使用IP当然是最方便的事情啦,但可移植性差而且可定制性较差. 仿真波形: 2.V ...

  4. try-with-resource机制的一个编译陷阱

    为了解决问题,偶然发现一个奇怪的地方:就是使用try-with-resource机制的代码编译后,使用jd-gui反编译文件出现// ERROR //,但是程序运行却是正常的. 进一步确认后发现:如果 ...

  5. tp5 日志管理

    日志驱动 日志可以通过驱动支持不同的方式写入,默认日志会记录到文件中,系统已经内置的写入驱动包括 File.Socket,如果要临时关闭日志写入,可以设置日志类型为Test即可,例如: 'log' = ...

  6. 【php】php实现数组反转

    php里面有个函数可以反转数组,工作中也经常用到,非常方便.今天来自己实现这样的功能. $arr = [2,5,6,1,8,16,12]; function reverse($arr){ $left ...

  7. Wannafly挑战赛29-A御坂美琴 (dfs+map)

    链接:https://ac.nowcoder.com/acm/contest/271/A来源:牛客网 御坂美琴 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 131072K,其他语言 ...

  8. Arch Linux中安装Anaconda

    安装步骤 通过AUR安装yaourt -S anaconda 激活Anaconda环境source /opt/anaconda/bin/activate root 关闭Anaconda环境source ...

  9. luoguP4707 重返现世

    收集邮票加强版,每个邮票不是等概率获得的了. 而且是获得K个,如果把一个全集S集合找出其获得时间集合(显然获得时间两两不同)的话,那么就是第n-k+1大的期望! %%%Sooke min-max容斥扩 ...

  10. agc031

    T1 题意:给你一个串,求所有子序列个数,满足没有相同字符.1e5,2s. 解:考虑一个合法的子序列.其中每个字母的出现位置都有(出现次数)种选择.还可以不选,要 + 1. 然后乘起来就做完了.如果变 ...