如何在侧边栏 bootstrap 中倾斜背景?

how to skew the background in sidebar bootstrap?

我在 bootstrap 中使用左侧边栏,我想倾斜背景,我的问题是填充处于活动状态时,我解决了它。 有时候小东西是看不到的!

/* Side Menu */

#sidebar-wrapper {
    z-index: 1000;
    position: fixed;
    left: 0;
    width: 550px;
    height: 100%;
    margin-left: -270px;
    overflow: hidden;
    background: #222;
 transform:skew(-30deg);
    -webkit-transition: all 0.4s ease 0s;
    -moz-transition: all 0.4s ease 0s;
    -ms-transition: all 0.4s ease 0s;
    -o-transition: all 0.4s ease 0s;
    transition: all 0.4s ease 0s;
}

.sidebar-nav {
    position: absolute;
    top: 50px;
    width: 550px;
    margin: 0px;
    padding: 0 0 0 100px;
    list-style: none;
 transform:skew(30deg);
}


.sidebar-nav li {
    text-indent: 20px;
    line-height: 40px;
}

.sidebar-nav li a {
    display: block;
    text-decoration: none;
    color: #999;
}

.sidebar-nav li a:hover {
    text-decoration: none;
    color: #fff;
}

.sidebar-nav li a:active,
.sidebar-nav li a:focus {
    text-decoration: none;
}

.sidebar-nav > .sidebar-brand {
    height: 55px;
    font-size: 18px;
    line-height: 55px;
}

.sidebar-nav > .sidebar-brand a {
    color: #999;
}

.sidebar-nav > .sidebar-brand a:hover {
    color: #fff;
    background: none;
}

#menu-toggle {
    z-index: 1;
    position: fixed;
    top: 0;
    left: 0;
}

#sidebar-wrapper.active {
    left: -280px;
    width: 250px;
    -webkit-transition: all 0.4s ease 0s;
    -moz-transition: all 0.4s ease 0s;
    -ms-transition: all 0.4s ease 0s;
    -o-transition: all 0.4s ease 0s;
    transition: all 0.4s ease 0s;
}
.btn dropdown-toggle toggle{ color:red; font-size:30px}
.btn btn-dark btn-lg toggle:hover{ color:#c32227; font-size:30px}
.toggle {
    margin: 5px 5px 0 0;
}
    <a id="menu-toggle" href="#" class="btn btn-lg toggle"><i class="btn glyphicon glyphicon-th-large toggle"></i></a>
    <nav id="sidebar-wrapper">
        <ul class="sidebar-nav">
            <a id="menu-close" href="#" class="btn pull-right toggle"><i class="glyphicon glyphicon-th-large"></i></a>
            <li>
                <a href="#top" onclick = $("#menu-close").click(); >Home</a>
            </li>
            <li>
                <a href="#about" onclick = $("#menu-close").click(); >About</a>
            </li>
            <li>
                <a href="#services" onclick = $("#menu-close").click(); >Services</a>
            </li>
            <li>
                <a href="#portfolio" onclick = $("#menu-close").click(); >Portfolio</a>
            </li>
            <li>
                <a href="#contact" onclick = $("#menu-close").click(); >Contact</a>
            </li>
        </ul>
    </nav>

http://codepen.io/anon/pen/GJePqjsample

[这是一个示例][2]

我想你在找这个,

$(function() {    
    $("#menu-close").click(function(e) {
        e.preventDefault();
        $("#sidebar-wrapper").toggleClass("active");
    });

    // Opens the sidebar menu
    $("#menu-toggle").click(function(e) {
        e.preventDefault();
        $("#sidebar-wrapper").toggleClass("active");
    });

// Scrolls to the selected menu item on the page

    $('a[href*=#]:not([href=#])').click(function() {
        if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') || location.hostname == this.hostname) {

            var target = $(this.hash);
            target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
            if (target.length) {
                $('html,body').animate({
                    scrollTop: target.offset().top
                }, 1000);
                return false;
            }
        }
    });

});  
/* Side Menu */

    #sidebar-wrapper {
z-index: 1000;
position: fixed;
left: 0;
width: 550px;
height: 100%;
margin-left: -270px;
overflow: hidden;
background: #222;
transform:skew(-30deg);
-webkit-transition: all 0.4s ease 0s;
-moz-transition: all 0.4s ease 0s;
-ms-transition: all 0.4s ease 0s;
-o-transition: all 0.4s ease 0s;
transition: all 0.4s ease 0s;
}

.sidebar-nav {
    position: absolute;
    top: 50px;
    width: 550px;
    margin: 0px;
    padding: 0 0 0 100px;
    list-style: none;
    transform:skew(30deg);
}


.sidebar-nav li {
    text-indent: 20px;
    line-height: 40px;
}

.sidebar-nav li a {
    display: block;
    text-decoration: none;
    color: #999;
}

.sidebar-nav li a:hover {
    text-decoration: none;
    color: #fff;
}

.sidebar-nav li a:active,
.sidebar-nav li a:focus {
    text-decoration: none;
}

.sidebar-nav > .sidebar-brand {
    height: 55px;
    font-size: 18px;
    line-height: 55px;
}

.sidebar-nav > .sidebar-brand a {
    color: #999;
}

.sidebar-nav > .sidebar-brand a:hover {
    color: #fff;
    background: none;
}

#menu-toggle {
    z-index: 1;
    position: fixed;
    top: 0;
    left: 0;
}

#sidebar-wrapper.active {
    left: -280px;
    width: 250px;
    -webkit-transition: all 0.4s ease 0s;
    -moz-transition: all 0.4s ease 0s;
    -ms-transition: all 0.4s ease 0s;
    -o-transition: all 0.4s ease 0s;
    transition: all 0.4s ease 0s;
}
.btn dropdown-toggle toggle{ color:red; font-size:30px}
.btn btn-dark btn-lg toggle:hover{ color:#c32227; font-size:30px}
.toggle {
    margin: 5px 5px 0 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<a id="menu-toggle" href="#" class="btn btn-lg toggle"><i class="btn glyphicon glyphicon-th-large toggle"></i></a>
<nav id="sidebar-wrapper">
    <ul class="sidebar-nav">
        <a id="menu-close" href="#" class="btn pull-right toggle"><i class="glyphicon glyphicon-th-large"></i></a>
        <li>
            <a href="#top" onclick = $("#menu-close").click(); >Home</a>
        </li>
        <li>
            <a href="#about" onclick = $("#menu-close").click(); >About</a>
        </li>
        <li>
            <a href="#services" onclick = $("#menu-close").click(); >Services</a>
        </li>
        <li>
            <a href="#portfolio" onclick = $("#menu-close").click(); >Portfolio</a>
        </li>
        <li>
            <a href="#contact" onclick = $("#menu-close").click(); >Contact</a>
        </li>
    </ul>
</nav>

祝你好运['}

/* Side Menu */

#sidebar-wrapper {
    z-index: 1000;
    position: fixed;
    left: 0;
    width: 550px;
    height: 100%;
    margin-left: -270px;
    overflow: hidden;
    background: #222;
 transform:skew(-30deg);
    -webkit-transition: all 0.4s ease 0s;
    -moz-transition: all 0.4s ease 0s;
    -ms-transition: all 0.4s ease 0s;
    -o-transition: all 0.4s ease 0s;
    transition: all 0.4s ease 0s;
}

.sidebar-nav {
    position: absolute;
    top: 50px;
    width: 550px;
    margin: 0px;
    padding: 0 0 0 100px;
    list-style: none;
 transform:skew(30deg);
}


.sidebar-nav li {
    text-indent: 20px;
    line-height: 40px;
}

.sidebar-nav li a {
    display: block;
    text-decoration: none;
    color: #999;
}

.sidebar-nav li a:hover {
    text-decoration: none;
    color: #fff;
}

.sidebar-nav li a:active,
.sidebar-nav li a:focus {
    text-decoration: none;
}

.sidebar-nav > .sidebar-brand {
    height: 55px;
    font-size: 18px;
    line-height: 55px;
}

.sidebar-nav > .sidebar-brand a {
    color: #999;
}

.sidebar-nav > .sidebar-brand a:hover {
    color: #fff;
    background: none;
}

#menu-toggle {
    z-index: 1;
    position: fixed;
    top: 0;
    left: 0;
}

#sidebar-wrapper.active {
    left: -280px;
    width: 250px;
    -webkit-transition: all 0.4s ease 0s;
    -moz-transition: all 0.4s ease 0s;
    -ms-transition: all 0.4s ease 0s;
    -o-transition: all 0.4s ease 0s;
    transition: all 0.4s ease 0s;
}
.btn dropdown-toggle toggle{ color:red; font-size:30px}
.btn btn-dark btn-lg toggle:hover{ color:#c32227; font-size:30px}
.toggle {
    margin: 5px 5px 0 0;
}
    <a id="menu-toggle" href="#" class="btn btn-lg toggle"><i class="btn glyphicon glyphicon-th-large toggle"></i></a>
    <nav id="sidebar-wrapper">
        <ul class="sidebar-nav">
            <a id="menu-close" href="#" class="btn pull-right toggle"><i class="glyphicon glyphicon-th-large"></i></a>
            <li>
                <a href="#top" onclick = $("#menu-close").click(); >Home</a>
            </li>
            <li>
                <a href="#about" onclick = $("#menu-close").click(); >About</a>
            </li>
            <li>
                <a href="#services" onclick = $("#menu-close").click(); >Services</a>
            </li>
            <li>
                <a href="#portfolio" onclick = $("#menu-close").click(); >Portfolio</a>
            </li>
            <li>
                <a href="#contact" onclick = $("#menu-close").click(); >Contact</a>
            </li>
        </ul>
    </nav>