LATEST >>

Welcome Here And Thanks For Visiting. Like Us On Facebook...

EXEIdeas – Let's Your Mind Rock » CSS Codes / HTML-CSS-PHP-JavaScript » Pure CSS Window Style Collapsible Tree Menu With Folder/File Icons

Pure CSS Window Style Collapsible Tree Menu With Folder/File Icons

Pure-CSS-Window-Style-Collapsible-Tree-Menu-With-Folder-File-Icons
A tree menu is a useful element to present hierarchical data in the visual interface of a website. It is most commonly used in file management systems to allow users to explore the folder and files. Basically, a simple tree-view navigation can be created using HTML nested lists. But in order to make each list collapsible, we need a JavaScript function to toggle the height of the list. Luckily, we can also make them collapsible using the HTML checkbox element and CSS. Well, in this tutorial, we are going to create a collapsible tree menu using pure CSS.

Here we have a pure vanilla JavaScript snippet that helps you create a simple image slider with basic carousel functionalities such as infinite scrolling, autoplay, responsive and navigation with bullet points.

There are many code snippets available online or on many other blogs and websites, but everyone cannot optimize your blog or website, so you need some optimized code snippets. So now checkout out the code snippet for your blog and website that will give you all features for your desired code. Now grab the ready-to-use code and paste it where you want.

Table of Contents

Features:

  1. Light Weight.
  2. Pure JavaScript Code.
  3. Cross Browser.
  4. No External Files.
  5. Fully Customizable.
  6. Responsive.

How To Use Pure CSS Window Style Collapsible Tree Menu With Folder/File Icons?

There are a few easy and understandable steps to achieve your desired functionality that we are gonna share below. Follow each step perfectly.

CSS:

<style type="text/css">
.tree-menu{
max-width: 640px;
margin: 10px auto;
}

input {
font-size: 1em;
}

.tree-menu ol.tree {
padding-left: 30px;
}

.tree-menu li {
list-style-type: none;
user-select: none;
color: #313131;
position: relative;
margin-left: -15px;
border-left: 1px dotted #aaa;
}

.tree-menu li label {
padding-left: 37px;
cursor: pointer;
background: url("https://codeconvey.com/Tutorials/pure-css-collapsible-tree-menu/css/img/folder-horizontal.png") no-repeat 15px 2px;
display: block;
}

.tree-menu li input {
width: 1em;
height: 1em;
position: absolute;
left: -0.5em;
top: 0;
opacity: 0;
cursor: pointer;
}

.tree-menu li input+ol {
height: 1em;
margin: -16px 0 0 -44px;
background: url("https://codeconvey.com/Tutorials/pure-css-collapsible-tree-menu/css/img/toggle-small-expand.png") no-repeat 40px 0;
}

.tree-menu li input+ol>li {
display: none;
margin-left: -14px !important;
padding-left: 1px
}

.tree-menu li.file {
margin-left: -1px !important;
}

.tree-menu li.file a {
display: inline-block;
padding-left: 21px;
color: #313131;
text-decoration: none;
background: url("https://codeconvey.com/Tutorials/pure-css-collapsible-tree-menu/css/img/document.png") no-repeat 0 0;
}

.tree-menu li input:checked+ol {
height: auto;
margin: -21px 0 0 -44px;
padding: 25px 0 0 80px;
background: url("https://codeconvey.com/Tutorials/pure-css-collapsible-tree-menu/css/img/toggle-small.png") no-repeat 40px 5px;
}

.tree-menu li input:checked+ol>li {
display: block;
margin: 0 0 0.063em;
}

.tree-menu li input:checked+ol>li:first-child {
margin: 0 0 0.125em;
} 
</style>

HTML:

<div class="tree-menu">
<ol class="tree">
<li>
<label for="menu-1">menu-1</label>
<input type="checkbox" checked id="menu-1" />
<ol>
<li>
<label for="menu-1-1">menu-1-1</label>
<input type="checkbox" id="menu-1-1" />
<ol>
<li>
<label for="menu-1-1-1">menu-1-1-1</label>
<input type="checkbox" id="menu-1-1-1" />
<ol>
<li>
<label for="menu-1-1-1-1">menu-1-1-1-1</label>
<input type="checkbox" id="menu-1-1-1-1" />
<ol>
<li class="file"><a href="">menu-1-1-1-1-1</a></li>
<li class="file"><a href="">menu-1-1-1-1-2</a></li>
<li class="file"><a href="">menu-1-1-1-1-3</a></li>
</ol>
</li>
<li class="file"><a href="">menu-1-1-1-2</a></li>
<li class="file"><a href="">menu-1-1-1-3</a></li>
<li class="file"><a href="">menu-1-1-1-4</a></li>
<li class="file"><a href="">menu-1-1-1-5</a></li>
<li class="file"><a href="">menu-1-1-1-6</a></li>
</ol>
</li>
<li class="file"><a href="">menu-1-1-2</a></li>
<li class="file"><a href="">menu-1-1-3</a></li>
<li class="file"><a href="">menu-1-1-4</a></li>
</ol> 
</li>
<li class="file"><a href="">menu-1-2</a></li>
<li class="file"><a href="">menu-1-3</a></li>
</ol>
</li>

<li>
<label for="menu-2">menu-2</label>
<input type="checkbox" id="menu-2" />
<ol>
<li>
<label for="menu-2-1">menu-2-1</label>
<input type="checkbox" id="menu-2-1" />
<ol>
<li>
<label for="menu-2-1-1">menu-2-1-1</label>
<input type="checkbox" id="menu-2-1-1" />
<ol>
<li class="file"><a href="">menu-2-1-1-1</a></li>
<li class="file"><a href="">menu-2-1-1-2</a></li>
<li class="file"><a href="">menu-2-1-1-3</a></li>
<li class="file"><a href="">menu-2-1-1-4</a></li>
<li class="file"><a href="">menu-2-1-1-5</a></li>
</ol>
</li>
<li class="file"><a href="">menu-2-1-2</a></li>
<li class="file"><a href="">menu-2-1-3</a></li>
<li class="file"><a href="">menu-2-1-4</a></li>
</ol> 
</li>
<li class="file"><a href="">menu-2-2</a></li>
<li class="file"><a href="">menu-2-3</a></li>
</ol>
</li>
</ol>
</div>

Customization:

No need to customize it. Just copy-paste. Rest edit the code as per comments and need. Remember to add JavaScript after HTML code.

Recommended For You:
A History Of HTML5 Past, Present And Future Via Infograph

Troubleshooting the Errors:

Do it with concentration and patience. Check your all steps and again and all codes or scripts. If you find any error you can contact us anytime via comment or better via email, We are always here to help you.

Final Words:

That’s all we have. We hope that you liked this article. If you have any problem with this code in your template then feel free to contact us with a full explanation of your problem. We will reply to you as time allows us If you have any doubts or problems please comment below. We are happy to help you! If you liked this article, Don’t forget to share this with your friends so they can also take benefit from it and leave.

You Like It, Please Share This Recipe With Your Friends Using...

Be the first to write a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *