Skip to content
the poor coder

semantics ui complete responsive menu

Poor Man
Published
Reading time
3 min read
On this page

Semantic UI Complete Responsive Menu#

As a web developer, I have come across the need to create responsive menus for websites many times. One of the best ways to create a responsive menu is by using Semantic UI.

What is Semantic UI?#

Semantic UI is a popular front-end development framework that provides pre-designed HTML and CSS components. It allows developers to create responsive, mobile-first user interfaces with ease.

How to create a complete responsive menu using Semantic UI?#

First, we need to include the Semantic UI CSS and JS files in our HTML document:

Text
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js"></script>

Next, we can create the menu using Semantic UI's Menu component:

Text
<div class="ui stackable menu">
  <a class="item" href="#">Home</a>
  <a class="item" href="#">About</a>
  <a class="item" href="#">Services</a>
  <a class="item" href="#">Contact</a>
  <div class="right menu">
    <a class="ui item" href="#">Login</a>
    <a class="ui primary button" href="#">Sign Up</a>
  </div>
</div>

In the above code, we have used the stackable class to make the menu stack vertically on small screens. The right menu class is used to align the login and sign up buttons to the right of the menu.

We can also make the menu more interactive by adding dropdowns and submenus:

Text
<div class="ui stackable menu">
  <a class="item" href="#">Home</a>
  <div class="ui simple dropdown item">
    <span>Products</span>
    <i class="dropdown icon"></i>
    <div class="menu">
      <a class="item" href="#">Product 1</a>
      <a class="item" href="#">Product 2</a>
      <a class="item" href="#">Product 3</a>
    </div>
  </div>
  <div class="ui simple dropdown item">
    <span>Services</span>
    <i class="dropdown icon"></i>
    <div class="menu">
      <a class="item" href="#">Service 1</a>
      <a class="item" href="#">Service 2</a>
      <a class="item" href="#">Service 3</a>
    </div>
  </div>
  <a class="item" href="#">Contact</a>
  <div class="right menu">
    <a class="ui item" href="#">Login</a>
    <a class="ui primary button" href="#">Sign Up</a>
  </div>
</div>

In the above code, we have used the simple dropdown class to create dropdowns for the Products and Services menu items. The menu class is used to define the items in the dropdown menus.

Conclusion#

Semantic UI provides an easy and efficient way to create responsive menus for websites. By using the pre-designed HTML and CSS components, developers can create menus that are both functional and visually appealing. With the ability to add dropdowns and submenus, Semantic UI allows for a fully customizable and interactive user experience.

Keep going

2023

how to sort an array

How to Sort an Array If you have an array and you want to order its elements in a specific way, you need to use a sorting algorithm. There are several sorting algorithms available, but two of the most commonly used are…

javascript2 min read
2023

jquery mobile or desktop

jQuery Mobile or Desktop? As a web developer, I have had some experience with both jQuery Mobile and jQuery Desktop. Both frameworks have their pros and cons, and which one to use really depends on the specific project…

javascript1 min read
2023

node.js folder structure

Node.js Folder Structure If you are new to Node.js, it can be daunting to create a folder structure that will work for your project. The structure you choose will depend on the size and complexity of your project. Here…

javascript1 min read
ESC