DAY2 2016-01-22

在知乎上看到手写div布局的问题就自己动手做了一些尝试,用了两种方法:1)死做;2)Flexbox

方法一:(死做)

  1 <!DOCTYPE html>
  2 <html>
  3     <head>
  4         <meta charset="UTF-8">
  5         <meta name="viewport" content="width=device-width,initial-scale=1.0">
  6         <title>distributionTest</title>
  7         <style>
  8             *{
  9                 margin:0;
 10                 padding:0;
 11             }
 12             body{
 13                 max-width:100%;
 14             }
 15             div,header{
 16                 border:10px solid #000;
 17             }
 18             .left-main-1,.left-main-2,.right-main{
 19                 border:5px solid #000;
 20             }
 21             .container{
 22                 width:960px;
 23                 margin:0 auto;
 24                 padding-top:20px;
 25                 background-color:#ddd;
 26                 border:0;
 27             }
 28             .clear{
 29                 clear:both;
 30                 width:0;
 31                 height:0;
 32                 border:0;
 33             }
 34             header{
 35                 width:920px;
 36                 height:80px;
 37                 margin:0 10px 20px 10px;
 38             }
 39             .left{
 40                 float:left;
 41             }
 42             .right{
 43                 float:right;
 44             }
 45             .sidebar{
 46                 margin-left:20px;
 47                 border:none;
 48             }
 49             .left-top{
 50                 width:260px;
 51                 height:260px;
 52                 margin-bottom:20px;
 53             }
 54             .left-main{
 55                 width:260px;
 56                 height:700px;
 57             }
 58             .left-main-1{
 59                 margin:15px 0 0 90px;
 60                 width:140px;
 61                 height:70px;
 62             }
 63             .left-main-2{
 64                 margin:20px 0 0 120px;
 65                 width:110px;
 66                 height:70px;
 67             }
 68             .content{
 69                 margin-right:40px;
 70                 border:0;
 71             }
 72             .right-top{
 73                 margin-bottom:20px;
 74                 border:0;
 75             }
 76             .right-top-1{
 77                 width:260px;
 78                 height:260px;
 79                 margin-right:35px;
 80             }
 81             .right-top-2{
 82                 width:260px;
 83                 height:260px;
 84             }
 85             .right-main{
 86                 width:583px;
 87                 height:712px;
 88             }
 89         </style>
 90     </head>
 91     <body>
 92         <div class="container">
 93             <header></header>
 94             <div class="sidebar left">
 95                 <div class="left-top">
 96                 </div>
 97                 <div class="left-main">
 98                     <div class="left-main-1"></div>
 99                     <div class="left-main-2"></div>
100                 </div>
101             </div>
102             <div class="content right">
103                 <div class="right-top">
104                     <div class="right-top-1 left"></div>
105                     <div class="right-top-2 right"></div>
106                     <div class="clear"></div>
107                 </div>
108                 <div class="right-main"></div>
109             </div>
110             <div class="clear"></div>
111         </div>
112     </body>
113 </html>

方法二:(Flexbox)

 1 <!DOCTYPE html>
 2 <html>
 3     <head>
 4         <meta charset="UTF-8">
 5         <meta name="viewport" content="width=device-width,initial-scale=1.0">
 6         <title>distributionTest1</title>
 7         <style>
 8             *{
 9                 margin:0;
10                 padding:0;
11                 box-sizing:border-box;
12             }
13             body{
14                 max-width:100%;
15             }
16             div,header{
17                 border:10px solid #000;
18             }
19             .container,.middle,.bottom{
20                 border:0;
21             }
22             .sidebar-1,.sidebar-2,.content{
23                 border:7px solid #000;
24             }
25             .container{
26                 width:960px;
27                 margin:0 auto;
28                 padding-top:10px;
29                 background-color:#aaa;
30             }
31             header{
32                 width:940px;
33                 height:160px;
34                 margin-left:10px;
35             }
36             .middle{
37                 display:flex;
38                 width:960px;
39                 padding:10px 10px 10px 0;
40                 flex-flow:row wrap;
41                 align-item:stretch;
42                 justify-content:space-around;
43             }
44             .mpart{
45                 width:290px;
46                 height:290px;
47             }
48             .bottom{
49                 display:flex;
50                 width:960px;
51                 padding:10px 10px 10px 0;
52                 flex-flow:row wrap;
53                 align-item:stretch;
54                 justify-content:space-around;
55             }
56             .sidebar{
57                 width:290px;
58                 height:700px;
59             }
60             .sidebar-1{
61                 width:150px;
62                 height:70px;
63                 margin-top:20px;
64                 margin-left:105px;
65             }
66             .sidebar-2{
67                 width:130px;
68                 height:70px;
69                 margin-top:10px;
70                 margin-left:125px;
71             }
72             .content{
73                 width:600px;
74             }
75         </style>
76     </head>
77     <body>
78         <div class="container">
79             <header></header>
80             <div class="middle">
81                 <div class="mpart"></div>
82                 <div class="mpart"></div>
83                 <div class="mpart"></div>
84             </div>
85             <div class="bottom">
86                 <div class="sidebar">
87                     <div class="sidebar-1"></div>
88                     <div class="sidebar-2"></div>
89                 </div>
90                 <div class="content"></div>
91             </div>
92         </div>
93     </body>
94 </html>

可以明显看出,第二种方法简单了很多。Flexbox也是布局很好的一个工具,今天第一次接触就感受到了其简便性,很好用。

再者,今天还尝试了用jquery做回到顶部的效果,代码如下:

 1 <!DOCTYPE html>
 2 <html lang="zh-CN">
 3     <head>
 4         <meta charset="UTF-8">
 5         <meta name="viewport" content="width=device-width,initial-scale=1.0">
 6         <title>jQuery-BackTop</title>
 7         <script src="js/jquery-2.1.4.min.js"></script>
 8         <style>
 9             *{
10                 margin:0;
11                 padding:0;
12             }
13             body{
14                 max-width:100%;
15                 height:1200px;;
16             }
17             header{
18                 width:100%;
19                 height:200px;
20                 background-color: #ded122;
21             }
22             .content{
23                 width:100%;
24                 height:800px;
25                 background-color: #11ddee;
26             }
27             footer{
28                 width:100%;
29                 height:200px;
30                 background-color #1122dd;
31             }
32             #back-to-top{
33                 display:none;
34                 position:fixed;
35                 right:50px;
36                 bottom:50px;
37                 width:30px;
38                 height:30px;
39                 background-color:#000;
40             }
41             a{
42                 padding:15px 15px;
43                 cursor:pointer;
44             }
45         </style>
46     </head>
47     <body>
48         <header></header>
49         <div class="content"></div>
50         <footer></footer>
51         <div id="back-to-top"><a href="#top"></a></div>
52         <script>
53         $(function(){
54             $(function(){
55                 $(window).scroll(function(){
56                     if($(window).scrollTop() > 100){
57                         $("#back-to-top").fadeIn(1000);
58                     }
59                     else{
60                         $("#back-to-top").fadeOut(800);
61                     }
62                 });
63
64                 $("#back-to-top").click(function(){
65                     $(‘body,html‘).animate({scrollTop:0},1000);
66                     return false;//stop defualt function
67                 });
68             });
69         });//must focus on () and {}
70         </script>
71     </body>
72 </html>
时间: 2024-12-17 19:38:06

DAY2 2016-01-22的相关文章

[官方软件] Easy Sysprep v4.3.29.602 【系统封装部署利器】(2016.01.22)--skyfree大神

[官方软件] Easy Sysprep v4.3.29.602 [系统封装部署利器](2016.01.22) Skyfree 发表于 2016-1-22 13:55:55 https://www.itsk.com/forum.php?mod=viewthread&tid=362766&highlight=Easy%2BSysprep [官方软件] Easy Sysprep v4.3.29.602 [系统封装部署利器](2016.01.22) [Easy Sysprep]概述:Easy Sy

2016.01.22 简单动画

简单动画没什么好说的,直接看代码.=-= //横向.纵向移动 [UIView animateWithDuration:0.5 animations:^{ self.aView.frame = CGRectMake(_aView.frame.origin.x, _aView.frame.origin.y + 50, _aView.frame.size.width, _aView.frame.size.height); }]; //渐变效果 [UIView animateWithDuration:0

2016.01.22 单例模式(Singleton)

单例模式:整个程序的一个类只能有一个实例对象:(UIApplication.NSUserDefaults等都是IOS中的系统单例) 1.物理设备 eg:打印机 2.不可多个同时存在的资源 eg:数据库 单例的写法: 这是第一种,也是最简单.最常用的一种: 1 #import "FileOpration.h" 2 3 static FileOpration *instance = nil; //静态变量,从定义开始到整个程序结束 4 5 @implementation FileOprat

[2016.01.22]万峰文本处理专家 v2.1

<万峰文本处理专家>是一款简单易用,且功能强大的各类文本文件处理软件.1.支持多任务的处理模式,允许一次处理多个任务.2.支持正则表达式替换,替换更加强大:3.支持各类关键字的行处理操作:4.支持各类起始关键字和结束关键字的行的处理操作:5.多线程任务管理,速度快,性能稳定.6.文本替换专家作者十年磨一剑之力作. 淘宝购买地址:http://item.taobao.com/item.htm?spm=0.0.0.0.0W6h2V&id=520620878928

个人快捷键配置备忘-2016.01.22

1 Visual Studio 2010 头文件和源文件切换:  Alt+F1 在VA助手中查看 注释: Ctrl+K,Ctrl+C  (先按下Ctrl,然后依次按K,C) 取消注释: Ctrl+K,Ctrl+U 快速跳转定义: F1 向前导航: Alt+1  向后导航: Alt+2 删除行: Shift+Delete 2 Eclipse

2016.01.18-2016.01.21盲审通关修改

请以上同学在1月21日(星期四)之前将以下材料交到研究生科: 1.装订好的硕士学位论文3本(注意:封面上作者姓名和指导教师隐去.致谢隐去.硕士学位期间发表的全部的论文作者隐去): 2.普通信封上写明评阅费:200元.邮寄费:22元,并将相应的钱款分别装入以上三个信封(普通信封,一共:200*3+22*3元): 3.从研究生管理信息系统中导出的“论文评阅书”封面上的作者姓名和指导教师姓名隐去:交三份“论文评阅书”和三份“学位论文评阅聘书”. 4.交三份“EMS”信封和一个装有20×3=60元邮寄费

“耐撕”团队 2016.3.22 站立会议

时间:2016.03.22 ① :18:00--18:25   ②18:40--19:00   总计45分钟. 成员: Z 郑蕊 * 组长 (博客:http://www.cnblogs.com/zhengrui0452/), P 濮成林(博客:http://www.cnblogs.com/charliePU/), Q 齐嘉亮(博客:http://www.cnblogs.com/dendroaspis-polylepis/), L  刘伟硕(博客:http://www.cnblogs.com/We

2016.01工作日志

2016.01.01 元旦在家,八点醒,开始继续阅读「30日でできる!OS自作入門」.主要目的,加深对os和cpu的理解.另外花些时间又重温王爽的<汇编语言>.今天,最大收获还是感官上体会系统底层:比如往内存xxxx里写入0或者1就可以实现操作系统对xxxx部件的控制.另外,看到了「30日でできる!OS自作入門」中自制操作系统的内存图,就可以知道,内存这种东西,就是操作系统,或者cpu规划的.内存本身是不分段的.内存的哪一段是ram哪一段是bios显卡,改变其地址值就可以实现特定效果. 对于这

MIT JOS学习笔记01(2016.10.22)

一.环境配置 关于MIT课程中使用的JOS的配置教程网上已经有很多了,在这里就不做介绍,个人使用的是Ubuntu 16.04 + qemu.另注,本文章中贴出的代码均是JOS中未经修改的源代码,其中有一些细节是MIT课程中要求学生自己实现的. 二.代码分析 1.boot.S(AT&T汇编格式) / boot.asm 1 #include <inc/mmu.h> 2 3 # Start the CPU: switch to 32-bit protected mode, jump into

2016/01/14开始学习git:标签管理:创建标签

标签也是版本库的一个快照指向某个commit的指针(分支可以移动,标签不能移动) 切换到需要打标签的分支上git tag <name>就可以打一个新标签: $ git tag v1.0 git tag查看所有标签: $ git tagv1.0 打之前提交的版本的commit需要当时的commit ID$ git tag v0.9 93ddf60 查看tag$ git tagv0.9v1.0 标签不是按时间顺序列出,而是按字母排序的.可以用git show <tagname>查看标签