前端及开发文章及欣赏

H5之外部浏览器唤起微信分享

seo达人

最近在做一个手机站,要求点击分享可以直接打开微信分享出去。而不是jiathis,share分享这种的点击出来二维码。在网上看了很多,都说APP能唤起微信,手机网页实现不了。也找了很多都不能直接唤起微信。

总结出来一个可以直接唤起微信的。适应手机qq浏览器和uc浏览器。

下面上代码,把这些直接放到要转发的页面里就可以了:

html部分:


  1. <script src="mshare.js"></script>//引进mshare.js
  2. <button data-mshare="0">点击弹出原生分享面板</button>
  3. <button data-mshare="1">点击触发朋友圈分享</button>
  4. <button data-mshare="2">点击触发发送给微信朋友</button>

js部分:


  1. <script>
  2. var mshare = new mShare({
  3. title: 'Lorem ipsum dolor sit.',
  4. url: 'http://m.ly.com',
  5. desc: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quaerat inventore minima voluptates.',
  6. img: 'http://placehold.it/150x150'
  7. });
  8. $('button').click(function () {
  9. // 1 ==> 朋友圈 2 ==> 朋友 0 ==> 直接弹出原生
  10. mshare.init(+$(this).data('mshare'));
  11. });
  12. </script>

下面是mshare.js的代码分享,把这些代码新建一个js文件放进去,然后在页面中引进就ok了。


  1. /**
  2. * 此插件主要作用是在UC和QQ两个主流浏览器
  3. * 上面触发微信分享到朋友圈或发送给朋友的功能
  4. */
  5. 'use strict';
  6. var UA = navigator.appVersion;
  7. /**
  8. * 是否是 UC 浏览器
  9. */
  10. var uc = UA.split('UCBrowser/').length > 1 ? 1 : 0;
  11. /**
  12. * 判断 qq 浏览器
  13. * 然而qq浏览器分高低版本
  14. * 2 代表高版本
  15. * 1 代表低版本
  16. */
  17. var qq = UA.split('MQQBrowser/').length > 1 ? 2 : 0;
  18. /**
  19. * 是否是微信
  20. */
  21. var wx = /micromessenger/i.test(UA);
  22. /**
  23. * 浏览器版本
  24. */
  25. var qqVs = qq ? parseFloat(UA.split('MQQBrowser/')[1]) : 0;
  26. var ucVs = uc ? parseFloat(UA.split('UCBrowser/')[1]) : 0;
  27. /**
  28. * 获取操作系统信息 iPhone(1) Android(2)
  29. */
  30. var os = (function () {
  31. var ua = navigator.userAgent;
  32. if (/iphone|ipod/i.test(ua)) {
  33. return 1;
  34. } else if (/android/i.test(ua)) {
  35. return 2;
  36. } else {
  37. return 0;
  38. }
  39. }());
  40. /**
  41. * qq浏览器下面 是否加载好了相应的api文件
  42. */
  43. var qqBridgeLoaded = false;
  44. // 进一步细化版本和平台判断
  45. if ((qq && qqVs < 5.4 && os == 1) || (qq && qqVs < 5.3 && os == 1)) {
  46. qq = 0;
  47. } else {
  48. if (qq && qqVs < 5.4 && os == 2) {
  49. qq = 1;
  50. } else {
  51. if (uc && ((ucVs < 10.2 && os == 1) || (ucVs < 9.7 && os == 2))) {
  52. uc = 0;
  53. }
  54. }
  55. }
  56. /**
  57. * qq浏览器下面 根据不同版本 加载对应的bridge
  58. * @method loadqqApi
  59. * @param {Function} cb 回调函数
  60. */
  61. function loadqqApi(cb) {
  62. // qq == 0
  63. if (!qq) {
  64. return cb && cb();
  65. }
  66. var script = document.createElement('script');
  67. script.src = (+qq === 1) ? '//3gimg.qq.com/html5/js/qb.js' : '//jsapi.qq.com/get?api=app.share';
  68. /**
  69. * 需要等加载过 qq 的 bridge 脚本之后
  70. * 再去初始化分享组件
  71. */
  72. script.onload = function () {
  73. cb && cb();
  74. };
  75. document.body.appendChild(script);
  76. }
  77. /**
  78. * UC浏览器分享
  79. * @method ucShare
  80. */
  81. function ucShare(config) {
  82. // ['title', 'content', 'url', 'platform', 'disablePlatform', 'source', 'htmlID']
  83. // 关于platform
  84. // ios: kWeixin || kWeixinFriend;
  85. // android: WechatFriends || WechatTimeline
  86. // uc 分享会直接使用截图
  87. var platform = '';
  88. var shareInfo = null;
  89. // 指定了分享类型
  90. if (config.type) {
  91. if (os == 2) {
  92. platform = config.type == 1 ? 'WechatTimeline' : 'WechatFriends';
  93. } else if (os == 1) {
  94. platform = config.type == 1 ? 'kWeixinFriend' : 'kWeixin';
  95. }
  96. }
  97. shareInfo = [config.title, config.desc, config.url, platform, '', '', ''];
  98. // android
  99. if (window.ucweb) {
  100. ucweb.startRequest && ucweb.startRequest('shell.page_share', shareInfo);
  101. return;
  102. }
  103. if (window.ucbrowser) {
  104. ucbrowser.web_share && ucbrowser.web_share.apply(null, shareInfo);
  105. return;
  106. }
  107. }
  108. /**
  109. * qq 浏览器分享函数
  110. * @method qqShare
  111. */
  112. function qqShare(config) {
  113. var type = config.type;
  114. //微信好友 1, 微信朋友圈 8
  115. type = type ? ((type == 1) ? 8 : 1) : '';
  116. var share = function () {
  117. var shareInfo = {
  118. 'url': config.url,
  119. 'title': config.title,
  120. 'description': config.desc,
  121. 'img_url': config.img,
  122. 'img_title': config.title,
  123. 'to_app': type,
  124. 'cus_txt': ''
  125. };
  126. if (window.browser) {
  127. browser.app && browser.app.share(shareInfo);
  128. } else if (window.qb) {
  129. qb.share && qb.share(shareInfo);
  130. }
  131. };
  132. if (qqBridgeLoaded) {
  133. share();
  134. } else {
  135. loadqqApi(share);
  136. }
  137. }
  138. /**
  139. * 对外暴露的接口函数
  140. * @method mShare
  141. * @param {Object} config 配置对象
  142. */
  143. function mShare(config) {
  144. this.config = config;
  145. this.init = function (type) {
  146. if (typeof type != 'undefined') this.config.type = type;
  147. try {
  148. if (uc) {
  149. ucShare(this.config);
  150. } else if (qq && !wx) {
  151. qqShare(this.config);
  152. }
  153. } catch (e) {}
  154. }
  155. }
  156. // 预加载 qq bridge
  157. loadqqApi(function () {
  158. qqBridgeLoaded = true;
  159. });
  160. if (typeof module === 'object' && module.exports) {
  161. module.exports = mShare;
  162. } else {
  163. window.mShare = mShare;
  164. }

好了,这样就可以直接唤起微信进行分享啦

事件冒泡和冒泡的阻止

seo达人

事件冒泡概念:当元素触发了事件的时候,会依次向上触发所有元素的相同事件。



事件冒泡的行为演示

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <title>Document</title>

    <style>

     #a{

         background: pink;

         width: 400px;

         height: 400px;

     }

     #b{

         background: green;

         width: 300px;

         height: 300px;

     }

     #c{

         background: red;

         width: 200px;

         height: 200px;

     }

    </style>

</head>

<body>

    <div id="a">

        我是a

          <div id="b">

                我是b

             <div id="c">我是c</div>

          </div>

    </div>

    <script>

     var a = document.querySelector('#a')

     var b = document.querySelector('#b')

     var c = document.querySelector('#c')



     a.onclick = fn1;

     b.onclick = fn2;

     c.onclick = fn3;



     function fn1(){

         alert('a来了')

     }



     function fn2(){

         alert('b来了')

     }

     

     function fn3(){

         alert('c来了')

     }

    </script>

</body>

</html>



上面这段代码一共有三个事件,三个div都分别绑定了单击事件。在页面中当单击c会连续弹出3个提示框。这就是事件冒泡引起的现象。事件冒 泡的过程是:c --> b --> a 。c冒泡到b冒泡到a。



冒泡的阻止

方法:

1.event.stopPropagation(); 是事件对象Event的一个方法,作用是阻止目标元素事件冒泡到父级元素 2.event.cancelBubble = true; IE浏览器的方法



<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <title>Document</title>

    <style>

     #a{

         background: pink;

         width: 400px;

         height: 400px;

     }

     #b{

         background: green;

         width: 300px;

         height: 300px;

     }



      #c{

         background: red;

         width: 200px;

         height: 200px;

     }

    </style>

</head>

<body>

    <div id="a">

        我是a

          <div id="b">

                我是b

             <div id="c">我是c</div>

          </div>

    </div>

    <script>

     var a = document.querySelector('#a')

     var b = document.querySelector('#b')

     var c = document.querySelector('#c')



     a.onclick = fn;

     b.onclick = fn;

     c.onclick = fn;



     function fn(event){

         var e = window.event || event;

         // 事件冒泡的阻止

         if(e.stopPropagation){

            e.stopPropagation();  // 通用写法

         }else{

             e.cancelBubble = true; // 阻止IE

         }

         var str = this.innerHTML;

         alert(str)

     }

    </script>

</body>

</html>


网页制作学习用好HTML字体标记及属性

前端达人

我们在这里将要谈的是有关文字的标记,包括字体大小、颜色、字型...等变化,适当的应用可以增加页面的美观!



常用字体标记



<Hn>...</Hn> 标题 ,设定标题字体大小, n = 1 ( 大 ) ~ 6 ( 小 ) 会自动跳下一行。通常用在如章节、段落等标题上。

如 : <H2> 标题 </H2>



标题

如 : <H3 ALIGN = CENTER> 标题 </H3> ( 标题置中 )

标题

<B>...</B> 粗体字 。

如 : <B> 粗体字 </B>



粗体字



<I>...</I> 斜体字 。

如 : <I> 斜体字 </I> 

斜体字



<U>...</U> 加底线 。

如 : <U> 加底线 </U> 

加底线



<DEL>...</DEL> 横线 ( 表示删除 )。

如 : <DEL> 横线 </DEL> 

横线



<TT>...</TT> 打字体 ( 固定宽度文字 )。

如 : <TT> 打字体 </TT> 

打字体



<SUP>...</SUP> 上标字 。

如 : 字体 <SUP> 上标字 </SUP> 

字体 上标字



<SUB>...</SUB> 下标字 。

如 : 字体 <SUB> 下标字 </SUB> 

字体 下标字



<!...> 注解 ( 不会显示在浏览器上 ),可以多行。



如 : <! 更新日期 : 2000/1/1>



设定字体大小、颜色、字型



有关设定文字的方法共有以下几种 :



1.设定HTML文件主体文字颜色。<BODY>...</BODY>标记。 



如 : <BODY TEXT=RED>...</BODY> 或 

<BODY TEXT=#FF0000>...</BODY>



2.设定基本字体大小、颜色、字型。<BASEFONT>...</BASEFONT>标记。



3.设定字体大小、颜色、字型。<FONT>...</FONT>标记。



<BASEFONT>...</BASEFONT> 设定基本字体 ,SIZE = 1 ~ 7,1 ( 最小 ) 7 ( 最大 )。

如 : <BASEFONT SIZE=4> 基本字体大小为 4 </BASEFONT> 

基本字体大小为 4



如 : <BASEFONT COLOR =#FF0000> 设定颜色 </BASEFONT> 

设定颜色



如 : <BASEFONT FACE = 标楷体 , 细明体 > 设定字型 </BASEFONT> 

设定字型



<BIG>...</BIG> 基本字体加大 。

如 : <BASEFONT SIZE=4> 基本字体大小为 4,</BASEFONT> 

<BIG> 加大为 5 </BIG> 

基本字体大小为 4, 加大为 5



<SMALL>...</SMALL> 基本字体减小 。

如 : <BASEFONT SIZE=4> 基本字体大小为 4,</BASEFONT> 

<SMALL> 减小为 3 </SMALL> 

基本字体大小为 4, 减小为 3



<FONT>...</FONT> 设定字体大小、颜色、字型 ,SIZE = 1 ~ 7,1 ( 最小 ) 7 ( 最大 )。

如 : <FONT SIZE=4> 字体大小为 4 </FONT> 

字体大小为 4



如 : <BASEFONT SIZE=4> 基本字体大小为 4 

<FONT SIZE= 1> 1字体大小为 5 </FONT> 

<FONT SIZE=-2> -2字体大小为 2 </FONT>...</BASEFONT> 

基本字体大小为 4 

1字体大小为 5 

-2字体大小为 2 



如 : <FONT COLOR =#FF0000> 设定颜色 </FONT> 

设定颜色



如 : <FONT FACE = 标楷体 , 细明体 > 设定字型 </FONT> 

设定字型



新建一个前端学习qun438905713,在群里大多数都是零基础学习者,大家相互帮助,相互解答,并且还准备很多学习资料,欢迎零基础的小伙伴来一起交流。


  1. 设定字体的大小分 : 绝对SIZE 如 : <FONT SIZE=4> 

    和 相对SIZE 如 : <FONT SIZE= 1> ( 以 BASEFONT 设定的字体大小做加减 )。


  2. 设定字体的颜色可以是颜色名称或#RRGGBB表红绿蓝强度 ( 00 暗 ~ FF 亮 )。 #RRGGBB 所代表的是红、绿、蓝三原色,每一色由两位十六进制的数值表示 ( 即十进制 0 ~ 255 )。 

    十六进制 : 0、1、2、3、4、5、6、7、8、9、A、B、C、D、E、F。


  3. 设定字体的字型会按照顺序找出显示的字型,若找不到则以系统预设字型显示。

    ————————————————

    版权声明:本文为CSDN博主「前端学习线路」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。

    原文链接:https://blog.csdn.net/webxuexi168/article/details/104411193

Layui中使用ECharts

seo达人

日常”过坑“记录

只记录方法不说原理。。。



步骤:



ECharts下载

引入echarts.js

注意:这里好像只能用echarts.js,其它的不行,英文后面配置的时候要改东西(ps:我也不太不清楚)







修改echarts.js

打开echarts.js,在文件大概开始处添加如下代码



window.layui && layui.define ? layui.define(function(exports){exports('echarts',factory(exports))}) :

如图:







在文件内容末尾添加如下代码:



exports.parseGeoJson = parseGeoJson;

return exports;

如图:







 



layui添加配置并使用





ok了,和网上其它的相比,我这个应该是最简单的配置了。


h5新增的表单标签

seo达人

h5新增的表单标签

原创weixin_46366721 最后发布于2020-02-29 12:27:39 阅读数 13  收藏

展开

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

   <style>

       / 谷歌 /

       input::-webkit-input-placeholder{

           color:blue;

       }

       / 火狐19+ /

       input::-moz--input-placeholder{

           color:blue

       }

       / 火狐4-18 /

       input:-moz-input-placeholder{

           color:blue;

       }

       / ie高版本,ie+ /

       input::-ms-input-placeholder{

           color:blue;

       }

       / 欧鹏 /

       input::-o-input-placeholder{

           color:blue;

       }

       

   </style>

</head>

<body>

<form action="" novalidate>

    <input type="email">

    <input type="submit">

    <br>

    <input type="url">

    <input type="submit">

    <br>

    <input type="range">

    <input type="submit">

    <br>

    <input type="number">

    <input type="submit">

    <br>

    <input type="search">

    <input type="submit">

    <br>

    <input type="color">

    <input type="submit">

    <br>

   <input type="time">

   <br>

   <input type="month">

   <br>

   <input type="week">

   <br>

   <!-- <input type="datetime-local> -->

   <input type="date">

   <br>

   <!-- <input type="text" required>

   <input type="submit"> -->

    <br>

    <input type="number" step="3">

    <input type="submit">

    <br>

    <input type="text" name="aa" autocomplete="off">

    <input type="submit">

    <br>

    <input type="text"  value="" placeholder="请输入您的姓名:"  autofocus>

    <input type="submit">

    <br>

    <input type="text" placeholder="请输入您的手机号:" pattern="^1[3|5|8]\d{9}$">

    <input type="submit">

    <br>

    <input type="file" multiple>

    <br>

    <input type="url" list="lll">

    <datalist id="lll">

        <option value="http://www.baidu.com" label="百度"></option>

        <option value="http://www.sina.com" label="新浪"></option>

        </datalist>

    <input type="submit">

</form>

</body>

</html>



h5新增type类型:



Type=“email” 限制用户必须输入email类型

Type=“url” 输入的网址前面必须加上http://

Type=“range” 产生一个滑动条表单

Type=“number” 必须输入的是数字,调整数字大小(谷歌浏览器输入字母不可以,但是可以输入e;火狐可以输入字母,不能提交)

Type=“search” 产生一个搜索意义的表单(火狐浏览器没有叉号,谷歌有)

Type=“color” 生成一个颜色选择的表单;

产生很大的兼容问题:



type=“time” 限制用户必须输入时间类型

type=“month” 限制用户必须输入月份类型(火狐浏览器不显示)

type="week"限制用户必须输入周类型

type="datetime-local"选取本地时间

type=“date”

新增表单属性:



required 检测是否为空;



min:最小值



max:最大值



step:数值增加的幅度; 如果输入的是step=“3”,搜索框输入2,按住上键调的话,会是3,因为法定值:-3 0 3 6 9



autocomplete是否自动提示信息 on(默认值)off;和name="" 一起使用;



placeholder:文本框的提示信息(value的值得手动删除,而placeholder不用删除,可以直接输入内容)



autofocus:自动聚焦,一个页面只能存在一个聚焦(auto:自动)



pattern:后面的属性值是一个正则表达式

//手机号验证pattern=“^1[3][5]\d{9}$”



novalidate:取消验证,放在form里面



multiple:选择多个文件上传



list:提示信息;必须结合datalist标签,绑定datelist (谷歌提示value和label,而火狐只有label提示)



h5:新增的表单标签



datalist

option

output:计算结果输出、脚本的输出


子类对象实例化全过程

seo达人

标准格式注意:

super()和this()调用语句不能同时在一个构造器中。

super()或this()调用语句只能作为构造器中的第一句出现。原因:

无论通过哪个构造器创建子类对象,需要保证先初始化父类。

目的是,当子类继承父类后,“继承”父类所有的属性和方法,因此子类有必要知道父类如何为对象进行初始化。

从结果上看:继承性

子类继承父类以后,就获取了父类中声明的属性或方法。

创建子类的对象,在堆空间中,就会加载所父类中声明的属性。

从过程上看:

当我们通过子类的构造器创建子类对象时,我们一定会直接或间接的调用其父类的构造器,进而调用父类的父类的构造器,…直到调用了java.lang.Object类中空参的构造器为止。正因为加载过所的父类的结构,所以才可以看到内存中父类中的结构,子类对象才可以考虑进行调用。

强调说明:

虽然创建子类对象时,调用了父类的构造器,但是自始至终就创建过一个对象,即为new的子类对象。


html内联元素和块级元素的基本概念及使用示例

前端达人

html标签分为两种,内联元素和块级元素,首先我们先了解一下内联元素和块级元素的概念:



块级元素:一般是其它元素的容器,可容纳内联元素和其它块级元素,块级元素排斥其它元素与其位于同一行,可设置宽度(width)高度(height)属性,正常流中的块级元素会垂直摆放。常见块状元素为“div”



内联元素(行内元素):内联元素只能容纳文本或者其他内联元素,是块级元素的后代,它允许其他内联元素与其位于同一行,不能设置高度(height)和宽度(width)。常见内联元素为“a”。



根据块级元素的概念我们可以理解为块级元素前后带有换行符,也就相当于元素前后加了一个<br>标签。我们可以把块级元素想象成一个块或一个矩形,所以块级元素能设置高度宽度属性



新建一个前端学习qun438905713,在群里大多数都是零基础学习者,大家相互帮助,相互解答,并且还准备很多学习资料,欢迎零基础的小伙伴来一起交流。

例:

css文件:

 



复制代码



代码如下:




div1{ 

width:200px; 

height:200px; 

background:#666 



div2{ 

width:200px; 

height:200px; 

background:#F00 

}





html文件: 

 



复制代码



代码如下:





<div id="div1"> 

div1 

块级元素排斥其他元素与其位于同一行 

</div> 

<div id="div2"> 

div2 

块级元素排斥其他元素与其位于同一行 

</div>





显示效果: 



两个div元素不位于同一行



 



根据内联元素的概念,我们可以理解为内联元素前后没有换行符。我们可以把内联元素想象成一条线,所以它不能设置height属性和width属性。



块级元素(block element)标签



address -地址

blockquote - 块引用

center – 居中对齐

dir -目录列表

div - 常用块级容易,也是CSS layout的主要标签

dl - 定义列表

fieldset - form控制组

form - 交互表单

h1 - 大标题

h2 - 副标题

h3 - 3级标题

h4 - 4级标题

h5 - 5级标题

h6 - 6级标题

hr - 水平分隔线

isindex - input prompt

menu - 菜单列表

noframes - frames可选内容,(对于不支持frame的浏览器显示此区块内容

noscript - 可选脚本内容(对于不支持script的浏览器显示此内容)

ol - 排序表单

p - 段落

pre - 格式化文本

table - 表格

ul - 非排序列表



内联元素(inline element)



a - 锚点

abbr - 缩写

acronym - 首字

b - 粗体(不推荐)

bdo - bidi override

big - 大字体

br - 换行

cite - 引用

code - 计算机代码(在引用源码的时候需要)

dfn - 定义字段

em - 强调

font - 字体设定(不推荐)

i - 斜体

img - 图片

input - 输入框

kbd - 定义键盘文本

label - 表格标签

q - 短引用

s - 中划线

samp - 定义范例计算机代码

select - 项目选择

small - 小字体文本

span - 常用内联容器,定义文本内区块

strike - 中划线

strong - 粗体强调

sub - 下标

sup - 上标

textarea - 多行文本输入框

tt - 定义打字机文本

————————————————

版权声明:本文为CSDN博主「前端学习线路」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/webxuexi168/article/details/104382660

CSS简单实现圣杯布局和双飞翼布局

seo达人

一、你能学到什么?

①如何使用css变量 ②实现圣杯布局和双飞翼的简单思路 ③了解浮动和margin的特性



css变量设置(两个布局都有的部分)

:root{

    / 左边栏宽度 /

    --lw:300px;

    /负左边栏宽度/

    --lwf:-300px;

    / 右边栏宽度 /

    --rw:400px;

    /负左边栏宽度/

    --rwf:-400px;

    / 高度 /

    --height:300px;

}



二、圣杯布局的html和css代码

html部分

  <div class="holyGrail">

    <div class="hg_main">main</div>

    <div class="hg_left">left</div>

    <div class="hg_right">right</div>

  </div>



css 实现对应的四个class

.holyGrail {

    height: var(--height);

    / 留出左右两栏的布局 为了字体不被覆盖/

    padding-left: var(--lw);

    padding-right: var(--rw);

}

.hg_main{

    width:100%;

    float: left;

    height: var(--height);

    background-color: blanchedalmond;

}

.hg_left{

    position: relative;

    left: var(--lwf);

    float: left;

    margin-left: -100%;

    width:var(--lw);

    height: var(--height);

    background-color: blueviolet;

}

.hg_right{

    float: left;

    margin-right: var(--rwf);

    width:var(--rw);

    height: var(--height);

    background-color: brown;

}





三、双飞翼布局的html和css代码

html部分

<div class="doubleWing">

    <div class="dw_main">

      <div class="dw_con">main</div>

    </div>

    <div class="dw_left">left</div>

    <div class="dw_right">right</div>

  </div>



css 实现对应的五个class

.doubleWing{

    padding-right: var(--rw);

}

.dw_left{

    float: left;

    margin-left: -100%;

    width:var(--lw);

    height: var(--height);

    background-color: blueviolet;

}

.dw_main{

    width:100%;

    float: left;

    height: var(--height);

    background-color: blanchedalmond;

}

.dw_con {

margin-left: var(--lw);

}

.dw_right{

    float: left;

    margin-right: var(--rwf);

    width:var(--rw);

    background-color: brown;

    height: var(--height); 

}



四、学会两个布局的注意点

圣杯布局

在最外边的类(holyGrail)左右要留出左栏和右栏的宽度(使用padding-left,padding-right)

中间的div.hg_main放在最上面,优先渲染,中间div自适应,width为100%

左中右栏的div都设置浮动,左栏通过margin-left:-100%移动到和中间的div同一起点,然后通过position: relative;

left: -(左栏的宽度);会移动到最外层div的左内边距的区域(中间div的左边)

右栏可以通过margin-right:-(右栏的宽度);移动到最外层div的右内边距的区域(中间div的右边)

双飞翼布局

在中栏的div再加一个div,设置margin-left:左栏的宽度,这样可以省略左栏的div使用postion和left的属性移动

最外层的div可以不用预留左栏的位置了

五、两个布局的对比的优缺点

布局 优点 缺点

圣杯 无多余dom 当中间的宽度小于左右的宽度时,结构混乱

双飞翼 可以支持各种宽度,通用性强较强 需要多加一层dom

代码下载地址

记得一定要自己去实现一下


关于javascript跳转与返回和刷新页面

seo达人

javascript中window.open()与window.location.href的区别

window.open(‘index.html’) 表示新增一个窗口打开 index.html 这个页面,并不刷新

location.href(‘index.html’) 表示在当前窗口重定向到新页面,打开并刷新 index.html 这个页面



window.location 是 window 对象的属性,用来替换当前页,也就是重新定位当前页

而window.open 是 window 对象的方法,是用来打开一个新窗口的函数



// 打开新页面

// 注意:有些浏览器的安全设置会将window.open()屏蔽,例如避免弹出广告窗

window.open('./index.html');



// 在原窗口打开新页面

window.location.href="./index.html";



window.open()详解



window.open ('page.html', 'newwindow', 'height=100, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no')





参数解释: 三个参数

window.open 弹出新窗口的命令;

‘page.html’ 弹出窗口的文件名;

‘newPage’ 弹出窗口的名字(不是文件名),非必须,可用空’'代替;

height=100 窗口高度;

width=400 窗口宽度;

top=0 窗口距离屏幕上方的象素值;

left=0 窗口距离屏幕左侧的象素值;

toolbar=no 是否显示工具栏,yes为显示;

menubar=no 是否显示菜单栏,yes为显示;

scrollbars=no 是否显示滚动栏,yes为显示;

resizable=no 是否允许改变窗口大小,yes为允许;

location=no 是否显示地址栏,yes为允许;

status=no 是否显示状态栏内的信息(通常是文件已经打开),yes为允许;



常用的js返回与刷新页面

在此用a标签举例





<a href="javascript: history.back(-1)">返回上一页</a> 

<a href="javascript:history.go(-1)">返回上一页</a> 

<a href="javascript:history.go(-2)">返回前两页</a> 

<a href="javascript:location.reload()">刷新当前页面</a> 

<a href="javascript:" onclick="self.location=document.referrer;">返回上一页并刷新</a> 





js





// 刷新当前页面

window.location.Reload();

self.location.reload();

window.location.href = window.location.href;


弹性布局(Flex)+骰子旋转实例^v^

seo达人

弹性布局(Flex)

随着移动互联网的发展,对于网页布局来说要求越来越高,而传统的布局方案对于实现特殊布局非常不方便,比如垂直居中。

2009年,W3C 提出了一种新的方案----Flex 布局,可以简便、完整、响应式地实现各种页面布局。目前,它已经得到了所有浏览器的支持,这意味着,现在就能很安全地使用这项功能。

下面是一些弹性布局的基本语法:

两部分:


  1. 语法是添加到父容器上的

            display : flex;(弹性盒子的标志哦!!!)

            flex-direction: row; 布局的排列方向 (主轴排列方向)

                 row 默认值,显示为行。方向为当前文档水平流方向,默认情况下是从左往右。

                 row-reverse  显示为行。但方向和row属性值是反的

                 column  显示为列

                 column-reverse 显示为列。但方向和column属性值是反的

            flex-wrap : nowrap; 是否进行换行处理。

                 nowrap; 默认值,不换行处理

                 wrap; 换行处理

                 wrap-reverse; 反向换行

            flex-flow : flex-direction flex-wrap 复合写法 (是有顺序的)。

            justify-content ; 属性决定了主轴方向上子项的对齐和分布方式。  

                flex-start : 子项都去起始位置对齐。

                flex-end : 子项都去结束位置对齐。

                center : 子项都去中心位置对齐。

                space-between : 表现为两端对齐。多余的空白间距在元素中间区域分配,两边没宽。 

                space-around : 边缘两侧的空白只有中间空白宽度一半即每个块都有左右间距。

                space-evenly :每个flex子项两侧空白间距完全相等。

            align-items : 每一行中的子元素上下对齐方式。

                stretch;默认值,flex子项拉伸

                flex-start;容器顶部对齐

                center;容器居中对齐

                flex-end;容器底部对齐

            align-content : 跟justify-content相反的操作。侧轴的对齐方式。(最少需要两行才能看出效果,因为他是多行的一个上下对齐方式)

                默认:多行下,有几行就会把容器划分为几部分,默认就是stretch拉伸的。

                值跟justify-content取值是相同的。


  2. 语法是添加到子容器上的?

            order : 排序(值越大越后)

                0:默认值      eg:1234

                1:放在后面    eg:1342

                -2:放在前面   eg:2134

            flex-grow : 扩展 ( 想看到扩展的效果,必须有空隙 )

                0 : 默认值 , 不去扩展

                0.5:占空隙的一半

                1 : 去扩展 , 会把空白区域全部沾满

             ( 注:子元素会按照设置的比例值来分配空隙,如果比例值总和小于1,那么会有空隙,如果比例值总和大于等于1,那么就没有空隙。)

            flex-shrink : 收缩

                正常默认值是1

                0表示不收缩,.5收缩小一些,2收缩大一些。(大小是跟正常缩放1进行比较的)

            flex-basis : 跟flex-shrink/flex-grow很像。

                flex-shrink/flex-grow是设置一个比例值,flex-basis是设置一个具体值。

            flex : 一种复合写法

                flex-grow  flex-shrink  flex-basis

                flex:1;

                    flex : 1 1 0    

                flex:0;

                    flex : 0 1 0

            algin-self: 跟align-items操作很像,区别就是只是针对某一个子项。

                



    注:默认情况下,在弹性盒子中的子元素的左右排列的。

    注:

        水平是主轴的时候:默认情况下,当宽高不写的时候,宽度由内容决定,高度由父容器决定。

        垂直是主轴的时候:默认情况下,当宽高不写的时候,宽度由父容器决定,高度由内容决定。



    注:当子项的总宽度大于父容器的时候,会自动收缩的(弹性的优先级是大于自身固定大小的)

    注:当子项的内容已经达到了父容器最小宽高的时候,就会出现溢出的现象。



    注:弹性布局中用的频率比较多的语法:

        display : flex;

        flex-direction;

        justify-content;

        align-items;

        flex;



    注:弹性布局的优势是做一维布局,网格布局的优势是做二维布局。



    下面是弹性布局骰子案例代码:



    <!DOCTYPE html>

    <html lang="en">

    <head>

        <meta charset="UTF-8">

        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <title>Document</title>

        <style>

            *{margin: 0;padding: 0;}

            ul{list-style: none;}

            a{text-decoration: none;}

            img{display: block;}



            .box1{width: 150px;height: 150px;display: flex;border: 1px black solid;margin: 20px auto;border-radius: 10px;justify-content: center;align-items: center;}

            .box1 div{width: 30px;height: 30px;border-radius:50%;background: black;}



            .box2{width: 150px;height: 150px;display: flex;border: 1px black solid;margin: 20px auto;border-radius: 10px;align-items: center;justify-content: space-between;}

            .box2 div{width: 30px;height: 30px;border-radius:50%;background: black;margin: 10px;}

            .box2 div:nth-of-type(1){align-self: flex-start;}

            .box2 div:nth-of-type(2){align-self: flex-end;}



            .box3{width: 150px;height: 150px;display: flex;border: 1px black solid;margin: 20px auto;border-radius: 10px;align-items: center;justify-content: space-between;}

            .box3 div{width: 30px;height: 30px;border-radius:50%;background: black;margin: 10px;}

            .box3 div:nth-of-type(1){align-self: flex-start;}

            .box3 div:nth-of-type(3){align-self: flex-end;}



            .box4{width: 150px;height: 150px;border: 1px black solid;margin: 20px auto;border-radius: 10px;display: flex;flex-direction: column;}

            .box4 div{height: 50%;display: flex;flex-direction: row;justify-content: space-around;align-items: center;}

            .box4 div li{display: block; width: 30px;height: 30px;border-radius:50%;background: black;}



            .box5{width: 150px;height: 150px;border: 1px black solid;margin: 20px auto;border-radius: 10px;display: flex;flex-direction: column;}

            .box5 div{height: 50%;display: flex;flex-direction: row;justify-content: space-around;align-items: center;}

            .box5 div li{display: block; width: 30px;height: 30px;border-radius:50%;background: black;}



            .box6{width: 150px;height: 150px;border: 1px black solid;margin: 20px auto;border-radius: 10px;display: flex;flex-direction: column;}

            .box6 div{height: 50%;display: flex;flex-direction: row;justify-content: space-around;align-items: center;}

            .box6 div li{display: block; width: 30px;height: 30px;border-radius:50%;background: black;}



            #box{width: 400px;height: 400px;margin: 20px auto;border: 1px springgreen solid; 

            perspective: 500px;perspective-origin: right top;}

            #box .main{position: relative;width: 150px;height: 150px;margin: 125px;

            transform-style: preserve-3d;transition: 4s;transform-origin: center center -50px;}

            #box .main .box1{position: absolute;background:limegreen;left: 0;top: 0;

            width: 150px;height: 150px;}

            #box .main .box2{position: absolute;background:limegreen;left: 0;top: 0;

            width: 150px;height: 150px;left: 150px;transform-origin:left; transform:rotateY(90deg);}

            #box .main .box3{position: absolute;background:limegreen;left: 0;top: 0;

            width: 150px;height: 150px;left: -150px;transform-origin:right; transform:rotateY(-90deg);}

            #box .main .box4{position: absolute;background:limegreen;left: 0;top: 0;

            width: 150px;height: 150px;top: -150px;transform-origin:bottom; transform:rotateX(90deg);}

            #box .main .box5{position: absolute;background:limegreen;left: 0;top: 0;

            width: 150px;height: 150px;top: 150px;transform-origin:top; transform:rotateX(-90deg);}

            #box .main .box6{position: absolute;background:limegreen;left: 0;top: 0;

            width: 150px;height: 150px;transform:translateZ(-150px) rotateY(180deg);}



            #box:hover .main{transform:rotateY(360deg);}

        </style>

    </head>

    <body>

        <div id="box">

            <div class="main">

                <div class="box1">

                    <div></div>

                </div>

                <div class="box2">

                    <div></div>

                    <div></div>

                </div>

                <div class="box3">

                    <div></div>

                    <div></div>

                    <div></div>

                </div>

                <div class="box4">

                    <div>

                        <li></li>

                        <li></li>

                    </div>

                    <div>

                        <li></li>

                        <li></li>

                    </div>

                </div>

                <div class="box5">

                    <div>

                        <li></li>

                        <li></li>

                    </div>

                    <div>

                        <li></li>

                    </div>

                    <div>

                        <li></li>

                        <li></li>

                    </div>

                </div>

                <div class="box6">

                    <div>

                        <li></li>

                        <li></li>

                    </div>

                    <div>

                        <li></li>

                        <li></li>

                    </div>

                    <div>

                        <li></li>

                        <li></li>

                    </div>

                </div>

            </div>

        </div>

    </body>

    </html>




日历

链接

blogger

蓝蓝 http://www.lanlanwork.com

存档