Reputation: 7566
I would like to create a logic such as displayed in this image for an HTML form.
What is the easiest way to do it? The server is using express and imports a layout file as a header replacement with css settings that do not include bootstrap. I am a complete beginner in front dev and I was told combining two css style sources in one HTML is possible but causes problems.
can I do this without JS/Jquery? If not, could you please provide a minimal example how to do it?
Upvotes: 1
Views: 7610
Reputation: 2679
Yes it can be done using css and javascript.. here is the code..
ul {
list-style: none;
padding: 0;
margin: 0;
background: #1bc2a2;
}
ul li {
display: block;
position: relative;
float: left;
background: #1bc2a2;
}
li ul { display: none; }
ul li a {
display: block;
padding: 1em;
text-decoration: none;
white-space: nowrap;
color: #fff;
}
ul li a:hover { background: #2c3e50; }
li:hover > ul {
display: block;
position: absolute;
}
li:hover li { float: none; }
li:hover a { background: #1bc2a2; }
li:hover li a:hover { background: #2c3e50; }
.main-navigation li ul li { border-top: 0; }
ul ul ul {
left: 100%;
top: 0;
}
ul:before,
ul:after {
content: " "; /* 1 */
display: table; /* 2 */
}
ul:after { clear: both; }
<ul class="main-navigation">
<li><a href="#">Home</a></li>
<li><a href="#">Front End Design</a>
<ul>
<li><a href="#">HTML</a></li>
<li><a href="#">CSS</a>
<ul>
<li><a href="#">Resets</a></li>
<li><a href="#">Grids</a></li>
<li><a href="#">Frameworks</a></li>
</ul>
</li>
<li><a href="#">JavaScript</a>
<ul>
<li><a href="#">Ajax</a></li>
<li><a href="#">jQuery</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#">WordPress Development</a>
<ul>
<li><a href="#">Themes</a></li>
<li><a href="#">Plugins</a></li>
<li><a href="#">Custom Post Types</a>
<ul>
<li><a href="#">Portfolios</a></li>
<li><a href="#">Testimonials</a></li>
</ul>
</li>
<li><a href="#">Options</a></li>
</ul>
</li>
<li><a href="#">About Us</a></li>
</ul>
I didn't include any dynamic content but you will be able to do it through javascript using arrays.
Upvotes: 3