Whenever I adjust the layout of the navigation bar, the edges end up getting clipped

I'm having trouble with the border shape of my navbar. When I try to make it a rounded pill shape, the edges get cut off instead of being properly displayed. https://i.stack.imgur.com/sUN2Y.png

Below is the HTML template:

<template>
<div class="navbar-container rounded-pill">
    <nav class="navbar navbar-expand-lg navbar-light bg-light">
        <div class="container-fluid">
            ...
        </div>
    </nav>
</div>    
</template>

And here's the CSS:

<style scoped>
@import url('https://fonts.googleapis.com/css2?family=Pacifico&display=swap');
.navbar-container {
    box-sizing: border-box;
    margin: 0.5rem;
    height: 100%;
    width:60%;
    border: 2px solid red;
    margin-left: 20%;
    background-color: transparent;
}

nav {
    background-color: white !important;
    font-size: 1.3rem !important;
}

nav ul li a {
    padding-inline: 1rem !important;
}
</style>

The issue arises when I try to achieve a pill-rounded shape for the navbar. Everything works fine in a square shape, but I can't seem to make it work using Bootstrap classes and CSS border radius.

Answer №1

Make sure to add the rounded-pill class to the navbar element, or you can apply the same border-radius value to both the navbar-container and navbar classes without using rounded-pill:

new Vue({
  el: '#demo',
})
.navbar-container {
  box-sizing: border-box;
  margin: 0.5rem;
  height: 100%;
  width: 60%;
  border: 2px solid red;
  margin-left: 20%;
  background-color: transparent;
  border-radius: 1em;
}
.navbar {
  border-radius: 1em;
}
nav {
  background-color: white !important;
  font-size: 1.3rem !important;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9dfff2f2e9eee9effceddda8b3acb3ae">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div id="demo">
  <div class="navbar-container">
    <nav class="navbar navbar-expand-lg navbar-light bg-light">
      <div class="container-fluid ">
        <a class="navbar-brand" href="#"></a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
           <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
          <ul class="navbar-nav mx-auto">
            <li class="nav-item text-center">
              <a class="nav-link" href="#">111</a>
            </li>
            <li class="nav-item text-center">
              <a class="nav-link" href="#">222</a>
            </li>
            <li class="nav-item text-center">
              <a class="nav-link" href="#">333</a>
            </li>
            <li class="nav-item text-center">
              <a class="nav-link" href="#">444</a>
            </li>
          </ul>
        </div>
      </div>
    </nav>
  </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

Will there ever be a possibility in the future to compile from D 2.0 to Javascript?

An experienced C++ programmer (that's me) is venturing into other programming languages and considering the value of learning more about D 2.0. The clean, fresh rewrite of D has caught my eye with its pragmatic and wise choices. Now, I'm eager to ...

default browser's drag and reposition feature

I'm trying to make an image draggable on my webpage by using default browser behavior, but it's not working for some reason. Here is the code snippet I'm using: <div style="position:relative;width:1000px; height:900px;border:solid;z-inde ...

What are some creative ways to generate revenue from my PWA through the Google Play Store, specifically by utilizing Trusted Web

Hey there, I'm currently busy working on a Vuejs (Quasar) PWA and planning to release it on the play store with TWA. I have some concerns about monetization through AdSense. I need to include the Google script in the head tag of my index.html for the ...

Exploring AngularJS: Effortlessly Retrieving Object Values

HTML: <div ng-app = "" ng-controller = "personController"> <p>Persoon: <select ng-model="persoon"> <option ng-repeat="person in persons">{{person.FirstName}} {{person.FamilyName}}</option> & ...

In Chrome, the $http GET request fails to send the JSESSIONID, but it functions properly on Firefox with AngularJS

Here is the code snippet I am working with: $http({ 'method': 'GET', 'url': 'http://www.example.com', 'withCredentials': true, headers: { 'Content-type': &apo ...

Using Firebase callable functions with React Native

Can I use Firebase callable functions with React Native? I have successfully deployed an onCall function and it is visible in my dashboard. I have initialized the functions using: // Initialize Cloud Functions through Firebase firebase.functions(); The ...

Guide on how to reload the page with its initial URL after the URL has been modified using history.pushState()

After utilizing history.pushState(), I encountered an issue where the page would refresh with the current URL instead of the original one when the user refreshed the page. I attempted to detect a page refresh using methods such as cookies and hidden field ...

Utilizing asynchronous functions to assign a JSON dataset to a variable

Having an issue here! I've created a function to retrieve data from a local JSON file on my server. The problem is that the data is returned asynchronously, so when I try to set it to a variable for later use, it always ends up being undefined. I don& ...

What is the best way to extract the value from a resolved Promise?

Currently, I am attempting to read a file uploaded by the user and convert it into a String using two functions. The first function is handleFileInput: handleFileInput(event){ setTimeOut(async()=>{ let abcd= await this.convertFileToString(this.fi ...

Traversing a JavaScript class within a for loop

I am attempting to access the locations listed in json.responseJSON.Sites, starting with LHR on the first iteration and then NJE on the next one, and so forth. The notifications for each location are "LHR" and "NJE", respectively. Is it possible to achieve ...

Difficulty with a proprietary third-party API causing CORS issues in a VUEJS application

I have come across many articles and Q&As discussing CORS and how to address it, but dealing with a private third-party API can be quite overwhelming. I've been trying to resolve this issue for some time now without success, experimenting with various ...

What is the best way to manage communication with a database in a Node.js application?

I have a specific structure in my Express app: There is a db helper that I use to interact with my MariaDB database Here is the code snippet: var MariaSQL = require('mariasql'); var db = new MariaSQL(); var queries = { getUserByID : &a ...

Mouse click failing to trigger CSS property update

I am attempting to create an accordion feature. I want the accordion to expand when hovering over the "accordion head," and also show/hide the accordion body when clicking on the "accordion head." I have successfully implemented the show/hide functionalit ...

jQuery does not support CSS pseudo-code

I'm having trouble with my CSS pseudo-code not being recognized by jQuery. Here is the code I'm using: CSS: h1 { background: red; width: 100px; display: inline-block; } h1:after { content:" | "; background:blue; display ...

What is the reason for browsers changing single quotation marks to double when making an AJAX request?

Jquery: var content = "<!DOCTYPE html><html lang='en'><head><meta charset='utf-8'><meta http-equiv='X-UA-Compatible' content='IE=edge'><meta name='viewport' content='w ...

Enhance your Vue.js application by dynamically adding a class when a computed value

Just delving into the world of vue.js and I have a simple query. I've been following a tutorial but now I'd like to add my own touch to it :-P Whenever there is a change in my rank, I would like to include a CSS class for animating the label. Ho ...

Updating textbox values with ajax results in the page refreshing and the newly assigned values being lost

I'm currently working on updating a section of my webpage using AJAX instead of C#, as I don't want the page to refresh. All I need to do is execute a SELECT query to retrieve the current client from the SQL database and populate the correspondin ...

Download files from Firebase storage to a user's device

I have a variety of files such as images, videos, and audio stored in my firebase storage. My goal is to provide users with the ability to download these files to their computers by clicking on a download button. After reviewing the firebase documentation ...

Vue.js is encountering an issue with NeDB where it is unable to locate the database files

Creating a Vue project: vue init webpack-simple nedbtest Installing the Nedb database: npm i nedb -S Modifying App.vue : <template> <div> <button @click="insert">Insert Data</button> <button @click="find">Find D ...

How to remove an event listener when e.target points to a hyperlink

element, I encountered an issue using a slideshow component sourced from our components library. This component receives swipe events from a utility function that is initialized upon mounting. The problem arose while testing on a mobile phone - tapping a ...