鼠标滚动倾斜分割切换

css部分:

   <style>
        body, html { font-size: 100%;     padding: 0; margin: 0;}

        /* Reset */
        *,
        *:after,
        *:before {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
        }

        /* Clearfix hack by Nicolas Gallagher: http://nicolasgallagher.com/micro-clearfix-hack/ */
        .clearfix:before,
        .clearfix:after {
            content: " ";
            display: table;
        }

        .clearfix:after {
            clear: both;
        }

        body{
            /*background: #f9f7f6;
            color: #404d5b;*/
            background: #494A5F;
            color: #D5D6E2;
            font-weight: 500;
            font-size: 1.05em;
            font-family: "Microsoft YaHei","宋体","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif, FreeSans, Arimo;
        }
        a{color: #2fa0ec;text-decoration: none;outline: none;}
        a:hover,a:focus{color:#74777b;}
        *, *:before, *:after {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            background: #15181A;
            font-family: "Open Sans", Helvetica, Arial, sans-serif;
        }

        .skw-pages {
            overflow: hidden;
            position: relative;
            height: 100vh;
        }

        .skw-page {
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
        }
        .skw-page__half {
            position: absolute;
            top: 0;
            width: 50%;
            height: 100vh;
            -webkit-transition: -webkit-transform 1s;
            transition: transform 1s;
        }
        .skw-page__half--left {
            left: 0;
            -webkit-transform: translate3d(-32.4vh, 100%, 0);
            transform: translate3d(-32.4vh, 100%, 0);
        }
        .skw-page__half--right {
            left: 50%;
            -webkit-transform: translate3d(32.4vh, -100%, 0);
            transform: translate3d(32.4vh, -100%, 0);
        }

        .skw-page.active .skw-page__half {
            -webkit-transform: translate3d(0, 0, 0);
            transform: translate3d(0, 0, 0);
        }

        .skw-page__skewed {
            overflow: hidden;
            position: absolute;
            top: 0;
            width: 140%;
            height: 100%;
            -webkit-transform: skewX(-18deg);
            -ms-transform: skewX(-18deg);
            transform: skewX(-18deg);
            background: #000;
        }
        .skw-page__half--left .skw-page__skewed {
            left: -40%;
        }
        .skw-page__half--right .skw-page__skewed {
            right: -40%;
        }
        .skw-page__content {
            display: -webkit-box;
            display: -webkit-flex;
            display: -ms-flexbox;
            display: flex;
            -webkit-box-align: center;
            -webkit-align-items: center;
            -ms-flex-align: center;
            align-items: center;
            -webkit-box-pack: center;
            -webkit-justify-content: center;
            -ms-flex-pack: center;
            justify-content: center;
            -webkit-flex-flow: column wrap;
            -ms-flex-flow: column wrap;
            flex-flow: column wrap;
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            padding: 0 30%;
            color: #fff;
            -webkit-transform: skewX(18deg);
            -ms-transform: skewX(18deg);
            transform: skewX(18deg);
            -webkit-transition: -webkit-transform 1s, opacity 1s;
            transition: transform 1s, opacity 1s;
            background-size: cover;
        }
        .skw-page__half--left .skw-page__content {
            padding-left: 30%;
            padding-right: 30%;
            -webkit-transform-origin: 100% 0;
            -ms-transform-origin: 100% 0;
            transform-origin: 100% 0;
        }
        .skw-page__half--right .skw-page__content {
            padding-left: 30%;
            padding-right: 30%;
            -webkit-transform-origin: 0 100%;
            -ms-transform-origin: 0 100%;
            transform-origin: 0 100%;
        }
        .skw-page.inactive .skw-page__content {
            opacity: 0.5;
            -webkit-transform: skewX(18deg) scale(0.95);
            -ms-transform: skewX(18deg) scale(0.95);
            transform: skewX(18deg) scale(0.95);
        }
        .skw-page__heading {
            margin-bottom: 15px;
            text-transform: uppercase;
            font-size: 25px;
            text-align: center;
        }
        .skw-page__description {
            font-size: 18px;
            text-align: center;
        }
        .skw-page__link {
            color: #FFA0A0;
        }
        .skw-page-1 .skw-page__half--left .skw-page__content {
            background-image: url("../../../../img/kaka1.jpg");
        }
        .skw-page-1 .skw-page__half--right .skw-page__content {
            background: #292929;
        }
        .skw-page-2 .skw-page__half--left .skw-page__content {
            background: #292929;
        }
        .skw-page-2 .skw-page__half--right .skw-page__content {
            background-image: url("../../../../img/kaka2.jpg");
        }
        .skw-page-3 .skw-page__half--left .skw-page__content {
            background-image: url("../../../../img/kaka3.jpg");
        }
        .skw-page-3 .skw-page__half--right .skw-page__content {
            background: #292929;
        }
        .skw-page-4 .skw-page__half--left .skw-page__content {
            background: #292929;
        }
        .skw-page-4 .skw-page__half--right .skw-page__content {
            background-image: url("../../../../img/kaka4.jpg");
        }
        .skw-page-5 .skw-page__half--left .skw-page__content {
            background-image: url("../../../../img/kaka5.jpg");
        }
        .skw-page-5 .skw-page__half--right .skw-page__content {
            background: #292929;
        }
    </style>

html部分:

<div class="skw-pages">
    <div class="skw-page skw-page-1 active">
        <div class="skw-page__half skw-page__half--left">
            <div class="skw-page__skewed">
                <div class="skw-page__content"></div>
            </div>
        </div>
        <div class="skw-page__half skw-page__half--right">
            <div class="skw-page__skewed">
                <div class="skw-page__content">
                    <h2 class="skw-page__heading">jQuery倾斜分割鼠标滚动切换代码</h2>
                    <p>适用浏览器:360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗. 不支持IE8及以下浏览器。</p>
                </div>
            </div>
        </div>
    </div>
    <div class="skw-page skw-page-2">
        <div class="skw-page__half skw-page__half--left">
            <div class="skw-page__skewed">
                <div class="skw-page__content">
                    <h2 class="skw-page__heading">Page 2</h2>
                    <p class="skw-page__description">Nothing to do here, continue scrolling.</p>
                </div>
            </div>
        </div>
        <div class="skw-page__half skw-page__half--right">
            <div class="skw-page__skewed">
                <div class="skw-page__content"></div>
            </div>
        </div>
    </div>
    <div class="skw-page skw-page-3">
        <div class="skw-page__half skw-page__half--left">
            <div class="skw-page__skewed">
                <div class="skw-page__content"></div>
            </div>
        </div>
        <div class="skw-page__half skw-page__half--right">
            <div class="skw-page__skewed">
                <div class="skw-page__content">
                    <h2 class="skw-page__heading">Page 3</h2>
                    <p class="skw-page__description">The end is near, I promise!</p>
                </div>
            </div>
        </div>
    </div>
    <div class="skw-page skw-page-4">
        <div class="skw-page__half skw-page__half--left">
            <div class="skw-page__skewed">
                <div class="skw-page__content">
                    <h2 class="skw-page__heading">Page 4</h2>
                    <p class="skw-page__description">Ok, ok, just one more scroll!</p>
                </div>
            </div>
        </div>
        <div class="skw-page__half skw-page__half--right">
            <div class="skw-page__skewed">
                <div class="skw-page__content"></div>
            </div>
        </div>
    </div>
    <div class="skw-page skw-page-5">
        <div class="skw-page__half skw-page__half--left">
            <div class="skw-page__skewed">
                <div class="skw-page__content"></div>
            </div>
        </div>
        <div class="skw-page__half skw-page__half--right">
            <div class="skw-page__skewed">
                <div class="skw-page__content">
                    <h2 class="skw-page__heading">Epic finale</h2>
                    <p class="skw-page__description">story the end!</p>
                </div>
            </div>
        </div>
    </div>
</div>

js部分:(此处需要引入jquery.js)

<<script type="text/javascript">
    $(document).ready(function () {
        var curPage = 1;
        var numOfPages = $(‘.skw-page‘).length;
        var animTime = 1000;
        var scrolling = false;
        var pgPrefix = ‘.skw-page-‘;
        function pagination() {
            scrolling = true;
            $(pgPrefix + curPage).removeClass(‘inactive‘).addClass(‘active‘);
            $(pgPrefix + (curPage - 1)).addClass(‘inactive‘);
            $(pgPrefix + (curPage + 1)).removeClass(‘active‘);
            setTimeout(function () {
                scrolling = false;
            }, animTime);
        }
        ;
        function navigateUp() {
            if (curPage === 1)
                return;
            curPage--;
            pagination();
        }
        ;
        function navigateDown() {
            if (curPage === numOfPages)
                return;
            curPage++;
            pagination();
        }
        ;
        $(document).on(‘mousewheel DOMMouseScroll‘, function (e) {
            if (scrolling)
                return;
            if (e.originalEvent.wheelDelta > 0 || e.originalEvent.detail < 0) {
                navigateUp();
            } else {
                navigateDown();
            }
        });
        $(document).on(‘keydown‘, function (e) {
            if (scrolling)
                return;
            if (e.which === 38) {
                navigateUp();
            } else if (e.which === 40) {
                navigateDown();
            }
        });
    });
</script>
时间: 2024-11-09 00:58:24

鼠标滚动倾斜分割切换的相关文章

滚动鼠标滚动,换页切换

效果类似这个网址所示:https://www.xyaz.cn/,网上也有这方面的插件,比如这个fullPage.js插件,https://alvarotrigo.com/fullPage/zh/#page1 我这个的是参考这位的:http://www.webfront-js.com/articaldetail/18.html.仅仅只是自己用作记录. 结构就是一个div作为容器,里面放要切换的页面. <!doctype html> <html lang="en">

15款fullpage.js鼠标滚动页面动画展示特效

jquery全屏鼠标滚动切换fullpage页面模板下载 html5响应式页面滚动背景图片动画特效 酷炫html5 css3全屏滚动动画专题模板 html5腾讯互动娱乐网站鼠标滚动展示模板 html5平安儿童手表页面滚动简约单页模板 html5叮咚手机app下载页面滚动展示特效 jquery fullPage证券股票软件页面滚屏动画特效 jquery.fullpage.js360安全路由全屏页面滚动效果 html5新年快乐医院专题页介绍模板下载 html5雷锋wifi软件介绍页面下滑滚动式特效

Duilib初级控件扩展一例: 具有鼠标滚动消息的OptionUI

当初之所以有这个想法, 是因为我想在Option上滚动鼠标的时候自动切换到前一个(或后一个)Option上面去. 所有的OptionUI在水平布局HorizontalLayout上面. 例子虽然能达到我要的前后的效果, 但是后来证明我错了, 试想想看, 为什么是让OptionUI来处理鼠标滚动消息, 让一个OptionUI处理鼠标滚动消息有啥意义? 明明该交给Option所在的水平布局来处理, 不是最好的选择吗? 的确是这样, 我当时就应该多想法再写的, 也可能是熟能生巧的原因吧, 以后注意了.

Winform 图片鼠标滚动查看(放大,缩小,旋转,拖动查看)[日常随笔]

方法千千万,我只是其中一笔[通过控制PictureBox来控制图片,图片完全施展在控件中]...几久不做,还真有点陌生! 窗体构造中添加鼠标滚动: 1 /// <summary> 2 /// 窗体构造方法 3 /// </summary> 4 public CandidateForm() 5 { 6 InitializeComponent(); 7 this.MouseWheel += new MouseEventHandler(CandidateForm_MouseWheel);

鼠标滚动事件

鼠标滚动事件 关于滚动事件这方面,其实是比较乱的. 滚轮事件的兼容性差异有些不拘一格,不是以往的IE8-派和其他派,而是FireFox派和其他派. 包括IE6在内的浏览器是使用onmousewheel,而FireFox浏览器一个人使用DOMMouseScroll. 经自己测试,即使现在FireFox 19下,也是不识onmousewheel. 在其他派中检测滚动数值的属性是wheelDelta ,向上滚为120,向下为-120. 在火狐中检测滚动数值的属性是detail,向上滚为-3,向下为3.

理解鼠标滚动事件

javascript<script> window.onload = function(){ var count = 0; document.onmousewheel = function(e){ /*鼠标滚动的量 下滚是负 上滚是正*/ if(e.wheelDelta < 0){ count ++; }else{ count --; } console.log(count); } }</script>``` #### 第二步 了解 fullpage jquery插件 >

CSS实现鼠标移动图片实现切换功能

CSS实现鼠标移动图片实现切换功能:当鼠标放在一个图片上的时候可以切换为其他图片,使用javascript可以实现,下面介绍一下如何使用CSS实现此功能.代码实例如下: <!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.softwhy.com/" />

基于jquery的鼠标滚动放大缩小图片

一直以来都想写一个图片放大和缩小的小玩意,本来以为会很复杂,这几天自己思考了一下,原来是so easy啊.目前实现的放大缩小,主要时依据鼠标的滚轮触发事件来实现的,废话少说直接上源码. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns

用AutoHotKey彻底解决“Ctrl键+鼠标滚动”时的缩放问题

“Ctrl键+鼠标滚动”会造成代码编辑窗口的字体缩放,这是自Visual Studio 2010以来引入的一个新特性,也是一个恼人的问题,详见VS2010中尴尬的代码窗口缩放功能. 于是,每次安装Visual Studio,首先安装的插件就是 Disable Mouse Wheel Zoom ,禁用这个特性. 但是,最近在用Visual Studio 2015 Preview,这个插件还不支持VS 2015,不得不饱受这个问题的折磨.今天(12月10日)实在忍无可忍,下定决心解决这个问题. 后来