Search code examples
csstwitter-bootstrap-3sidebar

how to skew the background in sidebar bootstrap?


I'm using a left sidebar in bootstrap and i wanted to skew the background, my problem was with the padding when it was active, and I solved it. sometimes little things can't be seen!

/* 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

[here's a sample][2]


Solution

  • /* 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>