I used Skrollr library to create parallax effect for the background. However, when skillor.init() is called, the body height is too high and create extra space below in the page.
The problem can be seen here:
http://codepen.io/designil/pen/Ggxde
HTML:
<div class="headrow">
<div class="container">
<div class="row">
<div class="col-md-3">
<h1 class="logo">21GUNS</h1>
</div>
<div class="col-md-9">
<div class="topmenu">
<p>
<i class="fa fa-twitter"></i>
<i class="fa fa-facebook"></i>
<i class="fa fa-linkedin"></i>
<i class="fa fa-pinterest"></i>
</p>
<ul class="list-unstyled">
<li>
<div class="dropdown">
<a data-toggle="dropdown" href="#">MENU 1</a>
<ul class="dropdown-menu" role="menu">
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here</a></li>
<li role="presentation" class="divider"></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li>
</ul>
</div>
</li>
<li>
MENU 2
</li>
<li>
MENU 3
</li>
<li>
MENU 4
</li>
<li>
MENU 5
</li>
</ul>
</div>
</div>
</div>
</div>
</div><!-- headrow -->
<div class="bannerrow">
<img src="http://placehold.it/1800x600" alt="" />
</div>
<div class="servicerow" data-top-bottom="background-position: 50% 75%;" data-bottom-top="background-position: 50% 100%;">
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3 text-center">
<header>
<h2>21SERVICES</h2>
<p>Drive next-generation technologies vortals engage, systems services dynamic to our clients.</p>
</header>
</div>
</div><!-- row -->
<div class="row">
<div class="col-md-5">
<div class="column2-box">
<i class="fa fa-gift fa-fw"></i>
<h3>FLAT DESIGN</h3>
<p>End-to-end, user-centred web-readiness cultivate granular drive convergence.</p>
</div>
</div>
<div class="col-md-5 col-md-offset-2">
<div class="column2-box">
<i class="fa fa-gift fa-fw"></i>
<h3>FLAT DESIGN</h3>
<p>End-to-end, user-centred web-readiness cultivate granular drive convergence.</p>
</div>
</div>
</div><!-- row -->
<div class="row">
<div class="col-md-5">
<div class="column2-box">
<i class="fa fa-gift fa-fw"></i>
<h3>FLAT DESIGN</h3>
<p>End-to-end, user-centred web-readiness cultivate granular drive convergence.</p>
</div>
</div>
<div class="col-md-5 col-md-offset-2">
<div class="column2-box">
<i class="fa fa-gift fa-fw"></i>
<h3>FLAT DESIGN</h3>
<p>End-to-end, user-centred web-readiness cultivate granular drive convergence.</p>
</div>
</div>
</div><!-- row -->
</div>
</div>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.1/css/font-awesome.min.css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/skrollr/0.6.11/skrollr.min.js"></script>
CSS:
#blue: #293448;
#red: #C1392B;
#import url(http://fonts.googleapis.com/css?family=Open+Sans);
body {
font-family: 'Open Sans', sans-serif;
}
.headrow {
background: #blue;
}
.logo a {
color: #fff;
transition: 0.3s;
&:hover {
text-decoration: none;
color: #eee;
}
}
.topmenu {
text-align: right;
p {
margin-top: 10px;
a {
display: inline-block;
margin: 0 5px;
text-align: right;
}
}
ul {
margin-bottom: 0;
}
li {
display: inline-block;
margin-left: 30px;
a {
color: #eee;
display: block;
padding-bottom: 10px;
border-bottom: 3px solid transparent;
transition: 0.3s;
}
a:hover {
text-decoration: none;
border-bottom: 3px solid #red;
}
.dropdown-menu {
text-align: left;
li {
margin: 0;
display: block;
}
a:hover {
background: #ccc;
}
a {
color: #blue;
border: 0;
transition: 0;
}
}
}
}
.bannerrow {
img { width: 100%; height: auto;}
}
.servicerow {
color: #fff;
padding-bottom: 100px;
background: url(http://i.imgur.com/pIaoyxQ.jpg) no-repeat;
background-size: cover;
header {
margin-top: 60px;
margin-bottom: 20px;
h2 { margin-bottom: 10px; }
p { font-size: 13pt; }
}
}
.column2-box {
border: 1px solid #ddd;
padding: 10px;
margin: 15px 0;
i { font-size: 110px; float: left; }
h3 { margin-top: 0; }
}
JS:
$(function() {
$('.dropdown-toggle').dropdown();
$('.dropdown').hover(function() {
$(this).find('.dropdown-menu').stop(true, true).delay(200).fadeIn(200);
}, function() {
$(this).find('.dropdown-menu').stop(true, true).delay(200).fadeOut(200);
});
var s = skrollr.init({forceHeight: false});
});
I am not sure which element makes the page too high.
skrollr.init({forceHeight: false});
https://github.com/Prinzhorn/skrollr#forceheighttrue
Skrollr makes sure you can actually reach data-bottom-top. As you can see, the gap allows the element's bottom to be perfectly aligned with the top of the viewport.
Related
I have hamburger menu and added click to open a sub menu and after that struggling to close the sub-menu, please check the detailed code below. Thanks...!!
function myFunction() {
document.getElementById("mob").style.display = "inline-flex";
document.getElementById("mob").style.position = "absolute";
}
.hamburger {
width: 35px;
height: 5px;
background-color: #f7941e;
margin: 6px 0;
}
.mobile-menu {
display: none;
}
.hamburger-container {
cursor: pointer;
}
<div class="mobile-navbar">
<div class="hamburger-container" onclick="myFunction()">
<div class="hamburger"></div>
<div class="hamburger"></div>
<div class="hamburger"></div>
<div class="mobile-menu" id="mob">
<ul class="mobile-menu-container">
<li class="mobile-menu-items">Home</li>
<li class="mobile-menu-items">Types Tours
<div class="mobile-types-sub-menu">
<ul class="mobile-types-sub-menu-items">
<li>test-1</li>
<li>test-2</li>
<li>test-3</li>
</ul>
</div>
</li>
<li class="mobile-menu-items">The regions</li>
<li class="mobile-menu-items">Instructors</li>
<li class="mobile-menu-items">Questions / Answers</li>
<li class="mobile-menu-items">Contacts</li>
</ul>
</div>
</div>
</div>
Toggle the class active on the #mob element, adding the CSS attributes you added in your function.
function myFunction() {
const toggle_btn = document.getElementById('mob');
toggle_btn.classList.toggle('active');
}
.hamburger {
width: 35px;
height: 5px;
background-color: #f7941e;
margin: 6px 0;
}
.mobile-menu {
display: none;
}
.hamburger-container {
cursor: pointer;
}
#mob.active {
display: inline-flex;
position: absolute;
}
<div class="mobile-navbar">
<div class="hamburger-container" onclick="myFunction()">
<div class="hamburger"></div>
<div class="hamburger"></div>
<div class="hamburger"></div>
<div class="mobile-menu" id="mob">
<ul class="mobile-menu-container">
<li class="mobile-menu-items">Home</li>
<li class="mobile-menu-items">Types Tours
<div class="mobile-types-sub-menu">
<ul class="mobile-types-sub-menu-items">
<li>test-1</li>
<li>test-2</li>
<li>test-3</li>
</ul>
</div>
</li>
<li class="mobile-menu-items">The regions</li>
<li class="mobile-menu-items">Instructors</li>
<li class="mobile-menu-items">Questions / Answers</li>
<li class="mobile-menu-items">Contacts</li>
</ul>
</div>
</div>
</div>
Create a hidden class and use toggle function to add or remove it
const myFunction = () => document.getElementById("mob").classList.toggle("hidden");
.hamburger {
width: 35px;
height: 5px;
background-color: #f7941e;
margin: 6px 0;
}
.mobile-menu {
display: inline-flex;
position: absolute;
}
.mobile-menu.hidden {
display: none;
}
.hamburger-container {
cursor: pointer;
}
<div class="mobile-navbar">
<div class="hamburger-container" onclick="myFunction()">
<div class="hamburger"></div>
<div class="hamburger"></div>
<div class="hamburger"></div>
<div class="mobile-menu hidden" id="mob">
<ul class="mobile-menu-container">
<li class="mobile-menu-items">Home</li>
<li class="mobile-menu-items">Types Tours
<div class="mobile-types-sub-menu">
<ul class="mobile-types-sub-menu-items">
<li>test-1</li>
<li>test-2</li>
<li>test-3</li>
</ul>
</div>
</li>
<li class="mobile-menu-items">The regions</li>
<li class="mobile-menu-items">Instructors</li>
<li class="mobile-menu-items">Questions / Answers</li>
<li class="mobile-menu-items">Contacts</li>
</ul>
</div>
</div>
</div>
Create a class of active-mobile-menu in the CSS and use the classList.toggle() function in the JavaScript to switch between different classes.
function myFunction() {
let mobileMenu = document.getElementById('mob');
mobileMenu.classList.toggle('active-mobile-menu');
}
.hamburger {
width: 35px;
height: 5px;
background-color: #f7941e;
margin: 6px 0;
}
.mobile-menu {
display: none;
}
.active-mobile-menu{
display: block;
position: absolute;
}
.hamburger-container {
cursor: pointer;
}
<div class="mobile-navbar">
<div class="hamburger-container" onclick="myFunction()">
<div class="hamburger"></div>
<div class="hamburger"></div>
<div class="hamburger"></div>
<div class="mobile-menu" id="mob">
<ul class="mobile-menu-container">
<li class="mobile-menu-items">Home</li>
<li class="mobile-menu-items">Types Tours
<div class="mobile-types-sub-menu">
<ul class="mobile-types-sub-menu-items">
<li>test-1</li>
<li>test-2</li>
<li>test-3</li>
</ul>
</div>
</li>
<li class="mobile-menu-items">The regions</li>
<li class="mobile-menu-items">Instructors</li>
<li class="mobile-menu-items">Questions / Answers</li>
<li class="mobile-menu-items">Contacts</li>
</ul>
</div>
</div>
</div>
**
I compose a part of the code of my project here to report the problem I am facing. I need to keep the js function to work the links that I put in the top bar.
$(function () {
function setFlatTheme() {
$("body").toggleClass("flat-theme");
$("#rad-color-opts").toggleClass("hide");
$(".rad-chk-pin input[type=checkbox]").prop("checked", true);
}
setFlatTheme();
$(document).on("click", function (e) {
e.preventDefault();
var $item = $(".rad-dropmenu-item");
if ($item.hasClass("active")) {
$item.removeClass("active");
}
});
$("li.rad-dropdown > a.rad-menu-item").on("click", function (e) {
e.preventDefault();
e.stopPropagation();
$(".rad-dropmenu-item").removeClass("active");
$(this).next(".rad-dropmenu-item").toggleClass("active");
});
});
.links > li {
list-style: none;
position: relative;
margin: 10px;
display: inline-block;
}
.rad-dropmenu-item.active {
display: block;
-webkit-animation: flipInX 1s ease;
}
.rad-notification-body {
color: black;
vertical-align: middle;
margin-left: 30px;
}
.rad-logo-container {
width: 225px;
text-align: center;
height: 50px;
float: left;
transition: all 0.2s ease-in-out;
}
.rad-menu-item {
position: relative;
padding: 0 5px;
line-height: 30px;
height: 30px;
color: #89949B;
z-index: 5;
display: inline-block;
}
.rad-dropmenu-item {
position: absolute;
right: -6px;
top: 45px;
min-width: 250px;
background: white;
border: 1px solid #BDBDBD;
border-top: 5px solid #515d6e;
border-radius: 2px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
display: none;
}
.rad-chk-pin span {
display: inline-block;
position: relative;
height: 20px;
width: 40px;
border-radius: 4px;
background: crimson;
border: 1px solid #f6f6f6;
}
.rad-chk-pin span:after {
content: "";
position: absolute;
background: white;
width: 20px;
height: 20px;
border-radius: 4px;
top: -1px;
left: 0px;
box-shadow: 0 0 0.5px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
transition: all 0.2s ease;
}
.rad-chk-pin input {
display: none;
}
.rad-chk-pin input:checked + span {
background: #23AE89;
}
.rad-chk-pin input:checked + span:after {
left: 19px;
}
.rad-color-swatch {
display: table;
width: 90px;
height: 25px;
border-radius: 4px;
}
.rad-color-swatch .colors {
width: 25px;
height: 25px;
display: table-cell;
cursor: pointer;
}
.rad-color-swatch .colors input[type=radio] {
display: none;
}
.rad-color-swatch .colors:first-child {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.rad-color-swatch .colors:last-child {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
.rad-sidebar.rad-nav-min {
width: 65px !important;
}
#media screen and (max-width: 850px) {
.rad-navigation {
height: 100px;
}
.rad-logo-container.rad-nav-min + .rad-logo-hidden {
display: none;
}
.rad-logo-container {
display: block;
float: none;
width: 100%;
border-bottom: 1px solid #F2F2F2;
}
.rad-top-nav-container {
display: block;
float: none;
height: 50px;
background: white;
}
.rad-sidebar.rad-nav-min {
transform: translate3d(-200px, 0, 0);
}
}
.flat-theme .rad-navigation .rad-top-nav-container .links > li > a {
border-radius: 50%;
width: 32px;
height: 32px;
background: #f6f6f6;
display: inline-block;
line-height: 32px;
}
.rad-bg-purple {
background: rebeccapurple;
}
.rad-bg-twitter {
background: #55acee;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.7/css/materialize.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jQuery-slimScroll/1.3.3/jquery.slimscroll.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.7/js/materialize.min.js"></script>
<body>
<section>
<header>
<nav class="rad-navigation">
<div class="rad-logo-container rad-nav-min">
<span class="letra">xxxxxxxxxxxxxx xxxxxxxxxxxx </span>
<i class="fa fa-bars acertobar"></i>
</div>
xxxxxxxxxx xxxxxxxxxx xxxxxxxxxxxx
<div class="rad-top-nav-container">
<ul class="pull-right links">
<li class="rad-dropdown no-color">
<a class="rad-menu-item" id="verificar" href="#"><img class="rad-list-img sm-img acerto" src="<?php echo $_SESSION['image'] ?>" alt="me" /></a>
<ul class="rad-dropmenu-item sm-menu">
<li class="rad-notification-item">
<a class="rad-notification-content lg-text" href="https://gestao.centropadreangelo.pt"><i class="fa fa-edit"></i> Perfil</a>
</li>
<li class="rad-notification-item">
<a class="rad-notification-content lg-text" href="#"><i class="fa fa-power-off"></i> Logout</a>
</li>
</ul>
</li>
<li class="rad-dropdown"><a id="verificar" class="rad-menu-item" href="#"><i class="fa fa-cog"></i></a>
<ul class="rad-dropmenu-item rad-settings">
<li class="rad-dropmenu-header">Definições</li>
<li class="rad-notification-item text-left">
<div class="pull-left"><i class="fa fa-link"></i></div>
<div class="pull-right">
<label class="rad-chk-pin pull-right">
<input type="checkbox" /><span></span></label>
</div>
<div class="rad-notification-body">
<div class="lg-text">Mudar para tema plano</div>
<div class="sm-text">Flattify it</div>
</div>
</li>
<li id="rad-color-opts" class="rad-notification-item text-left hide">
<div class="pull-left"><i class="fa fa-puzzle-piece"></i></div>
<div class="pull-right">
<div class="rad-color-swatch">
<label class="colors rad-bg-crimson rad-option-selected">
<input type="radio" checked name="color" value="crimson" />
</label>
<label class="colors rad-bg-teal">
<input type="radio" name="color" value="teal" />
</label>
<label class="colors rad-bg-purple">
<input type="radio" name="color" value="purple">
</label>
<label class="colors rad-bg-orange">
<input type="radio" name="color" value="orange" />
</label>
<label class="colors rad-bg-twitter">
<input type="radio" name="color" value="twitter" />
</label>
</div>
</div>
<div class="rad-notification-body">
<div class="lg-text">Escolha uma cor</div>
<div class="sm-text">Torne-o colorido</div>
</div>
</li>
</ul>
</li>
</ul>
<ul class="pull-right links">
<li>
<span class="letra1">xxxxx xxxxxxx xxxxxxxx</span>
</li>
</ul>
</div>
</nav>
</header>
</section>
<aside>
<nav class="rad-sidebar rad-nav-min">
<ul>
<li>
<a href="https://xxxxxxxxxxxxxxxxxxxxxxxxxx.pt" class="inbox">
<i class="fa fa-home acerto"><span class="icon-bg"></span></i>
<span class="rad-sidebar-item">HOME</span>
</a>
</li>
<li>
<a href="https://xxxxxxxxxxxxxxxxxxxxxxxxxx.pt/xxx.php" class="inbox">
<i class="fa fa-user">
<span class="icon-bg"></span>
</i>
<span class="rad-sidebar-item">INSCRIÇÃO</span>
</a>
</li>
</ul>
</nav>
</aside>
<main>
<form class="steps" id="inscricao" accept-charset="UTF-8" enctype="multipart/form-data" novalidate="">
<label for="validade" Style="margin-top: 10%;">Data de Validade </label>
<input id="validade" name="validade" type="date" >
</form>
</main>
</body>
But when you put this function, you stop opening the calendar in the input with the date type. If you remove the function, the calendar of the input already works. But when I remove the function, I’m unable to close the links on the top bar.
Can you help solve this problem?
You can shift the preventDefault() inside the if condition. So that the click default action is prevented only if the menu is opened. As per your current code, what happens is that It is capturing all click events on document and then preventing the event trigger always. So the datepicker is not able to catch the click event on calender and the calender never opens. With the following modification, now the click event will only get prevented when the menu is open.
$(function () {
$(document).on("click", function (e) {
var $item = $(".rad-dropmenu-item");
if ($item.hasClass("active")) {
$item.removeClass("active");
e.preventDefault();
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<body>
<section>
<header>
<nav class="rad-navigation">
<div class="rad-logo-container rad-nav-min">
<span class="letra">xxxxxxxxxxxxxx xxxxxxxxxxxx </span>
<i class="fa fa-bars acertobar"></i>
</div>
xxxxxxxxxx xxxxxxxxxx xxxxxxxxxxxx
<div class="rad-top-nav-container">
<ul class="pull-right links">
<li class="rad-dropdown no-color">
<a class="rad-menu-item" id="verificar" href="#"><img class="rad-list-img sm-img acerto" src="<?php echo $_SESSION['image'] ?>" alt="me" /></a>
<ul class="rad-dropmenu-item sm-menu">
<li class="rad-notification-item">
<a class="rad-notification-content lg-text" href="https://gestao.centropadreangelo.pt"><i class="fa fa-edit"></i> Perfil</a>
</li>
<li class="rad-notification-item">
<a class="rad-notification-content lg-text" href="#"><i class="fa fa-power-off"></i> Logout</a>
</li>
</ul>
</li>
<li class="rad-dropdown"><a id="verificar" class="rad-menu-item" href="#"><i class="fa fa-cog"></i></a>
<ul class="rad-dropmenu-item rad-settings">
<li class="rad-dropmenu-header">Definições</li>
<li class="rad-notification-item text-left">
<div class="pull-left"><i class="fa fa-link"></i></div>
<div class="pull-right">
<label class="rad-chk-pin pull-right">
<input type="checkbox" /><span></span></label>
</div>
<div class="rad-notification-body">
<div class="lg-text">Mudar para tema plano</div>
<div class="sm-text">Flattify it</div>
</div>
</li>
<li id="rad-color-opts" class="rad-notification-item text-left hide">
<div class="pull-left"><i class="fa fa-puzzle-piece"></i></div>
<div class="pull-right">
<div class="rad-color-swatch">
<label class="colors rad-bg-crimson rad-option-selected">
<input type="radio" checked name="color" value="crimson" />
</label>
<label class="colors rad-bg-teal">
<input type="radio" name="color" value="teal" />
</label>
<label class="colors rad-bg-purple">
<input type="radio" name="color" value="purple">
</label>
<label class="colors rad-bg-orange">
<input type="radio" name="color" value="orange" />
</label>
<label class="colors rad-bg-twitter">
<input type="radio" name="color" value="twitter" />
</label>
</div>
</div>
<div class="rad-notification-body">
<div class="lg-text">Escolha uma cor</div>
<div class="sm-text">Torne-o colorido</div>
</div>
</li>
</ul>
</li>
</ul>
<ul class="pull-right links">
<li>
<span class="letra1">xxxxx xxxxxxx xxxxxxxx</span>
</li>
</ul>
</div>
</nav>
</header>
</section>
<aside>
<nav class="rad-sidebar rad-nav-min">
<ul>
<li>
<a href="https://xxxxxxxxxxxxxxxxxxxxxxxxxx.pt" class="inbox">
<i class="fa fa-home acerto"><span class="icon-bg"></span></i>
<span class="rad-sidebar-item">HOME</span>
</a>
</li>
<li>
<a href="https://xxxxxxxxxxxxxxxxxxxxxxxxxx.pt/xxx.php" class="inbox">
<i class="fa fa-user">
<span class="icon-bg"></span>
</i>
<span class="rad-sidebar-item">INSCRIÇÃO</span>
</a>
</li>
<li>
<a href="#" class="inbox">
<i class="fa fa-power-off">
<span class="icon-bg"></span>
</i>
<span class="rad-sidebar-item">Terminar Sessão</span>
</a>
</li>
</ul>
</nav>
</aside>
<main>
<div class="hs_firstname field hs-form-field">
<label for="validade">Data de Validade <span style="color: red;">*</span></label>
<input id="validade" name="validade" required="required" type="date" value="<?php echo $validade; ?>" placeholder="" data-rule-required="true" data-msg-required="Campo obrigatório" >
<span class="error1" style="display: none;">
<i class="error-log fa fa-exclamation-triangle"></i>
</span>
</div>
</main>
</body>
$(document).on("click", function (e) {
e.preventDefault(); //<-- THIS HERE
When you click anywhere on the document, that click will be caught and the default action (like opening the date picker) will be prevented.
I suggest that instead of calling the .on() function on the entire document you limit it only to the part where your links are i.e.
$(".rad-navigation").on("click", ....
(this selects the .rad-navigation class)
$(document).ready(function($) {
$('#accordion').find('.accordion-toggle').addClass('icon-rotate');
$('#accordion').find('.accordion-content.default').prev('h4').removeClass('icon-rotate');
$('#accordion').find('.accordion-toggle').click(function(e) {
$(this).next().slideToggle().addClass('expanded').prev('h4').removeClass('icon-rotate');
$(".accordion-content").not($(this).next()).slideUp().removeClass('expanded').prev('h4').addClass('icon-rotate');
});
});
/* Accordion - Left Panel */
/* line 4, ../sass/my-request.scss */
.filter-panel .accordion-header {
background: #506070;
color: #FFF;
font-size: 16px;
padding: 15px;
font-weight: 600;
}
/* line 11, ../sass/my-request.scss */
.filter-panel .accordion-toggle-first {
cursor: pointer;
margin: 0;
font-size: 14px;
color: #333;
background: #F6F6F6;
padding: 15px 20px;
font-weight: 600;
border: 1px solid #DEDEDE;
border-top: 0;
}
/* line 22, ../sass/my-request.scss */
.filter-panel .accordion-toggle {
cursor: pointer;
margin: 0;
font-size: 14px;
color: #333;
background: #F6F6F6;
padding: 11px 20px;
font-weight: 600;
border: 1px solid #DEDEDE;
border-top: 0;
}
/* line 33, ../sass/my-request.scss */
.filter-panel .accordion-content {
display: none;
font-weight: 600;
border: 1px solid #DEDEDE;
border-top: 0;
}
/* line 39, ../sass/my-request.scss */
.filter-panel .accordion-content ul li {
padding: 10px 30px;
}
/* line 42, ../sass/my-request.scss */
.filter-panel .accordion-content.default {
display: block;
}
/* line 45, ../sass/my-request.scss */
.icon-rotate span {
transform: rotate(90deg);
transition: .25s;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="accordion" class="filter-panel">
<div class="accordion-header">Refine by:</div>
<div class="accordion-toggle-first">All</div>
<h4 class="accordion-toggle">Active <span class="align-right fa fa-angle-down fa-lg" aria-hidden="true"></span></h4>
<div class="accordion-content default">
<ul>
<li>
<div class="align-left">Pending DSL (12)</div>
<div class="align-right"><span class="text-right"><input type="checkbox" value=""></span></div>
<div class="clear"></div>
</li>
<li>
<div class="align-left">Pending ECR (21)</div>
<div class="align-right"><span class="text-right"><input type="checkbox" value=""></span></div>
<div class="clear"></div>
</li>
<li>
<div class="align-left">Pending OSI (10)</div>
<div class="align-right"><span class="text-right"><input type="checkbox" value=""></span></div>
<div class="clear"></div>
</li>
<li>
<div class="align-left">Pending OWS (6)</div>
<div class="align-right"><span class="text-right"><input type="checkbox" value=""></span></div>
<div class="clear"></div>
</li>
<li>
<div class="align-left">Pending Requestor (10)</div>
<div class="align-right"><span class="text-right"><input type="checkbox" value=""></span></div>
<div class="clear"></div>
</li>
</ul>
</div>
<h4 class="accordion-toggle">Closed <span class="align-right fa fa-angle-down fa-lg" aria-hidden="true"></span></h4>
<div class="accordion-content">
<ul>
<li>Cancelled (21)</li>
<li>Rejected (14)</li>
<li>Completed (21)</li>
</ul>
</div>
<h4 class="accordion-toggle">Type <span class="align-right fa fa-angle-down fa-lg" aria-hidden="true"></span></h4>
<div class="accordion-content">
<ul>
<li>Alias (13)</li>
<li>Sites (15)</li>
<li>Domain (19)</li>
<li>Social Media (9)</li>
<li>Archive/Back-up (21)</li>
<li>Mobile App (6)</li>
</ul>
</div>
<h4 class="accordion-toggle">VPU <span class="align-right fa fa-angle-down fa-lg" aria-hidden="true"></span></h4>
<div class="accordion-content">
<ul>
<li>Africa (23)</li>
<li>East Asia Pacific (15)</li>
<li>South Asia (19)</li>
<li>Latin America (9)</li>
</ul>
</div>
<h4 class="accordion-toggle">Date <span class="align-right fa fa-angle-down fa-lg" aria-hidden="true"></span></h4>
<div class="accordion-content">
</div>
</div>
I am using the following script
http://uniondesign.ca/wp-content/uploads/2012/09/accordion-demo.html
and adding arrow icon if any accordion is open n changing based on accordion open n close but I am stuck once all the accordion is closed my icon is not rotating.
Also attached the screenshot for more details
Error Screenshot
I think you could use toggleClass in this situation. Here is what I changed to get the demo to work.
$(document).ready(function($) {
$('#accordion').find('.accordion-toggle').addClass('icon-rotate');
$('#accordion').find('.accordion-content.default').prev('h4').removeClass('icon-rotate');
$('#accordion').find('.accordion-toggle').click(function(e) {
$(this).toggleClass('icon-rotate').next().slideToggle().addClass('expanded');
$(".accordion-content").not($(this).next()).slideUp().removeClass('expanded').prev('h4').addClass('icon-rotate');
});
});
Fiddle
CSS3 transition works fine in an HTML page, but not in a .aspx page. Is there a way to overcome this? I'd like to do the app in Web Forms as it makes designing the forms much easier. Any input would be appreciated.
Here is the .aspx page:
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="CMSWebForms.Index" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<link rel="stylesheet" type="text/css" href="Content/jquery-1.10.2.min.js" />
<link href="Content/bootstrap.min.css" rel="stylesheet" />
<link href="Content/bootstrap-combined.min.css" rel="stylesheet" />
<link href="Content/font-awesome.min.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="Content/test.css"/>
</head>
<body>
<ul id="sidebar" class="dropdown-menu text-right" role="menu" aria-labelledby="dropdownMenu" style="display: block; position: fixed; top: 0; left: 0;">
<li><h1 class="text-center"><a tabindex="-1" href="#">CMS</a></h1></li>
<li class="divider"></li>
<li class="dropdown-submenu pull-right">
<a tabindex="-1" href="#" id="myId">Sales</a>
<ul class="dropdown-menu text-right">
<li><a tabindex="-1" href="#">Customers</a></li>
<li class="dropdown-submenu pull-right">
<a tabindex="-1" href="#" id="myId">Pricing</a>
<ul class="dropdown-menu text-center">
<li><a tabindex="-1" href="#">A</a></li>
<li><a tabindex="-1" href="#">B</a></li>
<li><a tabindex="-1" href="#">C</a></li>
<li><a tabindex="-1" href="#">D</a></li>
<li><a tabindex="-1" href="#">E</a></li>
</ul>
</li>
<li><a tabindex="-1" href="#">Quotes</a></li>
<li><a tabindex="-1" href="#">Orders</a></li>
<li><a tabindex="-1" href="#">Pricing</a></li>
<li><a tabindex="-1" href="#">Reports</a></li>
</ul>
</li>
<p> </p>
<!--<p> </p>-->
<li class="dropdown-submenu pull-right">
<a tabindex="-1" href="#" id="myId">Manufacturing</a>
<ul class="dropdown-menu text-center">
<li><a tabindex="-1" href="#">One</a></li>
<li><a tabindex="-1" href="#">Two</a></li>
<li><a tabindex="-1" href="#">Three</a></li>
<li><a tabindex="-1" href="#">Four</a></li>
<li><a tabindex="-1" href="#">Five</a></li>
</ul>
</li>
</ul>
<!--</div>-->
<!--<div id="wrapper">-->
<div id="page-content-wrapper">
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<ul class="nav navbar-nav navbar-left">
<li>
<button id="sidebarToggle" class="btn btn-primary btn-lg">
<i class="fa fa-angle-left"></i>
</button>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#" class="btn btn-sm btn-info">
<i class="fa fa-sign-in"></i> Log in
</a>
</li>
</ul>
</div>
</nav>
<div class="content-header container-fluid text-center">
<h1 id="home" class="">
CMS
</h1>
</div>
<div class="page-content inset container-fluid">
<div class="row">
<div class="jumbotron text-center">
<h1 class="">Hello Beautiful!</h1>
<p class="">
</p>
Name:
<asp:TextBox ID="TextBox1" runat="server" Width="248px"></asp:TextBox>
Address:
<asp:TextBox ID="TextBox2" runat="server" Width="248px"></asp:TextBox>
</div>
</div>
</div>
<div id="footer" class="container-fluid">
<div class="navbar navbar-inverse navbar-fixed-bottom">
<h4 class="text-center text-primary">©2016 Apiron Technologies, Inc.</h4>
</div>
</div>
</div>
<script src="Scripts/jquery-1.10.2.min.js"></script>
<script src="Scripts/bootstrap.min.js"></script>
<script type="text/javascript" src="js/test.js"></script>
<script src="Scripts/site.js"></script>
</body>
</html>
</asp:Content>
Here is the CSS:
#sidebar{
background: #000;
color: #999999;
border-radius: 0;
padding: 0;
height: 100%;
width: 200px;
margin-top: 0;
transition: .25s;
}
#sidebar.dropdown-menu.text-right.hide-sidebar{
left: -200px !important;
transition: .25s;
}
.navbar.navbar-inverse{
border-radius: 0 !important;
background: #1536b6 !important;
}
.navbar-inverse
.navbar-inverse .nav>li>a {
color: #fff !important;
}
.btn-info{
color: #fff !important;
}
.navbar.navbar-inverse.navbar-fixed-bottom{
margin-left: 200px !important;
}
#page-content-wrapper {
margin-left: 200px;
transition: .25s;
}
#page-content-wrapper.hide-sidebar{
margin-left: 0;
transition: .25s;
}
.dropdown-menu {
border-radius: 0;
padding: 0;
}
.dropdown-menu li a {
background: #000;
color: #999999;
display: block;
text-decoration: none;
outline: none;
}
.dropdown-menu li a:hover,
.dropdown-menu li.active {
color: #fff;
background: rgba(255,255,255,0.2);
text-decoration: none;
}
.dropdown-menu.text-right li a {
background: #000;
color: #999999;
display: block;
text-decoration: none;
outline: none;
}
.dropdown-menu.text-right li a:hover,
.dropdown-menu.text-right li.active {
color: #fff;
background-color: #333131 ;
text-decoration: none;
}
.dropdown-submenu.pull-right{
background: #000;
display: block;
width: 100%;
}
#myId {
color: aqua;
}
and here is the JS:
(function () {
var $sidebarAndWrapper = $("#sidebar,#page-content-wrapper");
var $icon = $("#sidebarToggle i.fa");
$("#sidebarToggle").on("click", function () {
$sidebarAndWrapper.toggleClass("hide-sidebar");
if ($sidebarAndWrapper.hasClass("hide-sidebar")) {
$icon.removeClass("fa-angle-left");
$icon.addClass("fa-angle-right");
}
else {
$icon.removeClass("fa-angle-right");
$icon.addClass("fa-angle-left");
}
});
})();
What browser are you checking in? Try using another browser.
Once i had a same problem. Resetting IIS site fixed the issue. You can also try prefixing CSS.
Cheers
I took code for a dashboard we're building here; it's a free bootstrap dashboard template:
http://ironsummitmedia.github.io/startbootstrap-sb-admin-2/pages/index.html
We like it a lot as it's simple and displays the kind of layout we need. Here's what I've done to edit the above so far, to suit our needs:
http://tumolo.co.uk/smartcm/pages/index.html
If you resize your browser, so that you're reducing the width, with the original template, once it gets to (I assume) xs or sm size, the sidebar menu neatly hides and the 3line button in the top right displays. You can tell I'm new to bootstrap!
If you resize my version, once it gets to (I assume) xs or sm size, the sidbar menu displays instead of hides, like it should in original template.
IF it helps, I noticed that as I was editing from template to my version, when I started removing containers from original template, the menu stopped hiding when resizing browser window.
As we want to use this dashboard on mobile phones, it's important for me to understand how to make this menu hidden, as soon as you browse to it, from a mobile device... hope you can help, thanks.
<div class="navbar-default sidebar" role="navigation">
<div class="sidebar-nav navbar-collapse">
<ul class="nav" id="side-menu">
<li class="sidebar-search">
<div class="input-group custom-search-form">
<input type="text" class="form-control" placeholder="Search...">
<span class="input-group-btn">
<button class="btn btn-default" type="button">
<i class="fa fa-search"></i>
</button>
</span>
</div>
<!-- /input-group -->
</li>
<li>
<i class="fa fa-dashboard fa-fw"></i> Overview
</li>
<li>
<i class="fa fa-external-link-square fa-fw"></i> Allocation
</li>
<li>
<i class="fa fa-table fa-fw"></i> Events & Stages
</li>
<li>
<i class="fa fa-comment fa-fw"></i>Correspondence Log
</li>
<li>
<i class="fa fa-folder-open fa-fw"></i>Resources
</li>
</ul>
</div>
<!-- /.sidebar-collapse -->
</div>
You are missing <div class="collapse navbar-collapse" ></div>which surrounds the ul class.
Refer to the docs here > Bootstrap Navbar
/*!
* Start Bootstrap - SB Admin 2 Bootstrap Admin Theme (http://startbootstrap.com)
* Code licensed under the Apache License v2.0.
* For details, see http://www.apache.org/licenses/LICENSE-2.0.
*/
body {
background-color: #f8f8f8;
}
#wrapper {
width: 100%;
}
#page-wrapper {
padding: 0 15px;
min-height: 568px;
background-color: #fff;
}
#media(min-width:768px) {
#page-wrapper {
position: inherit;
margin: 0 0 0 250px;
padding: 0 30px;
border-left: 1px solid #e7e7e7;
background-color: #fff;
}
}
.navbar-static-top {
margin-right: 0;
background-color: #fff;
}
.navbar-top-links {
margin-right: 0;
background-color: #fff;
}
.navbar-top-links li {
display: inline-block;
}
.navbar-top-links li:last-child {
margin-right: 15px;
}
.navbar-top-links li a {
padding: 15px;
min-height: 50px;
}
.navbar-top-links .dropdown-menu li {
display: block;
}
.navbar-top-links .dropdown-menu li:last-child {
margin-right: 0;
}
.navbar-top-links .dropdown-menu li a {
padding: 3px 20px;
min-height: 0;
}
.navbar-top-links .dropdown-menu li a div {
white-space: normal;
}
.navbar-top-links .dropdown-messages,
.navbar-top-links .dropdown-tasks,
.navbar-top-links .dropdown-alerts {
width: 310px;
min-width: 0;
}
.navbar-top-links .dropdown-messages {
margin-left: 5px;
}
.navbar-top-links .dropdown-tasks {
margin-left: -59px;
}
.navbar-top-links .dropdown-alerts {
margin-left: -123px;
}
.navbar-top-links .dropdown-user {
right: 0;
left: auto;
}
.sidebar .sidebar-nav.navbar-collapse {
padding-right: 0;
padding-left: 0;
}
.sidebar .sidebar-search {
padding: 15px;
}
.sidebar ul li {
border-bottom: 1px solid #e7e7e7;
}
.sidebar ul li a.active {
background-color: #eee;
}
.sidebar .arrow {
float: right;
}
.sidebar .fa.arrow:before {
content: "\f104";
}
.sidebar .active>a>.fa.arrow:before {
content: "\f107";
}
.sidebar .nav-second-level li,
.sidebar .nav-third-level li {
border-bottom: 0!important;
}
.sidebar .nav-second-level li a {
padding-left: 37px;
}
.sidebar .nav-third-level li a {
padding-left: 52px;
}
#media(min-width:768px) {
.sidebar {
z-index: 1;
position: absolute;
width: 250px;
margin-top: 51px;
}
.navbar-top-links .dropdown-messages,
.navbar-top-links .dropdown-tasks,
.navbar-top-links .dropdown-alerts {
margin-left: auto;
}
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div id="wrapper">
<!-- Navigation -->
<nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">
<img class="img-responsive" src="img/loginlogo.png">
</a>
</div>
<!-- /.navbar-header -->
<div class="collapse navbar-collapse">
<ul class="nav navbar-top-links navbar-right">
<!-- /.dropdown -->
<li class="dropdown pull-right">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<i class="fa fa-user fa-fw"></i> <i class="fa fa-caret-down"></i>
</a>
<ul class="dropdown-menu dropdown-user">
<li><i class="fa fa-user fa-fw"></i> User Profile
</li>
<li><i class="fa fa-gear fa-fw"></i> Settings
</li>
<li class="divider"></li>
<li><i class="fa fa-sign-out fa-fw"></i> Logout
</li>
</ul>
<!-- /.dropdown-user -->
</li>
<!-- /.dropdown -->
</ul>
<!-- /.navbar-top-links -->
<div class="navbar-default sidebar" role="navigation">
<div class="sidebar-nav navbar-collapse">
<ul class="nav" id="side-menu">
<li class="sidebar-search">
<div class="input-group custom-search-form">
<input type="text" class="form-control" placeholder="Search..."> <span class="input-group-btn">
<button class="btn btn-default" type="button">
<i class="fa fa-search"></i>
</button>
</span>
</div>
<!-- /input-group -->
</li>
<li> <i class="fa fa-dashboard fa-fw"></i> Overview
</li>
<li> <i class="fa fa-external-link-square fa-fw"></i> Allocation
</li>
<li> <i class="fa fa-table fa-fw"></i> Events & Stages
</li>
<li> <i class="fa fa-comment fa-fw"></i>Correspondence Log
</li>
<li> <i class="fa fa-folder-open fa-fw"></i>Resources
</li>
</ul>
</div>
</div>
<!-- /.sidebar-collapse -->
</div>
<!-- /.navbar-static-side -->
</nav>
</div>