Creating dynamic web pages using Django and HTML with navigation pills

My HTML includes Django template tags for different pills, each with its own content.

How can I make the corresponding CONTENT appear when clicking on each NAV-PILL?

NAV-PILLS

<div class="container-fluid bg-dark">
    <div class="container text-center">
        <ul class="nav nav-pills center-pills">
            {% for menu in menus %}
                {% if menu.mealtype == 'Breakfast' %}
                    <li role="presentation" class="active"><a href="#">Breakfast</a></li>
                {% endif %}
                {% if menu.mealtype == 'Lunch' %}
                    <li role="presentation"><a href="#">Lunch</a></li>
                {% endif %}
                {% if menu.mealtype == 'Dinner' %}
                    <li role="presentation"><a href="#">Dinner</a></li>
                {% endif %}
                {% if menu.mealtype == 'Supper' %}
                    <li role="presentation"><a href="#">Supper</a></li>
                {% endif %}
            {% endfor %}
        </ul>
    </div>
</div>

CONTENT

{% for menu in menus %}
<section id="services">
    <div class="container">
        <div class="row">
            <div class="col-lg-12 text-center">
                <h2 class="section-heading text-capitalize">{{ menu.title }}</h2>
                <hr class= "primary">
            </div>
        </div>
    </div>
    <div class="container">
        <div class="row">
            {% for item in menu.menuitem_set.all %}
            <div class="col-lg-3 col-md-6 text-center">
                <div class="service-box">
                    <h4>{{ item.item_name }} <strong>{% if item.price %}${{ item.price|floatformat:2 }}{% endif %}</strong><span><p class="text-muted text-muted-psize"><em>{{ item.description }}</em></p></h4>
                </div>
            </div>
            {% cycle '' '' '' '</div><div class="row">'%}
            {% endfor %}
        </div>
    </div>
</section>
{% endfor %}

Answer №1

Here is a suggestion for your layout:

<div class="container-fluid bg-dark">
    <div class="container text-center">

        <div role="tabpanel">
            <ul class="nav nav-pills center-pills">
                <li role="presentation" class="active">
                    <a href="#tab1" aria-controls="tab1" role="tab" data-toggle="tab">Morning</a>
                </li>
                <li role="presentation">
                    <a href="#tab2" aria-controls="tab2" role="tab" data-toggle="tab">Afternoon</a>
                </li>
                <li role="presentation">
                    <a href="#tab3" aria-controls="tab3" role="tab" data-toggle="tab">Evening</a>
                </li>
                <li role="presentation">
                    <a href="#tab4" aria-controls="tab4" role="tab" data-toggle="tab">Night</a>
                </li>
            </ul>
        </div>

        <div class="tab-content">

            <div role="tabpanel" class="tab-pane fade in active" id="tab1">
                <div class="panel panel-jumbotron panel-default">
                    <div class="panel-body">
                        <!-- Add content here for the morning tab -->
                    </div>
                </div>
            </div>

            <div role="tabpanel" class="tab-pane fade" id="tab2">
                <div class="panel panel-jumbotron panel-default">
                    <div class="panel-body">
                        <!-- Add content here for the afternoon tab -->
                    </div>
                </div>  
            </div>

            <div role="tabpanel" class="tab-pane fade" id="tab3">
                <div class="panel panel-jumbotron panel-default">
                    <div class="panel-body">
                        <!-- Add content here for the evening tab -->
                    </div>
                </div>  
            </div>

            <div role="tabpanel" class="tab-pane fade" id="tab4">
                <div class="panel panel-jumbotron panel-default">
                    <div class="panel-body">
                        <!-- Add content here for the night tab -->
                    </div>
                </div>  
            </div>

        </div>
    </div>
</div>

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

The CSS styles are not being applied to the PHP code

I seem to have a tangled mess of CSS / PHP / HTML to deal with. The issue I'm facing is that something works on one PHP script but not the other. Here's a snippet of my code: <?php if ($daten->getData_DB_User($get_page_num) != fa ...

What seems to be the issue with my code for Javascript Math functions?

Welcome to the number game slider! If you roll above 50, you will get double the amount bet. Use the slider to choose your desired betting amount. Issue 1: After a win, the score does not update correctly. Instead of showing increments of 5, it displays s ...

Tips for placing an image in the bottom right corner of a frame

My goal on the Roman Numismatics page is to place the yellow 'bid' button at the lower right corner of each frame. Current code <p><a href="<?= $product->page_url() ?>"><img border="0" alt="Bid&qu ...

Tips for minimizing the arrow size in the infowindow on a Google Maps interface

As a newcomer to customizing Google Maps, I am looking to decrease the size of the arrow in the infowindow and position it in the bottom left corner for a better appearance. I am struggling to figure out how to adjust the height and width of the arrow and ...

The toolbar in django CMS is not displayed during the login process

I am in search of a solution to prevent the CMS toolbar from automatically appearing when a 'staff-user' logs in, using version 3.3.0. The toolbar should only be displayed when the URL contains ?edit. The official documentation mentions the CMS_ ...

Identical HTML elements appearing across multiple DOM pages

My question might seem silly, but I'm facing an issue. I have several HTML pages such as index.html and rooms.html, along with a main.js file containing scripts for all of these pages. The problem arises because I have variables like const HTMLelemen ...

Users report text-shadow not working in Opera browser

Recently, I incorporated a text block into a section of my webpage that utilizes parallax scrolling. This particular text block has been styled to include a subtle text shadow effect. However, when viewing the page in Opera, I encountered an issue where I ...

Immersive full-screen YouTube video embedded as hero background

Seeking a solution in HTML & CSS to display this embedded video as a 75vh height hero background. Currently, the iFrame maintains its width: 100% and height: 75vh, but the images themselves do not cover the entire header width. Essentially, I want it ...

When a link has text-transform set to uppercase, the LinkText function may not work properly

While working on a project with Selenium, I encountered an issue where a test case created using the Selenium IDE and converted to WebDriver did not run as expected when executed using NUnit. Upon further investigation, I discovered that on the webpage be ...

The namespace 'chatterbot' has not been registered

After cloning the chatterbot API and attempting to run the django_app from examples using python manage.py runserver, I encountered an issue where it displayed 'chatterbot' is not a registered namespace. Could someone please explain this error an ...

Extending flexislider to cover the entire screen with adaptable images

The Dilemma I'm currently facing a challenge while using the FlexSlider plugin to create a full-page slider similar to the one on the Suzy Hoodless website. My issue lies in trying to get the images within my slides to stretch and fit 100% of the hei ...

Having trouble logging into the Django admin panel with a custom user model

My custom user model uses phone number as the username, but for some reason, I am unable to login to the admin panel. Please Note: I can successfully create a superuser through the CLI. However, when I attempt to log in, it shows an error message saying: ...

How can I implement pagination in a Django 1.8 web application?

Recently, I developed a Django (1.8) web project and incorporated MongoDB as my database backend. One of the functionalities I have implemented is displaying table data in a view, and now I am looking to add pagination for better navigation. Here is a sni ...

A step-by-step guide on converting RAW SQL queries to Django queryset operations

Struggling with conversion to Django query using raw SQL, new to Django and any assistance is appreciated. Simple models include: - Winemaker (target model) - Wine - Post Winemaker has one or more Wines Wine has one or more Posts Annotation should b ...

Having trouble sharing an image - error

I have a project in HTML where I need to send an image to a PHP script for uploading to a directory on the server. Here is the HTML form I am using: <form role="form" action="upload.php" method="post" enctype="multipart/form-data"> <div class="f ...

What are the reasons for Django's performance issues?

I have been diving into Django recently, following the guidance outlined in the book Python Crash Course. Despite my best efforts to meticulously follow each step and even resorting to restarting from scratch a few times (including reinstalling MacOS for a ...

Console command to change paragraph tag color---Modifying the color

I am attempting to change the color of all paragraph tags on a webpage to white by utilizing the console. My initial attempt was: document.p.style.color = 'white'; However, this method did not have the desired effect. Interestingly, I have had s ...

PHP Email Form Data Submission

I've been struggling to get a form set up that will send the information to the admin upon submission, but so far, nothing seems to be working. I double-checked my junk and spam folders, and even made sure that $admin_email = "" is correctly set to th ...

Keeping existing data intact while updating only the FileField column in Django

When working with Django, I defined a model: class List(models.Model): item = models.CharField(max_length=200) document = models.FileField(upload_to='documents/', null=True, blank=True) There's a specific page designed solely for up ...

Nested dropdown within a parent container with scrollable overflow

As part of a project, I am required to design a view where a drop-down menu is positioned at the bottom of a parent div. You can see an example here: http://jsfiddle.net/Gruck/6owhaa63/. The "move to" item expands to show more options, similar to the mocku ...