Achieving a balanced css navbar size that fits the page dimensions

I'm encountering an issue with my navbar where it gets distorted when the window size is too small. How can I make it shrink proportionally to fit the page? I've attempted several solutions, but they only reduce the text size without properly resizing the navbar.

Below is the HTML code:

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

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
</head>

<body>
  <header id="nav-wrapper">
    <nav id="nav">
      <div class="nav left">
        <span class="gradient skew">
          <h1 class="logo un-skew"><a href="#home">RiseUpOnario.ca</a></h1>
        </span>
        <button id="menu" class="btn-nav"><span class="fas fa-bars"></span></button>
      </div>
      <div class="nav right">
        <a href="#home" class="nav-link active"><span class="nav-link-span"><span class="u-nav">Home</span></span></a>
        <a href="#blog" class="nav-link"><span class="nav-link-span"><span class="u-nav">Blog</span></span></a>
        <a href="#join" class="nav-link"><span class="nav-link-span"><span class="u-nav">Join</span></span></a>
        <a href="#donate" class="nav-link"><span class="nav-link-span"><span class="u-nav">Donate</span></span></a>
        <a href="#mppfiner" class="nav-link"><span class="nav-link-span"><span class="u-nav">MPP Finder</span></span></a>
        <a href="#aboutus" class="nav-link"><span class="nav-link-span"><span class="u-nav">About Us</span></span></a>
        <a href="#contact" class="nav-link"><span class="nav-link-span"><span class="u-nav">Contact</span></span></a>
      </div>
    </nav>
  </header>
  <main>
    <section id="home">
    </section>

    <section id="blog">
    </section>

    <section id="join">
    </section>

    <section id="donate">
    </section>

    <section id="mppfinder">
    </section>

    <section id="aboutus">
    </section>

    <section id="contact">
    </section>
  </main>

</body>

</html>


<style>
/* Your custom CSS goes here */

</style>



<script>
// Your JavaScript code goes here

</script>

Answer №1

Consider utilizing the percentage unit in your CSS to style fonts and div elements more effectively! For instance, if you want text or a container inside another container to resize proportionally when the parent container is resized, you can specify your interior elements like this:

elementName{ max-width: 75%}

Give it a try to see if it improves the styling of elements within the navigation wrapper.

Answer №2

To adjust the height of the navbar, consider setting it to 10vh or experimenting with different values. The unit "vh" represents a percentage of the viewport height, while "vw" does the same for viewport width.

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

Sliding in the wrong direction on Bootstrap 5.2 carousel

I'm currently working on a carousel project. However, I encountered an issue where the images slide down initially and then jump up to the correct level as depicted in the image below. I've tried adjusting the height, width, and auto settings to ...

Unable to apply inset box-shadow to image

I've added a box-shadow to my image. box-shadow: 0 0 10px RED inset However, the shadow is not showing up on the image. When I use Firebug to change the image path, I can see that the shadow is behind the image. How can I apply the shadow directly ...

Looking to implement a condition that prevents the echoing of HTML code when a certain template ID is selected?

Struggling with inherited PHP MVC code for a website, I encounter an issue on a specific page where unwanted code is echoed out. To prevent this, I aim to skip the echoing when a specific templateID (which I set as default) is selected. However, I'm u ...

What could be causing my tabs (such as HOME, ABOUT ME..) not displaying the correct paragraph or section content?

I have set up navigation tabs on my website using anchor tags, but they are currently not linked to any specific paragraphs. I want the corresponding paragraph to be displayed when a tab is clicked, but I'm unsure how to add this functionality using j ...

Tips for fixed positioning of a div on a webpage without being affected by the Windows logo shortcut keys + Left/Right arrow

Whenever I utilize the keyboard shortcuts to move a window from one side of the screen to another and then minimize it either upwards or downwards, I find myself faced with an issue. I can accomplish this action by using the Windows key in combination with ...

Retrieve the hidden input values from a div using jQuery

Currently, I am in the midst of a project using CakePHP with jQuery and AJAX. Within this project, I have a div that is being repeated in a PHP loop. Here is what the div looks like: <div class="heart"> <input type="hidden" i ...

Remove information inside table cells <td> when the table is in edit mode by using JavaScript or jQuery

I am facing an issue where I need to clear the data in a HTML td onfocus, especially in an editable table using JQuery tabledit. The table is populated with data from a database and I want to be able to edit a td without having to manually delete the exist ...

Retrieving Dropdown Value in Bootstrap 5: How to Obtain the Selected Item's Value from the Dropdown Button

I am having a slight issue with my dropdown button where I am trying to display the selected item as the value of the dropdown button. The Flag Icon and Text should be changing dynamically. I have tried some examples but it seems that it is not working as ...

I need to connect data to a textarea element within an ASP.NET MVC view

<div class="col-md-6"> <label>Share Your Business, Accomplishments & Dreams (500 Words Maximum)</label> <textarea name="Description" type="text" placeholder="SHARE YOUR BUSINESS, ACCOMPLIS ...

Unresolved dependencies causing a rollup error

When I try to use import file from 'file.json' in a Vue component and run npm run build to bundle it with Rollup, I encounter an issue. An error is thrown during the process, preventing the file from being bundled as expected. https://i.sstatic ...

Clickable links and compliant W3C coding

Recently, I have encountered errors in the W3C validator due to the presence of "name" attributes in some <a> tags in my document. The validator flagged these attributes as obsolete. I am curious to know when and why this happened? Additionally, I n ...

Where am I going wrong in my attempts to use a callback function?

I am currently attempting to implement a callback function for this particular JavaScript function. function Filtering_GetSite(siteElement) { $.ajax({ type: "POST", url: "samle.asmx/f1", data: "", contentType: "application/json; charset= ...

AngularJS inputs using ng-model should be blank when in the pristine state

Check out this input element within an HTML form: <input ng-model="amount" /> Currently, the input displays as $scope.amount = 0 in the controller. I want to start with a blank input field instead. This way, users can easily input data without havi ...

When using ESLint together with React, you may encounter errors related to `no-unused-vars

I've configured eslint and eslint-plugin-react. After running ESLint, I'm encountering no-unused-vars errors for all React components. It seems that the linter is not recognizing JSX or React syntax. Any solutions? For example: app.js import ...

Could you explain the distinction among req.path, req.params, and req.query?

I'm curious about the distinctions among req.path, req.params, req.query, and req.body in node.js. Can someone provide an explanation? ...

Passing the index in React Native

I am currently developing a music app utilizing the react-native-track-player library. I have created three components named Clusters, Songlist, and Play. Understanding How the Screen Works The flow of components is as follows: Clusters component -> S ...

Crafting a unique image size for an ACF gallery: A step-by-step guide

I'm currently utilizing the capabilities of Advanced Custom Fields to build an image gallery. I originally had the image size set to thumbnail, but when I tried setting it to medium it didn't seem to work, leaving me unsure if there was something ...

Building a sleek grid similar to Pinterest in Bootstrap v4.0 without relying on jQuery (using a black color scheme with equal width and varying height)

Is it feasible to craft a grid similar to Pinterest using Bootstrap 4? I am aware of the jQuery plugins that can be used, but is there a way to achieve this purely with CSS? Note: This is not a duplicate question. Please try to comprehend my query first ...

Revamp local route variables in Express.js without the need for a page refresh

Currently, I am working on a project using node.js along with the express.js framework and EJS for template handling. Below is my routing code: app.get('/',function(req,res) { res.render('index', { matches: [], status_messag ...

I am looking to gzip compress a file using Vue.js and then send it to the backend server

I recently installed npm install compressing and encountered an error message regarding the 'fs' module. How can I zip a file in Vue.js 2.6? Uncaught Error: Cannot find module 'fs' at webpackMissingModule (webpack:///./node_modules/ ...