How to disable sidenav overlay in Materializecss? - html

I have the following code:
<ul id="slide-out" class="side-nav">
<li><a class="subheader">Scalls Seleccionados</a></li>
<li><a class="btn waves-effect waves-light cyan"><i class="material-icons">inbox</i>Scall 1</a></li>
<li><a class="btn waves-effect waves-light cyan"><i class="material-icons">inbox</i>Scall 2</a></li>
<li><a class="btn waves-effect waves-light cyan"><i class="material-icons">inbox</i>Scall 3</a></li>
<li><div class="divider"></div></li>
</ul>
<a data-activates="slide-out" class="button-collapse btn-floating btn-large cyan" style="top: 10px; left: 10px;">
<i class="material-icons">menu</i>
</a>
Do you have any idea how to disable/remove the overlay when I display the sidenav in Materializecss?
I've spend a lot of time trying to remove it.

IF the issue is because the overlay is overlapping the nav menu, use this CSS fix;
.navbar-fixed {
z-index: 999;
}
// the default value is 997 in materialize.min.css, which places the nav behind the overlay... :(

add this to your css file :
#sidenav-overlay {
background-color: transparent;
}

I know it is an old question but for anyone wanting to remove the overlay the following works:-
.sidenav-overlay {
height: 0px;
width: 0px;
}
or with Svelte:-
:global(.sidenav-overlay) {
height: 0px;
width: 0px;
}

One approach would be to add .sidenav-overlay{opacity: 0;} to your css.

Well, I have also not found any specific function call to do so.
This is how disabling the sidenav without removing it from DOM.
var sideNavElem = $('a[data-activates="slide-out"]');
$(sideNavElem).off('click');
$(sideNavElem).click(function(e){
e.preventDefault();
});
is it similar to what you are looking for?

You can easily remove it from DOM using onOpenStart event
$('.side-nav').sidenav({
..., //your sidenav options here
onOpenStart: function(sidenav) {
sidenav.M_Sidenav._overlay.remove();
}
});

Related

how to create w3-bar content with equal height

Currently I am trying to use the newly added w3-bar class from w3.css to create a top navigation with some buttons and a logo.
If the navigation bar only consists of buttons, everything works fine, since the height of the buttons is the same everywhere.
Now when I try to add a logo to that navigation bar which is higher than the buttons, then the buttons are placed to the top of the bar.
<div class="w3-border w3-light-grey w3-bar" style="height: 80px">
<a class="w3-bar-item w3-button" href="#">Home</a>
<img class="w3-bar-item" src="http://lorempixel.com/200/56/">
<a class="w3-bar-item w3-button" href="#">Link 1</a>
<a class="w3-bar-item w3-button" href="#">Link 2</a>
<a class="w3-bar-item w3-button w3-green w3-right" href="#">Link 3</a>
</div>
I would like to manage it to place the buttons in the vertical middle position so it looks way better.
I can manage this vertically centered buttons when i use w3-cell-row and w3-cell-middle like so:
<div class="w3-border w3-light-grey w3-cell-row" style="height: 80px">
<a class="w3-cell w3-cell-middle w3-button" href="#">Home</a>
<img class="w3-cell w3-cell-middle " src="http://lorempixel.com/200/56/">
<a class="w3-cell w3-cell-middle w3-button" href="#">Link 1</a>
<a class="w3-cell w3-cell-middle w3-button" href="#">Link 2</a>
<a class="w3-cell w3-cell-middle w3-button w3-green w3-right" href="#">Link 3</a>
</div>
But if i try to vertically center the buttons in the w3-bar navigation bar, i can't get it to work.
You can check this fiddle to see the two different results:
https://jsfiddle.net/TheChaos/o1cg5e64/
Does anybody know how to vertically center (and fill the navbar) completely with w3.css classes (or some additional css)?
i'm adding another answer as i believe the first answer to still be helpful for some readers.
https://jsfiddle.net/showcaseimagery/8r9bmgm3/
the .w3-bar-item of this CSS will do it, i've added the other two styles for optionals
.w3-bar-item {
position: relative;
top: 50%;
transform: translateY(-50%);
}
#brand {
display: block !important;
padding: 0 !important;
}
img#brand {
height: 100%;
width: auto;
}
with the only alteration to the html as #brand
Here ya go, will this solve your issue?
https://jsfiddle.net/byxw86d1/
I've removed the inline-height from the parent div and added a .brand class to the image for styling. Having the navigation items large is better for small screen users, though you can set a breakpoint for that
<div class="w3-border w3-light-grey w3-cell-row" style="height: 80px">
.brand {
display:block;
height:auto;
width:100%;
margin-bottom:0 !important;
}
<!-- create full size image for larger screen OPTIONAL -->
.w3-cell-row {
display:block;
}

Textbox with Dropdown as Group Addon

I am trying to use the Dropdown as a Group Add-on in bootstrap:
<div class="col-md-5">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">#Html.DropDownListFor(m => m.SelectedCountryCode, new SelectList(Model.ListOfCountries, "PhoneCode", "PhoneCode"), "Select")</div>
#Html.TextBoxFor(m => Model.Value, new { #class = "form-control" })
</div>
</div>
</div>
This is the result I get:
Is there another way to do this so my styles of dropdown are same as the textbox?
I don't want the grey part around the dropdown.
Here is a JSFiddle:
https://jsfiddle.net/mdawood1991/yLygh0v4/
This is the best way to fix this. Style the dropdown with this:
background: transparent;
border: 0;
Then it'll look like this:
And when open:
You can use an input-group-btn dropdown:
<div class="input-group-btn">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"
aria-expanded="false">Select <span class="caret"></span></button>
<ul class="dropdown-menu" role="menu">
<li>0044</li>
<li>0033</li>
<li>001</li>
</ul>
</div><!-- /btn-group -->
Fiddle.
Or, you can remove the padding from the .input-group-addon:
.input-group-addon {
padding: 0 !important;
background: transparent;
}
Fiddle.
What about styling the select box?
select{
background-color: transparent;
}
It may be that I got your question wrong :)
The area then just vanishes on my phone. I'm using safari on iOS 8.
You can also override the background color for that class:
.input-group-addon {
background: white;
}
Or just change it in the existing CSS.

Changing div display on click using css dynamically [duplicate]

This question already has answers here:
Changing the style of html tag by clicking on another
(2 answers)
Closed 8 years ago.
I have the following code, the parentAppliance is part of main left nav table and on hovering over "Appliance" I see a subtable containing "health". Now I want the subtable to disappear when I click on "Health", any thoughts?
CSS:
.childAppliance
{
display:none;
}
.parentAppliance:hover .childAppliance
{
display: block;
top: 50px;
left: 130px;
}
HTML:
<a href="#/appliance_status.home" hiddentitle="Appliance" id="ui-id-83" class="ui-corner-all" tabindex="-1" role="menuitem" aria-haspopup="true" title="" data-original-title="">
<span class="ui-menu-icon ui-icon ui-icon-carat-1-e"></span><ins class="ui-navigation-static-menu-icon ui-navigation-static-menu-icon-backup"></ins>
<span class="ui-navigation-static-menu-text" style="display: inline;">Appliance</span>
</a>
<ul id="ApplianceSubTable" class="ui-menu ui-widget ui-widget-content ui-corner-all childAppliance" role="menu" aria-hidden="true" aria-expanded="false" aria-labelledby="ui-id-83">
<li itemid="Health" class="ui-menu-item" role="presentation">
<a href="#/appliance_status.home" hiddentitle="Health" id="ui-id-33" class="ui-corner-all ui-state-focus applianceFocus" tabindex="-1" role="menuitem" title="">
<span class="ui-navigation-static-menu-text">Health</span>
</a>
</li>
</ul>
You need to use Javascript/Jquery for that.
HTML
<li itemid="Health" class="ui-menu-item" role="presentation" id="Health">
jQuery
$( "#Health" ).click(function() {
$('#ApplianceSubTable').hide();
});
You have to add some javascript adding a clicked class.
$('.parentAppliance').on('click', function () { $(this).toggleClass('clicked'); });
And the css
.parentAppliance.clicked .childAppliance {
display: block;
top: 50px;
left: 130px;
}
Using javascript you can toggle a class which behaves like a hover.

Full Width Split Dropdown Button in Twitter Bootstrap

I have a place on my site which is using a bunch of button elements styled with btn-block (example from the Twitter Bootstrap Docs). I now want to switch some of them to split buttons (example), but I can't seem to get the split buttons and the normal buttons to be the same length.
I have experimented with all kinds of things, but I can't seem to find a way to do this. Has anyone ever managed to do it? Keep in mind that I do not want to hard-code the width of any elements if I don't have to. (Note that this includes not using hard-coded percentages either.) If it is absolutely necessary, I am OK with defining a width for the toggle part of the button (because I know there will only be a single arrow character in there) but want to specify as few "magic numbers" as possible in order to keep the code maintainable in the future.
Wrap the dropdown-lead in a container:
(Note: This example is for Bootstrap 2.x)
.dropdown-lead {
width: 100%;
}
.leadcontainer {
left: 0;
position: absolute;
right: 30px;
}
.dropdown-toggle {
width: 30px;
float: right;
box-sizing: border-box;
}
.fillsplit {
position: relative;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/2.3.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/2.3.2/js/bootstrap.min.js"></script>
<button class="btn btn-block btn-primary" type="button">Block level button</button>
<div class="btn-group btn-block fillsplit">
<div class="leadcontainer">
<a class="btn btn-primary dropdown-lead" href="#"><i class="icon-user icon-white"></i> User</a>
</div>
<a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#"><span class="caret"></span></a>
<ul class="dropdown-menu">
<li><i class="icon-pencil"></i> Edit
</li>
<li><i class="icon-trash"></i> Delete
</li>
<li><i class="icon-ban-circle"></i> Ban
</li>
<li class="divider"></li>
<li><i class="i"></i> Make admin
</li>
</ul>
<div>
</div>
I was looking for the same kind of behavior and found this flexbox solution: http://codepen.io/ibanez182/pen/MwZwJp
It's an elegant implementation which makes use of the flex-grow property.
Just add the .btn-flex class to the .btn-group in your HTML. This is all the CSS you need:
.btn-flex {
display: flex;
align-items: stretch;
align-content: stretch;
}
.btn-flex .btn:first-child {
flex-grow: 1;
}
Credit goes to the author of the pen: Nicola Pressi
If you add the class btn-block to the .btn-group element and give the dropdownbutton elements % widths, that'd do the trick.
.dropdown-lead{
width: 96%;
box-sizing: border-box;
}
.dropdown-toggle{
width: 4%;
box-sizing: border-box;
}
Here's an example: http://jsfiddle.net/eBJGW/5/

How to disable div or jstree inside div?

Can anyone tell me how to disable a div or elements inside a div?
I have a jstree in my div and I want to disable the div/jstree.
Thanks!
I made a simple example for you here
Basically, it creates a div over your jstree's one so that it is disabled from user interactions.
I guess you can make it visually better, but i think this gives you the idea.
I also checked that there is no strigth way to disable a jstree, even if it could be usefull.
Maybe you'd want to ask the dev in google group...
HTML Code:
<button id="disable">Disable</button>
<button id="enable">Enable</button>
<div id="jstree-wrapper">
<div id="demo" style="height:100px;">
<ul>
<li id="node_1_id">
<a>Root node 1</a>
<ul>
<li id="child_node_1_id">
<a>Child node 1</a>
</li>
<li id="child_node_2_id">
<a>Child node 2</a>
</li>
</ul>
</li>
</ul>
<ul>
<li><a>Team A's Projects</a>
<ul>
<li><a>Iteration 1</a>
<ul>
<li><a>Story A</a></li>
<li><a>Story B</a></li>
<li><a>Story C</a></li>
</ul>
</li>
<li><a>Iteration 2</a>
<ul>
<li><a>Story D</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div id="disabler"></div>
</div>​
CSS code:
#jstree-wrapper {
position: relative;
}
#disabler {
position: absolute;
top: 0px;
left: 0px;
background-color: black;
opacity: 0.5;
}​
JS Code:
$(document).ready(function() {
$("#demo").jstree();
$("#disable").on("click", function() {
$("#disabler").css("width", $("#demo").width());
$("#disabler").css("height", $("#demo").height());
});
$("#enable").on("click", function() {
$("#disabler").css("width", "0px");
$("#disabler").css("height", "0px");
});
});
Here's a very good example I didn't find done so simple and good anywhere else. In this example you can simulate the 'disabled' attribute only by adding CSS style as I entered in the code snippet. It disables by using the CSS "visible:hidden", and adds a translucent mask to cover the whole div area and disable anything inside it. You can choose to comment out the 'Visibility:hidden' to be able to see the elements behind the mask, but then they will be tabable, if you don't mind them hidden then uncomment that style.
function disable(elementId, enabling) {
el = document.getElementById(elementId);
if (enabling) {
el.classList.remove("masked");
} else
{
el.classList.add("masked");
}
}
.masked {
position: relative;
pointer-events: none;
display: inline-block;
//visibility:hidden; /* Uncomment this for complete disabling */
}
.masked::before {
position: absolute;
width: 100%;
height: 100%;
top: 0px;
left: 0px;
visibility: visible;
opacity: 0.2;
background-color: black;
content: "";
}
<button onclick="alert('Now, click \'OK\' then \'Tab\' key to focus next button.\nThen click \'Enter\' to activate it.');">Test</button>
<div id="div1" style="display:inline-block" class="masked">
<button onclick="alert('Sample button was clicked.')">Maskakable</button>
<button onclick="alert('Sample button was clicked.')">Maskakable</button><br/>
<br/>
<button onclick="alert('Sample button was clicked.')">Maskakable</button>
<button onclick="alert('Sample button was clicked.')">Maskakable</button>
</div>
<button>Dummy</button>
<br/>
<br/>
<br/>
<button id="enableBtn" onclick="disable('div1',true);disable('enableBtn',false);disable('disableBtn',true);">Enable</button>
<button id="disableBtn" onclick="disable('div1',false);disable('enableBtn',true);disable('disableBtn',false);" class="masked">Disable</button>