How can Bootstrap-Vue showcase an SVG image as a navigation item?

I need help positioning the Octocat image on the top right corner of a NavBar:

In the Vue Snippet below, the icon is currently only visible if there is text inside the <b-nav-item>:

<template>
  <div>
    <b-navbar toggleable="lg" type="dark" variant="dark">
      <b-navbar-brand href="#">NavBar</b-navbar-brand>

      <b-navbar-toggle target="nav-collapse"></b-navbar-toggle>

      <b-collapse id="nav-collapse" is-nav>
        <b-navbar-nav class="ml-auto">
          <b-nav-item> Test </b-nav-item>
          <!-- Icon not displayed -->
          <b-nav-item>
            <svg
              class="navbar-nav-svg"
              xmlns="http://www.w3.org/2000/svg"
              viewBox="0 0 512 499.36"
              focusable="false"
            >
              <title>GitHub</title>
              <path
                d="M256 0C114.64 0 0 114.61 0 256c0 113.09 73.34 209 175.08 242...
              </path>
            </svg>
          </b-nav-item>
        </b-navbar-nav>
      </b-collapse>
    </b-navbar>
  </div>
</template>

<script>
export default {
  name: "App",
};
</script>

Click here to view code in Codesandbox

Answer №1

It seems like you may have copied this code snippet from Vue Bootstrap without realizing that it is missing the navbar-nav-svg class:

<style scoped>
.navbar-nav-svg {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  vertical-align: text-top;
}
</style>

Answer №2

Your idea is solid, but I recommend including the height attribute in the svg tag for better design:

<svg
      class="navbar-nav-svg"
      xmlns="http://www.w3.org/2000/svg"
      viewBox="0 0 512 499.36"
      focusable="false"
      height="1rem"
            >

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

Struggling to comprehend the filtering arguments in VueJS?

While going through the VueJS Filter(orderby) API documentation, I came across some confusion regarding the arguments. Below is a sample for reference: Arguments: {String | Function} targetStringOrFunction "in" (optional delimiter) {String} [...s ...

Distinguishing Between ReactDOM.render and React Component Render

As I delve into learning React, I have come across the render() method being used in two different ways: Firstly, it is used with ReactDOM.render() ReactDOM.render( < Test / > , document.getElementById('react-application') ); Sec ...

Can you place more than one Twitter Bootstrap carousel on a single webpage?

Latest Version of Twitter Bootstrap: 2.0.3 Sample HTML Code: <!DOCTYPE html> <html dir="ltr" lang="en-US" xmlns:og="http://opengraphprotocol.org/schema/"> <head> <link rel="stylesheet" type="text/css" media="all" href="reddlec/style. ...

Verify whether the input is currently being focused on

My current issue involves an input field that requires a minimum number of characters. If a user begins typing in the field but then switches to another without meeting the character requirement, I would like to change the text color to red. I attempted u ...

What is the recommended way to compile SCSS module in a Vue component using Laravel Mix?

I recently attempted to set up the webpack configuration in my Laravel project. However, I encountered an issue where modular CSS was working perfectly fine without the lang="scss" attribute, but now I need to work with SCSS. I'm struggling to figure ...

JQuery - Unable to replace the old name with the new one

Hello, I am currently working on jQuery. I have a code snippet to update the project name. It includes an input field and a save button. The process involves fetching the current project name, displaying it in the input field, allowing for edits, and the ...

Expandable Bootstrap collapse and accordion open horizontally, not vertically

I want to use Bootstrap collapse but I want to keep my div-s with the content beneath each link, mainly because that's how i need it to work on mobile (the menu is a column and that the content opens under each link). Unfortunately, on website I have ...

JavaScript's version of "a certain phrase within a text"

If I'm working in Python and need to verify if a certain value is present in a string, I would use: if "bar" in someString: ... What would be the equivalent code in Javascript for this task? ...

Google AdSense is unable to detect code fragments within the header of a Next.js website

Hello, I've been trying to set up Google AdSense on my Next.js site, but AdSense doesn't seem to recognize it. I keep receiving an error saying that I need to place the code inside my headers. How can I properly implement this? Below is my _docum ...

Is it possible to update the .env file in the server for a generated Nuxt app without the need to regenerate the code?

Is it possible to modify the .env and the created nuxt app in order to detect any modifications, allowing for distinct variables for each server? ...

Vessel situated after the helm

There seems to be an issue with my toolbar and sidenav overlapping the contents of my container. I thought about adding a top margin to the container to fix the problem caused by the toolbar, but adjusting the sidenav in the same way creates display probl ...

Troubleshooting Vue and Typescript: Understanding why my computed property is not refreshing the view

I'm struggling to understand why my computed property isn't updating the view as expected. The computed property is meant to calculate the total price of my items by combining their individual prices, but it's only showing me the initial pri ...

Setting up the permanent class path for Nodejs in Linux Mint

Recently, I attempted to install Nodejs Version 6.9.4 on my Linux Mint system using the following steps: $ cd /tmp $ wget http://nodejs.org/dist/v6.3.1/node-v6.3.1-linux-x64.tar.gz $ tar xvfz node-v6.3.1-linux-x64.tar.gz $ mkdir -p /usr/local/nodejs $ mv ...

Setting up KaTeX integration (code injection) on Circle.so

In my quest to create an online hub for IB Math students, I've decided to utilize Circle.so as my platform of choice. The diverse range of features offered by Circle.so, such as code injection capabilities and sleek design, make it an appealing option ...

What is the best approach to manage dynamic regex values for input types within ngFor loop?

In my project, I have an array of objects containing details for dynamically generating input fields. I have successfully implemented the dynamic input field generation based on the type received from an API. However, I am facing a challenge with matching ...

The validation of Google Recaptcha is malfunctioning when used on a local server

Has anyone successfully validated Google reCAPTCHA on localhost? I'm having issues getting it to work properly. Any recommendations for the best solution? ...

The use of jquery UI.js is causing issues with loading select menus dynamically

When attempting to load a dynamically loaded select menu on my page using Ajax/PHP, I encountered an issue where the jquery UI plugin prevented the data from loading. As a result, I was unable to see anything when changing the first select menu. Below is ...

Establish a timeout period for ajax requests using jQuery

$.ajax({ url: "test.html", error: function(){ //do something }, success: function(){ //do something } }); At times, the success function performs well, but sometimes it does not. How can I add a timeout to this ajax re ...

The ReactJS component is unable to resolve the specified domain name

Whenever I utilize a component like const React = require('react'); const dns = require('dns'); class DnsResolver extends React.Component { componentDidMount() { dns.resolve('https://www.google.com', (err, addres ...