Multiple Row Menu built-in Bootstrap library.
When we have to create a responsive site easily & fast then we definitely choose Bootstrap. Because the most important elements we use in website building they are comes with Bootstrap. On many websites, you can see mega menus for showing more information to users. Big websites like school & e-commerce always use the mega menu, because they have lots of verity or categories.
To you will learn to create a multi-row dropdown menu using Bootstrap. These types of menus called Mega Menu, A mega menu contains image, forms,links, etc. But In this menu, we added links only you can add other this that’s not difficult. When you are using bootstrap then creating all is easy. If you don’t have knowledge of bootstrap then start learning now that’s very easy. Previously I have shared many types of menus you can check out those.
So, Today I am sharing A Bootstrap Mega Menu With CSS Responsive Design. Basically, This is a multi-row menu with Bootstrap, HTML, CSS, & JavaScript. I used JavaScript for creating the toggle button for the mobile version only, nothing else. You can remove JS if you don’t want toggle button for small screens.
If you are thinking now how this mega menu actually is, then see the preview given below.
Preview Of Responsive Multiple Row Menu
See this video preview to getting an idea of how this mega or multi-row menu looks like.
Bootstrap Mega Menu With CSS Source Code
Before sharing source code, Let’s talk about it. As you know I used bootstrap for creating this mega menu. With Bootstrap I used CSS @mediaquery to creating this responsive. For creating 3 rows I put col-md-4
, which is a bootstrap class for creating 3 rows. Actually, Bootstrap device the screen size in 12 parts (get info), what why I put col-md-4
because 4 multiply 3 equals 12.
In the CSS section, I put many things because there are lots of links and their styles. Like every section stylish, responsive values, colors, etc. The CSS part is very easy to understand, there are no difficult things or properties. There are lots of small conditions, that’s why I am not explaining that.
I used font-awesome for creating icons, Previously many time I have used this library for icons. As I told already, I just used JavaScript for creating a toggle button for small screens. In the small screen, there are no grid or multi-row menu, There options are all dropdown. When you click on the menu button on the mobile version, then all categories or links appear in dropdown order.
There is nothing to explain because they are basics also I put many links that’s why there is little difficult to explain. After getting the codes you will understand automatically, If you get any trouble to understand anything then you can ask me.
For creating this HTML CSS Bootstrap Mega Menu program, You have to create 3 files, First for HTML/Bootstrap, second for CSS, & the last one for JavaScript. Follow the steps to creating this without any error.
index.html
Create an HTML file named ‘index.html‘ and put these codes given below.
1 |
<!-- code by Ogbugbu Web Development Service ( https://web-design.ogbugbu-technologies.com.ng ) --> |
1 2 3 4 |
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <script src="function.js"></script> |
style.css
Now create a CSS file named ‘style.css‘ and put these codes by copy & pasting.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
body { font-family: 'Metrophobic', sans-serif; font-weight: bold; margin-top: 1rem; background: #fff; } #toggle-button { width: 100%; padding: 20px 0; } @media (min-width: 768px) and (max-width: 991px) { .menu-dropdown { margin-top: 4rem; } } @media (max-width: 767px) { .menu-dropdown { margin-top: inherit; } } @media (max-width: 767px) { #toggle-button { display: block; } .nav.nav-pills.pull-right { display: none; } a:first-child { color: #fbb016 !important; } a:first-child:hover { background-color: #222 !important; color: #fbb016 !important; } } @media (min-width: 768px) { #toggle-button { display: none; } .nav.nav-pills.pull-right { display: block; } } .nav { display: block; } .mega-menu { border: 3px solid #333; } .menu-dropdown { left: 0; right: 0; padding: 0; } .inside-menu { position: static !important; } .menu-section { margin-bottom: 30px; } .menu-head { color: #fbb016; border-bottom: 1px solid #ccc; padding: 15px 0; font-size: 20px; } .menu-head:first-child { margin-top: 15px; } .menu-head-icon-1 { height: 35px; float: left; font-size: 40px; margin-right: 10px; } .menu-head-icon-1 i { display: block; } .menu-head-icon-2 { margin-top: 6px; float: right; } .menu-head-title { margin-top: 6px; font-weight: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .menu-items { display: block; font-size: 17px; padding: 15px 0; border-bottom: 1px solid #ccc; color: red; transition: all .3s ease; } .menu-items:link { text-decoration: none; color: #444; } .menu-items:visited { text-decoration: none; color: #444; } .menu-items:hover { text-decoration: none; background: #f2f2f2; color: #444; padding-left: 10px; } .menu-items:active { text-decoration: none; color: #444; } .menu-items-icon-a { float: right; color: #fbb016; } .items-title { font-weight: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } @media (max-width: 767px) { .mega-menu { border: 0; } .menu-section { margin-bottom: 10px; } .menu-head { display: none; } .menu-items-icon-a { display: none; } .items-title { font-size: 14px; padding-left: 15px; } .mega-menu .main-container + * { display: block !important; } .inside-menu { position: relative !important; width: 100%; } .inside-menu .caret { display: none; } .menu-dropdown { display: block !important; position: relative !important; width: 100% !important; border: none !important; box-shadow: none; } } a { color: #333 !important; margin-top: 2px; } a:hover, .nav .open > a, .nav .open > a:focus, .nav .open > a:hover { color: #fbb016 !important; } |
function.js
The final step, Create a JavaScript file named ‘function.js‘ & put the codes.
1 2 3 4 5 6 7 8 9 |
$(function() { $(document).on('click', '.dropdown-menu', function(e) { e.stopPropagation() }) }) $( "#toggle-button" ).click(function() { $( ".nav.nav-pills.pull-right" ).slideToggle("slow"); }); |