Is there a way to create a collapsible menu in Semantic UI?

This is my customized menu using Semantic UI, which is stackable for mobile devices. I am looking to make it collapsible on low resolutions such as mobile devices. Here is an example of what I'm aiming for: https://i.sstatic.net/6qHuc.png

Could anyone provide guidance on how to achieve this? Thank you

<!DOCTYPE html>
<html lang="en">

<head>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.10/semantic.min.css"
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
   
</head>

<body>

  <div id="container" class="ui fluid container">

    <div id="navbar" class="ui stackable yellow inverted menu">
      <div class="item">
        <img src="assets/images/logo.png">
      </div>
      <a class="item" href="">Page1</a>

      <div class="ui pointing dropdown link item">

        <span class="text yellow inverted">Page 2</span>
        <i class="dropdown icon"></i>

        <div class="menu">
          <a class="item" href="">Small</a>
          <a class="item">Medium</a>
          <a class="item">Large</a>
        </div>
      </div>

      <a class="item" href="">Page 3</a>
      <a class="item" href="">Page 4</a>
      <a class="item" href="">Page 5</a>
    </div>

  </div>



   <script src="semantic/dist/semantic.min.js"></script>
  <script>
    $('.dropdown').dropdown({
      transition: 'drop',
      on: 'hover'
    });
  </script>
</body>

</html>

Answer №1

One idea could be to place all elements inside a container with the id of "hiddable" and use a CSS media query:

@media only screen and (max-width: 320px){

       #hiddable { display:none }

}

You can also include this JavaScript snippet:

$( ".dropdown" ).click(function() {
  $("#hiddable").show();
});

to achieve a similar effect.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can Eclipse PDT be integrated with a Javascript IDE?

My current setup in Eclipse PDT for PHP allows me to work with HTML, CSS, and JavaScript, but I have noticed that there is no error code checking feature for JavaScript. Can anyone suggest a plugin or tool that I can download into my Eclipse IDE to help ...

What could be causing my PHP login page to malfunction?

I'm facing an issue with my code where nothing happens when I click the submit button. This is puzzling as the same code worked perfectly fine in a previous project. I'm unable to pinpoint where the problem lies. Here's the HTML form: < ...

I am attempting to create a basic animation using jQuery

Currently, I am working on animating a div. What I am aiming for is that when a user clicks a button, I want to hide one div and display another div that is the next child element. If you would like to see my progress so far, check out this fiddle. My in ...

Choose a specific item by its name and retrieve its corresponding identifier using Angular

In my current MVC project using HTML and angular, I am facing an issue with a select list. The list is supposed to be selected based on the name entered in an input box, but unfortunately, I am unable to retrieve the id associated with the selected item. ...

Display the desired labels on the x-axis using the labels formatter function

Having a set of plotLines, I am looking to display corresponding labels on my xAxis. The data consists of random values around 100 (yAxis) and dates that increment by 10 days (xAxis). var getDaysArray = function(start, end) { for (var arr = [], dt = st ...

Navigate through the components of an array within HTML

I am a beginner in HTML and I need to customize a specific piece of code to suit my requirements. Here is the code snippet written in pseudo code: <app-myapp *ngIf="true" [exclude] = "[this.myUser.id]" ...

What is the best way to iterate through anchor links surrounding an image and dynamically load content into the figcaption element using AJAX?

Seeking assistance for an issue related to my understanding of the $this keyword in jQuery. I am facing a problem where I have 3 images on a page, each wrapped in an anchor link. My goal is to loop through these links, retrieve the URL of each anchor lin ...

Where can I find the link to access three.js on the internet?

Currently working on a JavaScript application within Google App Engine using three.js, but struggling to find the URL for online inclusion in my document. Uploading the entire large-sized three.js package is not ideal, so I'm looking for a way to obta ...

The JavaScript code is failing to retrieve any data from the API

import React, { Component } from 'react'; export class FetchData extends Component { static displayName = FetchData.name; constructor(props) { super(props); this.state = { users: [], loading: true }; } componentDidMount() { ...

When I attempt to press the shift + tab keys together, Shiftkey is activated

Shiftkey occurs when attempting to press the shift + tab keys simultaneously $("#buttonZZ").on("keydown",function (eve) { if (eve.keyCode == 9 && eve.shiftKey) { eve.preventDefault(); $("#cancelbtn").focus(); } if (eve. ...

The passport authentication process is malfunctioning as there seems to be an issue with the _verify function

Having an issue and could use some assistance. I am currently implementing passport in my express application. While I am able to successfully register a user, I encounter an error when trying to log in. TypeError: this._verify is not a function at Str ...

Resolving the issue of "Cannot GET" error with Node.js and Express

I have a class named Server in Server.js: const express = require('express'); class Server { constructor() { this.app = express(); this.app.get('/', function(req, res) { res.send('Hello World&apos ...

Difficulties arise when dealing with card elements and scrolling on a

Currently working on an ecommerce simulation project for a course, I successfully implemented a featured section with cards. However, when it comes to scrolling, I am facing an issue where the cards overlap with my sticky navbar as I scroll down. If anyo ...

Obtain JSX content from a React Component that has been imported

As part of our library documentation efforts, I am looking to convert a React Component function into JSX format. To illustrate, let's consider a rendered Button component and showcase the code used to create it. One approach could be to simply read ...

Tips for formatting a phone number using regular expressions in [Vue 2]

I am currently working on creating regex code that will meet the following requirements: Only allow the first character (0th index) in a string to be either a '+' symbol or a number (0-9). No non-numerical values (0-9) should be allowed anywhere ...

Selecting CSS tag excluding the first-child element

My goal is to use CSS to target the li elements in a list that do not have a description and are not the first-child with a b element. I want to apply padding-left to these specific li elements that do not have a title. <ul> <li><b>t ...

Display <div> exclusively when in @media print mode or when the user presses Ctrl+P

Looking for a way to create an HTML division using the div element that is only visible when the print function is used (Ctrl+P) and not visible in the regular page view. Unfortunately, I attempted the following method without success. Any advice or solut ...

Is it possible to modify the state of a function component from a different function in React?

React 16.8 introduced the state and setState features to function-based components. Here's my query: If we have a Function based component, is there any way to modify its state from outside the function? For instance: import {useState} from &apos ...

With NodeJs, Mongoose refrains from storing any data in the database

Recently, I encountered a puzzling issue with my code designed to store superhero names and powers in a database. Despite all the connections functioning correctly, I faced an unexpected challenge. When running mongod, I utilized the --dbpath C:/nodeproje ...

Select value not updating as expected

I have a select box that is linked to a switch statement in PHP, which changes the order of the results returned from the database based on the value selected in the select box. However, I am facing an issue with my JavaScript not working correctly. Can an ...