页面内容没有更改下拉列表?

问题描述 投票:0回答:1

我想设置页面显示:相对于下拉列表。当它处于活动状态时>意味着当我点击下拉主按钮查看它列表时。该页面的其他内容将随之改变。喜欢=> Something like that

enter image description here

我想要上面的东西,但不能这样做,我到目前为止所做的工作......

enter image description here

enter image description here

看我的其他页面内容在列表后面...但我想要一些像我的上面的2张图...

我的HTML ..>

        <div id="guts">
        <div style="margin-right: 84%;margin-top: 1%;" class="wrapper-demo">
            <div style="width: 300px;" id="dd" class="wrapper-dropdown-5 active" tabindex="1"><img style="margin-bottom: -2px;" height="15px" width="15px" src="../ico/1490619478_ic_dashboard_48px.ico" />     Dashboard
                <ul class="dropdown">
                    <li><a href="#"><i class="icon-user"></i>Home</a></li>
                    <li><a href="#"><i class="icon-cog"></i>My Profile</a></li>
                    <li><a href="#"><i class="icon-remove"></i>My Applied Batches</a></li>
                    <li><a href="#"><i class="icon-remove"></i>Offer Courses</a></li>
                    <li><a href="#"><i class="icon-remove"></i>Deadlines</a></li>
                </ul>
            </div>
        ​</div>
        <h2>Hi</h2>
        <h2>Hi</h2>
        <h2>Hi</h2>
    </div>

和js - >

            function DropDown(el) {
            this.dd = el;
            this.initEvents();
        }
        DropDown.prototype = {
            initEvents : function() {
                var obj = this;

                obj.dd.on('click', function(event){
                    $(this).toggleClass('active');
                    event.stopPropagation();
                }); 
            }
        }

        $(function() {

            var dd = new DropDown( $('#dd') );

            $(document).click(function() {
                // all dropdowns
                $('.wrapper-dropdown-5').removeClass('active');
            });

        });

和css ..>

@import url('demo.css');
        @import url('font-awesome.css');

        /* GLOBALS */

        *,
        *:after,
        *:before {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            padding: 0;
            margin: 0;
        }

        ::selection {
            background: transparent; 
        }

        ::-moz-selection {
            background: transparent; 
        }

        .wrapper-demo {
            margin: 60px 0 0 0;
            *zoom: 1;
            font-weight: 400;
        }

        .wrapper-demo:after {
            clear: both;
            content: "";
            display: table;
        }

        /* DEMO 1 */

        .wrapper-dropdown-1 {
            /* Size and position */
            position: relative; /* Enable absolute positionning for children and pseudo elements */
            width: 200px;
            padding: 10px;
            margin: 0 auto;

            /* Styles */
            background: #9bc7de;
            color: #fff;
            outline: none;
            cursor: pointer;

            /* Font settings */
            font-weight: bold;
        }

        .wrapper-dropdown-1:after {
            content: "";
            width: 0;
            height: 0;
            position: absolute;
            right: 16px;
            top: 50%;
            margin-top: -6px;
            border-width: 6px 0 6px 6px;
            border-style: solid;
            border-color: transparent #fff;    
        }

        .wrapper-dropdown-1 .dropdown {
            /* Size & position */
            position: absolute;
            top: 100%;
            left: 0;
            right: 0;

            /* Styles */
            background: #fff;
            list-style: none;
            font-weight: normal; /* Cancels previous font-weight: bold; */

            /* Hiding */
            opacity: 0;
            pointer-events: none;
        }

        .wrapper-dropdown-1 .dropdown li a {
            display: block;
            text-decoration: none;
            color: #9e9e9e;
            padding: 10px 20px;
        }

        /* Hover state */
        .wrapper-dropdown-1 .dropdown li:hover a {
            background: #f3f8f8;
        }

        /* Active state */
        .wrapper-dropdown-1.active .dropdown {
            opacity: 1;
            pointer-events: auto;
        }

        .wrapper-dropdown-1.active:after {
            border-color: #9bc7de transparent;
            border-width: 6px 6px 0 6px ;
            margin-top: -3px;
        }

        .wrapper-dropdown-1.active {
          background: #9bc7de;
          background: -moz-linear-gradient(left,  #9bc7de 0%, #9bc7de 78%, #ffffff 78%, #ffffff 100%);
          background: -webkit-gradient(linear, left top, right top, color-stop(0%,#9bc7de), color-stop(78%,#9bc7de), color-stop(78%,#ffffff), color-stop(100%,#ffffff));
          background: -webkit-linear-gradient(left,  #9bc7de 0%,#9bc7de 78%,#ffffff 78%,#ffffff 100%);
          background: -o-linear-gradient(left,  #9bc7de 0%,#9bc7de 78%,#ffffff 78%,#ffffff 100%);
          background: -ms-linear-gradient(left,  #9bc7de 0%,#9bc7de 78%,#ffffff 78%,#ffffff 100%);
          background: linear-gradient(to right,  #9bc7de 0%,#9bc7de 78%,#ffffff 78%,#ffffff 100%);
          filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#9bc7de', endColorstr='#ffffff',GradientType=1 );
        }

        /* No CSS3 support */

        .no-opacity       .wrapper-dropdown-1 .dropdown,
        .no-pointerevents .wrapper-dropdown-1 .dropdown {
            display: none;
            opacity: 1; /* If opacity support but no pointer-events support */
            pointer-events: auto; /* If pointer-events support but no pointer-events support */
        }

        .no-opacity       .wrapper-dropdown-1.active .dropdown,
        .no-pointerevents .wrapper-dropdown-1.active .dropdown {
            display: block;
        }

        /* DEMO 2 */

        .wrapper-dropdown-2 {
            /* Size and position */
            position: relative; /* Enable absolute positionning for children and pseudo elements */
            width: 200px;
            margin: 0 auto;
            padding: 10px 15px;

            /* Styles */
            background: #fff;
            border-left: 5px solid grey;
            cursor: pointer;
            outline: none;
        }

        .wrapper-dropdown-2:after {
            content: "";
            width: 0;
            height: 0;
            position: absolute;
            right: 16px;
            top: 50%;
            margin-top: -3px;
            border-width: 6px 6px 0 6px;
            border-style: solid;
            border-color: grey transparent;
        }

        .wrapper-dropdown-2 .dropdown {
          /* Size & position */
            position: absolute;
            top: 100%;
            left: -5px;
            right: 0px;

            /* Styles */
            background: white;
            -webkit-transition: all 0.3s ease-out;
            -moz-transition: all 0.3s ease-out;
            -ms-transition: all 0.3s ease-out;
            -o-transition: all 0.3s ease-out;
            transition: all 0.3s ease-out;
            list-style: none;

            /* Hiding */
            opacity: 0;
            pointer-events: none;
        }

        .wrapper-dropdown-2 .dropdown li a {
            display: block;
            text-decoration: none;
            color: #333;
            border-left: 5px solid;
            padding: 10px;
            -webkit-transition: all 0.3s ease-out;
            -moz-transition: all 0.3s ease-out;
            -ms-transition: all 0.3s ease-out;
            -o-transition: all 0.3s ease-out;
            transition: all 0.3s ease-out;
        }

        .wrapper-dropdown-2 .dropdown li:nth-child(1) a { 
            border-left-color: #00ACED;
        }

        .wrapper-dropdown-2 .dropdown li:nth-child(2) a {
            border-left-color: #4183C4;
        }

        .wrapper-dropdown-2 .dropdown li:nth-child(3) a {
            border-left-color: #3B5998;
        }

        .wrapper-dropdown-2 .dropdown li i {
            margin-right: 5px;
            color: inherit;
            vertical-align: middle;
        }

        /* Hover state */

        .wrapper-dropdown-2 .dropdown li:hover a {
            color: grey;
        }

        /* Active state */

        .wrapper-dropdown-2.active:after {
            border-width: 0 6px 6px 6px;
        }

        .wrapper-dropdown-2.active .dropdown {
            opacity: 1;
            pointer-events: auto;
        }

        /* No CSS3 support */

        .no-opacity       .wrapper-dropdown-2 .dropdown,
        .no-pointerevents .wrapper-dropdown-2 .dropdown {
            display: none;
            opacity: 1; /* If opacity support but no pointer-events support */
            pointer-events: auto; /* If pointer-events support but no pointer-events support */
        }

        .no-opacity       .wrapper-dropdown-2.active .dropdown,
        .no-pointerevents .wrapper-dropdown-2.active .dropdown {
            display: block;
        }

        /* DEMO 3 */

        .wrapper-dropdown-3 {
            /* Size and position */
            position: absolute;
            width: 200px;
            margin: 0 auto;
            padding: 10px;

            /* Styles */
            background: #fff;
            border-radius: 7px;
            border: 1px solid rgba(0,0,0,0.15);
            box-shadow: 0 1px 1px rgba(50,50,50,0.1);
            cursor: pointer;
            outline: none;

            /* Font settings */
            font-weight: bold;
            color: #8AA8BD;
        }

        .wrapper-dropdown-3:after {
            content: "";
            width: 0;
            height: 0;
            position: absolute;
            right: 15px;
            top: 50%;
            margin-top: -3px;
            border-width: 6px 6px 0 6px;
            border-style: solid;
            border-color: #8aa8bd transparent;
        }

        .wrapper-dropdown-3 .dropdown {
          /* Size & position */
            position: absolute;
            top: 140%;
            left: 0;
            right: 0;

            /* Styles */
            background: white;
            border-radius: inherit;
            border: 1px solid rgba(0,0,0,0.17);
            box-shadow: 0 0 5px rgba(0,0,0,0.1);
            font-weight: normal;
            -webkit-transition: all 0.5s ease-in;
            -moz-transition: all 0.5s ease-in;
            -ms-transition: all 0.5s ease-in;
            -o-transition: all 0.5s ease-in;
            transition: all 0.5s ease-in;
            list-style: none;

            /* Hiding */
            opacity: 0;
            pointer-events: none;
        }

        .wrapper-dropdown-3 .dropdown:after {
            content: "";
            width: 0;
            height: 0;
            position: absolute;
            bottom: 100%;
            right: 15px;
            border-width: 0 6px 6px 6px;
            border-style: solid;
            border-color: #fff transparent;    
        }

        .wrapper-dropdown-3 .dropdown:before {
            content: "";
            width: 0;
            height: 0;
            position: absolute;
            bottom: 100%;
            right: 13px;
            border-width: 0 8px 8px 8px;
            border-style: solid;
            border-color: rgba(0,0,0,0.1) transparent;    
        }

        .wrapper-dropdown-3 .dropdown li a {
            display: block;
            padding: 10px;
            text-decoration: none;
            color: #8aa8bd;
            border-bottom: 1px solid #e6e8ea;
            box-shadow: inset 0 1px 0 rgba(255,255,255,1);
            -webkit-transition: all 0.3s ease-out;
            -moz-transition: all 0.3s ease-out;
            -ms-transition: all 0.3s ease-out;
            -o-transition: all 0.3s ease-out;
            transition: all 0.3s ease-out;
        }

        .wrapper-dropdown-3 .dropdown li i {
            float: right;
            color: inherit;
        }

        .wrapper-dropdown-3 .dropdown li:first-of-type a {
            border-radius: 7px 7px 0 0;
        }

        .wrapper-dropdown-3 .dropdown li:last-of-type a {
            border: none;
            border-radius: 0 0 7px 7px;
        }

        /* Hover state */

        .wrapper-dropdown-3 .dropdown li:hover a {
            background: #f3f8f8;
        }

        /* Active state */

        .wrapper-dropdown-3.active .dropdown {
            opacity: 1;
            pointer-events: auto;
        }

        /* No CSS3 support */

        .no-opacity       .wrapper-dropdown-3 .dropdown,
        .no-pointerevents .wrapper-dropdown-3 .dropdown {
            display: none;
            opacity: 1; /* If opacity support but no pointer-events support */
            pointer-events: auto; /* If pointer-events support but no pointer-events support */
        }

        .no-opacity       .wrapper-dropdown-3.active .dropdown,
        .no-pointerevents .wrapper-dropdown-3.active .dropdown {
            display: block;
        }


        /* DEMO 4 */

        .wrapper-dropdown-4 {
            /* Size and position */
            position: absolute;
            width: 270px;
            margin: 0 auto;
            padding: 10px 10px 10px 30px;

            /* Styles */
            background: #fff;
            border: 1px solid silver;
            cursor: pointer;
            outline: none;
        }

        .wrapper-dropdown-4:after {
            content: "";
            width: 0;
            height: 0;
            position: absolute;
            right: 10px;
            top: 50%;
            margin-top: -3px;
            border-width: 6px 6px 0 6px;
            border-style: solid;
            border-color: #ffaa9f transparent;
        }

        .wrapper-dropdown-4 .dropdown {
            /* Size & position */
            position: absolute;
            top: 100%;
            margin-top: 1px;
            left: -1px;
            right: -1px;

            /* Styles */
            background: white;
            border: inherit;
            border-top: none;
            list-style: none;
            -webkit-transition: all 0.3s ease-out;
            -moz-transition: all 0.3s ease-out;
            -ms-transition: all 0.3s ease-out;
            -o-transition: all 0.3s ease-out;
            transition: all 0.3s ease-out;

            /* Hiding */
            opacity: 0;
            pointer-events: none;
        }

        /* Red lines: the pseudo-elements way */
        .wrapper-dropdown-4 .dropdown:before,
        .wrapper-dropdown-4:before {
            content: "";
            width: 4px;
            height: 100%;
            position: absolute;
            top: 0;
            left: 15px;
            border: 1px solid #ffaa9f;
            border-top: none;
            border-bottom: none;
            z-index: 2;
        }

        /* Red lines: the gradients way */

        /*
        .wrapper-dropdown-4 .dropdown,
        .wrapper-dropdown-4 {
          background: linear-gradient(left, white 5%, #ffaa9f 5%, #ffaa9f 5.3%, white 5.3%, white 6.5%, #ffaa9f 6.5%, #ffaa9f 6.8%, white 6.8%);
        }

        .wrapper-dropdown-4 .dropdown li:hover label {
          background: linear-gradient(left, #f0F0F0 5%, #ffaa9f 5%, #ffaa9f 5.3%, #f0F0F0 5.3%, #f0F0F0 6.5%, #ffaa9f 6.5%, #ffaa9f 6.8%, #f0F0F0 6.8%);
        }
        */

        .wrapper-dropdown-4 .dropdown li {
            position: relative; /* Enable absolute positioning for checkboxes */
        }

        .wrapper-dropdown-4 .dropdown li label {
            display: block;
            padding: 10px 10px 10px 30px; /* Same padding as the button */
            border-bottom: 1px dotted #1ccfcf;
            -webkit-transition: all 0.3s ease-out;
            -moz-transition: all 0.3s ease-out;
            -ms-transition: all 0.3s ease-out;
            -o-transition: all 0.3s ease-out;
            transition: all 0.3s ease-out;
        }

        .wrapper-dropdown-4 .dropdown li:last-of-type label {
            border: none;
        }

        .wrapper-dropdown-4 .dropdown li input /* Checkboxes */ {
            position: absolute;
            display: block;
            right: 10px;
            top: 50%;
            margin-top: -8px;
        }

        /* Hover state */

        .wrapper-dropdown-4 .dropdown li:hover label {
            background: #f0f0f0;
        }

        /* Checked state */

        .wrapper-dropdown-4 .dropdown li input:checked ~ label {
            color: grey;
            text-decoration: line-through;
        }

        /* Active state */

        .wrapper-dropdown-4.active:after {
            border-width: 0 6px 6px 6px;
        }

        .wrapper-dropdown-4.active .dropdown {
            opacity: 1;
            pointer-events: auto;
        }

        /* No CSS3 support */

        .no-opacity       wrapper-dropdown-4 .dropdown,
        .no-pointerevents .wrapper-dropdown-4 .dropdown {
            display: none;
            opacity: 1; /* If opacity support but no pointer-events support */
            pointer-events: auto; /* If pointer-events support but no pointer-events support */
        }

        .no-opacity       .wrapper-dropdown-4.active .dropdown,
        .no-pointerevents .wrapper-dropdown-4.active .dropdown {
            display: block;
        }

        /* DEMO 5 */

        .wrapper-dropdown-5 {
            /* Size & position */
            position: relative;
            width: 200px;
            margin: 0 auto;
            padding: 12px 15px;

            /* Styles */
            background: #fff;
            border-radius: 5px;
            box-shadow: 0 1px 0 rgba(0,0,0,0.2);
            cursor: pointer;
            outline: none;
            -webkit-transition: all 0.3s ease-out;
            -moz-transition: all 0.3s ease-out;
            -ms-transition: all 0.3s ease-out;
            -o-transition: all 0.3s ease-out;
            transition: all 0.3s ease-out;
        }

        .wrapper-dropdown-5:after { /* Little arrow */
            content: "";
            width: 0;
            height: 0;
            position: absolute;
            top: 50%;
            right: 15px;
            margin-top: -3px;
            border-width: 6px 6px 0 6px;
            border-style: solid;
            border-color: #4cbeff transparent;
        }

        .wrapper-dropdown-5 .dropdown {
            /* Size & position man */
            position: absolute;
            top: 100%;
            left: 0;
            right: 0;

            /* Styles */
            background: #fff;
            border-radius: 0 0 5px 5px;
            border: 1px solid rgba(0,0,0,0.2);
            border-top: none;
            border-bottom: none;
            list-style: none;
            -webkit-transition: all 0.3s ease-out;
            -moz-transition: all 0.3s ease-out;
            -ms-transition: all 0.3s ease-out;
            -o-transition: all 0.3s ease-out;
            transition: all 0.3s ease-out;

            /* Hiding */
            max-height: 0;
            overflow: hidden;
        }

        .wrapper-dropdown-5 .dropdown li {
            padding: 0 10px ;
        }

        .wrapper-dropdown-5 .dropdown li a {
            display: block;
            text-decoration: none;
            color: #333;
            padding: 10px 0;
            transition: all 0.3s ease-out;
            /*border-bottom: 1px solid #e6e8ea;*/
        }

        .wrapper-dropdown-5 .dropdown li:last-of-type a {
            border: none;
        }

        .wrapper-dropdown-5 .dropdown li i {
            margin-right: 5px;
            color: inherit;
            vertical-align: middle;
        }

        /* Hover state */

        .wrapper-dropdown-5 .dropdown li:hover a {
            color: #57a9d9;
        }

        /* Active state */

        .wrapper-dropdown-5.active {
            border-radius: 5px 5px 0 0;
            background: #4cbeff;
            box-shadow: none;
            border-bottom: none;
            color: white;
        }

        .wrapper-dropdown-5.active:after {
            border-color: #82d1ff transparent;
        }

        .wrapper-dropdown-5.active .dropdown {
            border-bottom: 1px solid rgba(0,0,0,0.2);
            max-height: 400px;
        }

        /* No CSS3 support: none */

你需要添加jquery来测试代码......

我认为这对html和js没有问题,只有css.so css专家请帮助我。看到一个大代码后就跑掉了......是css ...

jquery html css
1个回答
0
投票

如果是margin-bottom状态,只需将active添加到您的下拉类中。以下代码应解决此问题:

    .wrapper-dropdown-5.active {
        border-radius: 5px 5px 0 0;
        background: #4cbeff;
        box-shadow: none;
        border-bottom: none;
        color: white;
        margin-bottom: 200px;
    }

试过这个,它的确有效。调整底部边距的值以满足您的需要。希望这可以帮助。

© www.soinside.com 2019 - 2024. All rights reserved.