• b站pink老师JavaScript的移动端网页特效 案例代码——移动端轮播图+返回顶部模块


    目录

    代码段

    1.index.js部分(全是重点)

    2.index.html部分(红色部分是重点)

    3.index.css部分(红色部分是重点)

    4.normalize.css部分(不是重点,辅助作用)


    目标效果:

    1.利用定时器(setInterval)自动轮播图片

    2.等着1.中过渡完成之后,再去判断 监听过渡完成的事件 transitionend

    实现无缝滚动

    第一个focus1的index是0,最后一个focus1的index是3。当index变为3或更大的时候,跳转回index为0;当index<0的时候,跳转回index为2

    3.ul滚动的时候,小圆点跟随变化

    4.手指可以滑动轮播图(本质上是让ul跟随手指移动)

    (触摸元素(touchstart)获得手指初始坐标,手指滑动(touchmove)获得手指移动距离,盒子最终移动距离=盒子之前的移动距离+手指移动的距离)

    5.在4.中手指滑动轮播图手指移开(touchend)的时候,如果用户手指移动过再去判断,不然不判断

    (1)如果移动距离大于50px,则播放上一张/下一张

    (2)如果移动距离小于50px,则回弹

    手指移开(touchend)后,重新开启定时器,让ul继续自动轮播

    6.当窗口滚到nav的地方,显示goBack返回顶部图片

    7.点击goBack图片,滚动窗口至页面最上方 window.scroll(0,0);

    (1)轮播图要实现无缝滚动,所以复制第一张图片去最后

    (2)【移动端轮播图的特殊性】因为移动端的轮播图,如果处在第一张图片,往右拉动,可以看到第一张图片之前的内容。因此需要复制第三张图片去第一张图片的前面,防止用户拉动后看到空白。这样用户处在原来的第一张图片1,右拉会看到新复制过去的图片3。

     (3)复制完毕后,由于盒子默认左对齐

    如下图:一开始看到的是图片3

    所以加这一句话,使得一开始看是看到的是图片1 

     (4)自动播放的无缝滚动原理

    a.先播放图片1,再图片2,图片3,再最后一个复制的图片1

    b.然后让最后一个图片1,快速跳到前面的那个图片1上去 :

     

     之后就继续重复a.步骤

    e.g.轮播图效果见图片的红框中 

    1.index.js部分(全是重点)

    1. window.addEventListener('load', function () {//等整个页面加载完毕,再运用js
    2. // 1.获取元素
    3. var focus = document.querySelector('.focus');
    4. var ul = focus.children[0];
    5. var ol = focus.children[1];
    6. // 移动的每张图片的宽度,就是focus宽度
    7. // 获得focus的宽度
    8. var w = focus.offsetWidth;
    9. // 2.利用定时器自动轮播图片
    10. // 声明一个变量index来控制ul每次移动
    11. var index = 0;
    12. var timer = setInterval(function () {
    13. index++;
    14. var translatex = -index * w;//因为是往左走,所以是负值
    15. ul.style.transition = 'all .3s';//添加过渡,让图片慢点自动滚动
    16. ul.style.transform = 'translateX(' + translatex + 'px)';//每隔2S,往左滚动一张图片
    17. }, 2000);
    18. // 等着过渡完成之后,再去判断 监听过渡完成的事件 transitionend
    19. ul.addEventListener('transitionend', function () {
    20. // 无缝滚动
    21. // 第一个focus1index0,最后一个focus1index3
    22. //index变为3或更大的时候,跳转回index0
    23. if (index >= 3) {
    24. index = 0;
    25. // 去掉过渡,直接跳转
    26. ul.style.transition = 'none';
    27. // 用最新的index*宽度,继续滚动图片
    28. var translatex = -index * w;
    29. ul.style.transform = 'translateX(' + translatex + 'px)';
    30. } else if (index < 0) {
    31. //index<0的时候,跳转回index2
    32. index = 2;
    33. // 去掉过渡,直接跳转
    34. ul.style.transition = 'none';
    35. // 用最新的index*宽度,继续滚动图片
    36. var translatex = -index * w;
    37. ul.style.transform = 'translateX(' + translatex + 'px)';
    38. }
    39. // 3.小圆点跟随变化效果
    40. // 移除(classList.remove)ol中li中有current类名的li
    41. ol.querySelector('li.current').classList.remove('current');
    42. // 给当前index的li添加(classList.add)类名current
    43. ol.children[index].classList.add('current');
    44. });
    45. // 4.手指滑动轮播图
    46. // 本质上是让ul跟随手指移动
    47. // 触摸元素(touchstart)获得手指初始坐标
    48. // 此处是左右滑动,所以只需要X坐标
    49. var startX = 0;
    50. var moveX = 0;//之后会使用到该移动距离,所以要是全局变量
    51. var flag = false;//声明一个全局变量flag
    52. ul.addEventListener('touchstart', function (e) {
    53. startX = e.targetTouches[0].pageX;
    54. // 手指滑动轮播图的时候,要停止轮播图的自动滚动
    55. // 当手指按下时候,就停止图片自动滚动
    56. clearInterval(timer);
    57. });
    58. // 手指滑动(touchmove)获得手指移动距离
    59. ul.addEventListener('touchmove', function (e) {
    60. // 手指移动距离=手指滑动时的手指X坐标-手指初始X坐标
    61. moveX = e.targetTouches[0].pageX - startX;
    62. // 盒子最终移动距离=盒子之前的移动距离+手指移动的距离
    63. var translatex = -index * w + moveX;
    64. // 手指移动的时候不需要过渡效果,所以去掉过渡,直接跳转
    65. ul.style.transition = 'none';
    66. ul.style.transform = 'translateX(' + translatex + 'px)';
    67. flag = true;//如果用户手指移动过再去判断,不然不判断
    68. e.preventDefault();//阻止滚动ul的时候,让屏幕滚动的行为
    69. });
    70. // 手指移开(touchend)根据移动距离判断是 回弹 还是 播放上一张/下一张
    71. ul.addEventListener('touchend', function (e) {
    72. if (flag) {//如果用户手指移动过再去判断,不然不判断
    73. //1)如果移动距离大于50px,则播放上一张/下一张
    74. if (Math.abs(moveX) > 50) {
    75. // 如果是右滑,则播放下一张,moveX是正值
    76. if (moveX > 0) {
    77. index--;
    78. } else {
    79. // 如果是左滑,则播放上一张,moveX是负值
    80. index++;
    81. }
    82. // 用最新的index*宽度,继续滚动图片
    83. var translatex = -index * w;
    84. // 图片滚动时要有过渡效果
    85. ul.style.transition = 'all .3s';
    86. ul.style.transform = 'translateX(' + translatex + 'px)';
    87. } else {
    88. // (2)如果移动距离小于50px,则回弹
    89. // 用最新的index*宽度,继续滚动图片
    90. var translatex = -index * w;
    91. // 图片滚动时要有过渡效果
    92. ul.style.transition = 'all .1s';
    93. ul.style.transform = 'translateX(' + translatex + 'px)';
    94. }
    95. }
    96. // 手指离开的时候就重新开启定时器
    97. clearInterval(timer);//先清除定时器,保证页面中只有一个定时器
    98. //再开启定时器
    99. timer = setInterval(function () {
    100. index++;
    101. var translatex = -index * w;
    102. ul.style.transition = 'all .3s';
    103. ul.style.transform = 'translateX(' + translatex + 'px)';
    104. }, 2000);
    105. });
    106. // 返回顶部模块制作
    107. var goBack = document.querySelector('.goBack');
    108. var nav = document.querySelector('nav');
    109. window.addEventListener('scroll', function () {
    110. if (window.pageYOffset >= nav.offsetTop) {
    111. // 当窗口滚到nav的地方,显示goBack返回顶部图片
    112. goBack.style.display = 'block';
    113. } else {
    114. goBack.style.display = 'none';
    115. }
    116. });
    117. // 点击goBack图片,滚动窗口至页面最上方
    118. goBack.addEventListener('click', function () {
    119. window.scroll(0, 0);
    120. });
    121. })

    2.index.html部分(红色部分是重点)

       

       

       

       

       

        携程在手,说走就走

       

       

       

       

       

           

            我 的

       

       

       

           

                 

                 

                 

    •            

    •            

    •            

    •            

                 

    •        

           

                 

    1.            

    2.            

    3.        

       

       

       

       

       

       

       

       

       

           

               

    热门活动

                获取更多福利

           

           

               

               

               

           

       

    3.index.css部分(红色部分是重点)

    body {

        max-width: 540px;

        min-width: 320px;

        margin: 0 auto;

        font: normal 14px/1.5 Tahoma, "Lucida Grande", Verdana, "Microsoft Yahei", STXihei, hei;

        color: #000;

        background: #f2f2f2;

        overflow-x: hidden;

        -webkit-tap-highlight-color: transparent;

    }

    ul {

        list-style: none;

        margin: 0;

        padding: 0;

    }

    a {

        text-decoration: none;

        color: #222;

    }

    div {

        box-sizing: border-box;

    }


     

    /* 搜索模块 */

    .search-index {

        display: flex;

        /* 固定定位跟父级没有关系 它以屏幕为准 */

        position: fixed;

        top: 0;

        left: 50%;

        /* 设置z-index让搜索模块始终在最上层 */

        z-index: 999;

        /* 固定的盒子应该有宽度 */

        -webkit-transform: translateX(-50%);

        transform: translateX(-50%);

        width: 100%;

        min-width: 320px;

        max-width: 540px;

        height: 44px;

        /* background-color: pink; */

        background-color: #F6F6F6;

        border-top: 1px solid #ccc;

        border-bottom: 1px solid #ccc;

    }

    .search {

        position: relative;

        height: 26px;

        line-height: 24px;

        border: 1px solid #ccc;

        flex: 1;

        font-size: 12px;

        color: #666;

        margin: 7px 10px;

        padding-left: 25px;

        border-radius: 5px;

        box-shadow: 0 2px 4px rgba(0, 0, 0, .2);

    }

    .search::before {

        content: "";

        position: absolute;

        top: 5px;

        left: 5px;

        width: 15px;

        height: 15px;

        background: url(../images/sprite.png) no-repeat -59px -279px;

        background-size: 104px auto;

    }

    .user {

        width: 44px;

        height: 44px;

        /* background-color: purple; */

        font-size: 12px;

        text-align: center;

        color: #2eaae0;

    }

    .user::before {

        content: "";

        display: block;

        width: 23px;

        height: 23px;

        background: url(../images/sprite.png) no-repeat -59px -194px;

        background-size: 104px auto;

        margin: 4px auto -2px;

    }


     

    /* goBack */

    .goBack {

        display: none;

        position: fixed;

        bottom: 50px;

        right: 20px;

        width: 38px;

        height: 38px;

        background: url(../images/back.png) no-repeat;

        background-size: 38px 38px;

    }


     

    /* focus */

    .focus {

        position: relative;

        padding-top: 44px;

        overflow: hidden;

    }

    .focus img {

        width: 100%;

    }

    .focus ul {

        width: 500%;

        margin-left: -100%;

    }

    .focus ul li {

        float: left;

        width: 20%;

    }

    .focus ol {

        position: absolute;

        bottom: -9px;

        right: 5px;

    }

    .focus ol li {

        display: inline-block;

        width: 5px;

        height: 5px;

        background-color: #fff;

        list-style: none;

        border-radius: 2px;

        /* 给ol里的li也就是小圆点加transition过渡,让小圆点的变化更自然 */

        transition: all .3s;

    }

    .focus ol li.current {

        width: 15px;

    }


     

    /* local-nav */

    .local-nav {

        display: flex;

        height: 64px;

        margin: 3px 4px;

        background-color: #fff;

        border-radius: 8px;

    }

    .local-nav li {

        flex: 1;

    }

    .local-nav a {

        display: flex;

        flex-direction: column;

        /* 侧轴居中对齐 因为是单行 */

        align-items: center;

        font-size: 12px;

    }

    .local-nav li [class^="local-nav-icon"] {

        width: 32px;

        height: 32px;

        background-color: pink;

        margin-top: 8px;

        background: url(../images/localnav_bg.png) no-repeat 0 0;

        background-size: 32px auto;

    }

    .local-nav li .local-nav-icon-icon2 {

        background-position: 0 -32px;

    }

    .local-nav li .local-nav-icon-icon3 {

        background-position: 0 -64px;

    }

    .local-nav li .local-nav-icon-icon4 {

        background-position: 0 -96px;

    }

    .local-nav li .local-nav-icon-icon5 {

        background-position: 0 -128px;

    }


     

    /* nav */

    nav {

        overflow: hidden;

        border-radius: 8px;

        margin: 0 4px 3px;

    }

    .nav-common {

        display: flex;

        height: 88px;

        background-color: pink;

    }

    .nav-common:nth-child(2) {

        margin: 3px 0;

    }

    .nav-items {

        /* 不冲突的 */

        flex: 1;

        display: flex;

        flex-direction: column;

    }

    .nav-items a {

        flex: 1;

        text-align: center;

        line-height: 44px;

        color: #fff;

        font-size: 14px;

        /* 文字阴影 */

        text-shadow: 1px 1px rgba(0, 0, 0, .2);

    }

    .nav-items a:nth-child(1) {

        border-bottom: 1px solid #fff;

    }

    .nav-items:nth-child(1) a {

        border: 0;

        background: url(../images/hotel.png) no-repeat bottom center;

        background-size: 121px auto;

    }


     

    /* -n+2就是选择前面两个元素 */

    .nav-items:nth-child(-n+2) {

        border-right: 1px solid #fff;

    }

    .nav-common:nth-child(1) {

        background: -webkit-linear-gradient(left, #FA5A55, #FA994D);

    }

    .nav-common:nth-child(2) {

        background: -webkit-linear-gradient(left, #4B90ED, #53BCED);

    }

    .nav-common:nth-child(3) {

        background: -webkit-linear-gradient(left, #34C2A9, #6CD559);

    }


     

    /* subnav-entry */

    .subnav-entry {

        display: flex;

        border-radius: 8px;

        background-color: #fff;

        margin: 0 4px;

        flex-wrap: wrap;

        padding: 5px 0;

    }

    .subnav-entry li {

        /* 里面的子盒子可以写 % 相对于父级来说的 */

        flex: 20%;

    }

    .subnav-entry a {

        display: flex;

        flex-direction: column;

        align-items: center;

    }

    .subnav-entry-icon {

        width: 28px;

        height: 28px;

        background-color: pink;

        margin-top: 4px;

        background: url(../images/subnav-bg.png) no-repeat;

        background-size: 28px auto;

    }


     

    /* sales-box */

    .sales-box {

        border-top: 1px solid #bbb;

        background-color: #fff;

        margin: 4px;

    }

    .sales-hd {

        position: relative;

        height: 44px;

        border-bottom: 1px solid #ccc;

    }

    .sales-hd h2 {

        position: relative;

        text-indent: -999px;

        overflow: hidden;

    }

    .sales-hd h2::after {

        position: absolute;

        top: 5px;

        left: 8px;

        content: "";

        width: 79px;

        height: 15px;

        background: url(../images/hot.png) no-repeat 0 -20px;

        background-size: 79px auto;

    }

    .more {

        position: absolute;

        right: 5px;

        top: 0px;

        background: -webkit-linear-gradient(left, #FF506C, #FF6BC6);

        border-radius: 15px;

        padding: 3px 20px 3px 10px;

        color: #fff;

    }

    .more::after {

        content: "";

        position: absolute;

        top: 9px;

        right: 9px;

        width: 7px;

        height: 7px;

        border-top: 2px solid #fff;

        border-right: 2px solid #fff;

        transform: rotate(45deg);

    }

    .row {

        display: flex;

    }

    .row a {

        flex: 1;

        border-bottom: 1px solid #eee;

    }

    .row a:nth-child(1) {

        border-right: 1px solid #eee;

    }

    .row a img {

        width: 100%;

    }

    4.normalize.css部分(不是重点,辅助作用)

    1. /*! normalize.css v5.0.0 | MIT License | github.com/necolas/normalize.css */
    2. /**
    3. * 1. Change the default font family in all browsers (opinionated).
    4. * 2. Correct the line height in all browsers.
    5. * 3. Prevent adjustments of font size after orientation changes in
    6. * IE on Windows Phone and in iOS.
    7. */
    8. /* Document
    9. ========================================================================== */
    10. html {
    11. font-family: sans-serif; /* 1 */
    12. line-height: 1.15; /* 2 */
    13. -ms-text-size-adjust: 100%; /* 3 */
    14. -webkit-text-size-adjust: 100%; /* 3 */
    15. }
    16. /* Sections
    17. ========================================================================== */
    18. /**
    19. * Remove the margin in all browsers (opinionated).
    20. */
    21. body {
    22. margin: 0;
    23. }
    24. /**
    25. * Add the correct display in IE 9-.
    26. */
    27. article,
    28. aside,
    29. footer,
    30. header,
    31. nav,
    32. section {
    33. display: block;
    34. }
    35. /**
    36. * Correct the font size and margin on `h1` elements within `section` and
    37. * `article` contexts in Chrome, Firefox, and Safari.
    38. */
    39. h1 {
    40. font-size: 2em;
    41. margin: 0.67em 0;
    42. }
    43. /* Grouping content
    44. ========================================================================== */
    45. /**
    46. * Add the correct display in IE 9-.
    47. * 1. Add the correct display in IE.
    48. */
    49. figcaption,
    50. figure,
    51. main { /* 1 */
    52. display: block;
    53. }
    54. /**
    55. * Add the correct margin in IE 8.
    56. */
    57. figure {
    58. margin: 1em 40px;
    59. }
    60. /**
    61. * 1. Add the correct box sizing in Firefox.
    62. * 2. Show the overflow in Edge and IE.
    63. */
    64. hr {
    65. box-sizing: content-box; /* 1 */
    66. height: 0; /* 1 */
    67. overflow: visible; /* 2 */
    68. }
    69. /**
    70. * 1. Correct the inheritance and scaling of font size in all browsers.
    71. * 2. Correct the odd `em` font sizing in all browsers.
    72. */
    73. pre {
    74. font-family: monospace, monospace; /* 1 */
    75. font-size: 1em; /* 2 */
    76. }
    77. /* Text-level semantics
    78. ========================================================================== */
    79. /**
    80. * 1. Remove the gray background on active links in IE 10.
    81. * 2. Remove gaps in links underline in iOS 8+ and Safari 8+.
    82. */
    83. a {
    84. background-color: transparent; /* 1 */
    85. -webkit-text-decoration-skip: objects; /* 2 */
    86. }
    87. /**
    88. * Remove the outline on focused links when they are also active or hovered
    89. * in all browsers (opinionated).
    90. */
    91. a:active,
    92. a:hover {
    93. outline-width: 0;
    94. }
    95. /**
    96. * 1. Remove the bottom border in Firefox 39-.
    97. * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
    98. */
    99. abbr[title] {
    100. border-bottom: none; /* 1 */
    101. text-decoration: underline; /* 2 */
    102. text-decoration: underline dotted; /* 2 */
    103. }
    104. /**
    105. * Prevent the duplicate application of `bolder` by the next rule in Safari 6.
    106. */
    107. b,
    108. strong {
    109. font-weight: inherit;
    110. }
    111. /**
    112. * Add the correct font weight in Chrome, Edge, and Safari.
    113. */
    114. b,
    115. strong {
    116. font-weight: bolder;
    117. }
    118. /**
    119. * 1. Correct the inheritance and scaling of font size in all browsers.
    120. * 2. Correct the odd `em` font sizing in all browsers.
    121. */
    122. code,
    123. kbd,
    124. samp {
    125. font-family: monospace, monospace; /* 1 */
    126. font-size: 1em; /* 2 */
    127. }
    128. /**
    129. * Add the correct font style in Android 4.3-.
    130. */
    131. dfn {
    132. font-style: italic;
    133. }
    134. /**
    135. * Add the correct background and color in IE 9-.
    136. */
    137. mark {
    138. background-color: #ff0;
    139. color: #000;
    140. }
    141. /**
    142. * Add the correct font size in all browsers.
    143. */
    144. small {
    145. font-size: 80%;
    146. }
    147. /**
    148. * Prevent `sub` and `sup` elements from affecting the line height in
    149. * all browsers.
    150. */
    151. sub,
    152. sup {
    153. font-size: 75%;
    154. line-height: 0;
    155. position: relative;
    156. vertical-align: baseline;
    157. }
    158. sub {
    159. bottom: -0.25em;
    160. }
    161. sup {
    162. top: -0.5em;
    163. }
    164. /* Embedded content
    165. ========================================================================== */
    166. /**
    167. * Add the correct display in IE 9-.
    168. */
    169. audio,
    170. video {
    171. display: inline-block;
    172. }
    173. /**
    174. * Add the correct display in iOS 4-7.
    175. */
    176. audio:not([controls]) {
    177. display: none;
    178. height: 0;
    179. }
    180. /**
    181. * Remove the border on images inside links in IE 10-.
    182. */
    183. img {
    184. border-style: none;
    185. }
    186. /**
    187. * Hide the overflow in IE.
    188. */
    189. svg:not(:root) {
    190. overflow: hidden;
    191. }
    192. /* Forms
    193. ========================================================================== */
    194. /**
    195. * 1. Change the font styles in all browsers (opinionated).
    196. * 2. Remove the margin in Firefox and Safari.
    197. */
    198. button,
    199. input,
    200. optgroup,
    201. select,
    202. textarea {
    203. font-family: sans-serif; /* 1 */
    204. font-size: 100%; /* 1 */
    205. line-height: 1.15; /* 1 */
    206. margin: 0; /* 2 */
    207. }
    208. /**
    209. * Show the overflow in IE.
    210. * 1. Show the overflow in Edge.
    211. */
    212. button,
    213. input { /* 1 */
    214. overflow: visible;
    215. }
    216. /**
    217. * Remove the inheritance of text transform in Edge, Firefox, and IE.
    218. * 1. Remove the inheritance of text transform in Firefox.
    219. */
    220. button,
    221. select { /* 1 */
    222. text-transform: none;
    223. }
    224. /**
    225. * 1. Prevent a WebKit bug where (2) destroys native `audio` and `video`
    226. * controls in Android 4.
    227. * 2. Correct the inability to style clickable types in iOS and Safari.
    228. */
    229. button,
    230. html [type="button"], /* 1 */
    231. [type="reset"],
    232. [type="submit"] {
    233. -webkit-appearance: button; /* 2 */
    234. }
    235. /**
    236. * Remove the inner border and padding in Firefox.
    237. */
    238. button::-moz-focus-inner,
    239. [type="button"]::-moz-focus-inner,
    240. [type="reset"]::-moz-focus-inner,
    241. [type="submit"]::-moz-focus-inner {
    242. border-style: none;
    243. padding: 0;
    244. }
    245. /**
    246. * Restore the focus styles unset by the previous rule.
    247. */
    248. button:-moz-focusring,
    249. [type="button"]:-moz-focusring,
    250. [type="reset"]:-moz-focusring,
    251. [type="submit"]:-moz-focusring {
    252. outline: 1px dotted ButtonText;
    253. }
    254. /**
    255. * Change the border, margin, and padding in all browsers (opinionated).
    256. */
    257. fieldset {
    258. border: 1px solid #c0c0c0;
    259. margin: 0 2px;
    260. padding: 0.35em 0.625em 0.75em;
    261. }
    262. /**
    263. * 1. Correct the text wrapping in Edge and IE.
    264. * 2. Correct the color inheritance from `fieldset` elements in IE.
    265. * 3. Remove the padding so developers are not caught out when they zero out
    266. * `fieldset` elements in all browsers.
    267. */
    268. legend {
    269. box-sizing: border-box; /* 1 */
    270. color: inherit; /* 2 */
    271. display: table; /* 1 */
    272. max-width: 100%; /* 1 */
    273. padding: 0; /* 3 */
    274. white-space: normal; /* 1 */
    275. }
    276. /**
    277. * 1. Add the correct display in IE 9-.
    278. * 2. Add the correct vertical alignment in Chrome, Firefox, and Opera.
    279. */
    280. progress {
    281. display: inline-block; /* 1 */
    282. vertical-align: baseline; /* 2 */
    283. }
    284. /**
    285. * Remove the default vertical scrollbar in IE.
    286. */
    287. textarea {
    288. overflow: auto;
    289. }
    290. /**
    291. * 1. Add the correct box sizing in IE 10-.
    292. * 2. Remove the padding in IE 10-.
    293. */
    294. [type="checkbox"],
    295. [type="radio"] {
    296. box-sizing: border-box; /* 1 */
    297. padding: 0; /* 2 */
    298. }
    299. /**
    300. * Correct the cursor style of increment and decrement buttons in Chrome.
    301. */
    302. [type="number"]::-webkit-inner-spin-button,
    303. [type="number"]::-webkit-outer-spin-button {
    304. height: auto;
    305. }
    306. /**
    307. * 1. Correct the odd appearance in Chrome and Safari.
    308. * 2. Correct the outline style in Safari.
    309. */
    310. [type="search"] {
    311. -webkit-appearance: textfield; /* 1 */
    312. outline-offset: -2px; /* 2 */
    313. }
    314. /**
    315. * Remove the inner padding and cancel buttons in Chrome and Safari on macOS.
    316. */
    317. [type="search"]::-webkit-search-cancel-button,
    318. [type="search"]::-webkit-search-decoration {
    319. -webkit-appearance: none;
    320. }
    321. /**
    322. * 1. Correct the inability to style clickable types in iOS and Safari.
    323. * 2. Change font properties to `inherit` in Safari.
    324. */
    325. ::-webkit-file-upload-button {
    326. -webkit-appearance: button; /* 1 */
    327. font: inherit; /* 2 */
    328. }
    329. /* Interactive
    330. ========================================================================== */
    331. /*
    332. * Add the correct display in IE 9-.
    333. * 1. Add the correct display in Edge, IE, and Firefox.
    334. */
    335. details, /* 1 */
    336. menu {
    337. display: block;
    338. }
    339. /*
    340. * Add the correct display in all browsers.
    341. */
    342. summary {
    343. display: list-item;
    344. }
    345. /* Scripting
    346. ========================================================================== */
    347. /**
    348. * Add the correct display in IE 9-.
    349. */
    350. canvas {
    351. display: inline-block;
    352. }
    353. /**
    354. * Add the correct display in IE.
    355. */
    356. template {
    357. display: none;
    358. }
    359. /* Hidden
    360. ========================================================================== */
    361. /**
    362. * Add the correct display in IE 10-.
    363. */
    364. [hidden] {
    365. display: none;
    366. }

  • 相关阅读:
    对于JSP原理以及源码的深入剖析与理解心得
    校招C#面试题整理—Unity客户端
    计算机组成原理 | 中央处理器
    服务器环境搭建
    Unity的OnOpenAsset:深入解析与实用案例
    【历史上的今天】8 月 15 日:苹果推出初代 iMac;谷歌收购摩托罗拉移动;Fuchsia 首次发布
    java计算机毕业设计基于安卓Android的升降式停车场管理系统APP
    JavaSE | 顺序表练习
    102.二叉树的层序遍历
    Python爬虫_某宝网案例
  • 原文地址:https://blog.csdn.net/weixin_72322475/article/details/126934729