Guide to Aligning Logo Beside Title at Equal Height Using Vue.js and Bootstrap

export default {
  name: 'Sidebar'
};
#logo {
  margin: 20px auto;
  display: block;
  width: 50%;
  border: none;
}

.nav-item a {
  color: #83888c;
  font-size: 18px;
}

.nav-item {
  justify-content: space-around;
}

.data-uri-logo1 {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cg id='backup_24px'%3E%3Cpath id='icon/action/backup_24px' fill-rule='evenodd' clip-rule='evenodd' d='M19.35 10.04C18.67 6.59 15.64 4 12 4C9.10999 4 6.59998 5.64001 5.34998 8.04001C2.33997 8.35999 0 10.91 0 14C0 17.31 2.68994 20 6 20H19C21.76 20 24 17.76 24 15C24 12.36 21.95 10.22 19.35 10.04ZM...opacity='0.54'/%3E%3C/g%3E%3C/svg%3E");
  height: 2rem;
  width: 2rem;
  background-repeat: no-repeat;
  justify-content: space-around;
}

.title-section {
  display: flex;
}
<template>
    <div>
        <b-sidebar id="sidebar" aria-label="Sidebar " no-header width="300px">
            <template #footer="{ hide }">
                <b-button size="sm">Collapse</b-button>
                <b-button size="sm" @click="hide">Logout</b-button>
            </template>

<div>
  <b-img id="logo" :src="require('./../assets/logo.png')" thumbnail></b-img>
</div>

<div>
  <b-nav vertical>
    <div class="title-section">
      <div class="data-uri-logo1"></div>
      <b-nav-item>title1</b-nav-item>
    </div>
    <div class="title-section">
      <div class="data-uri-logo1"></div>
      <b-nav-item>title2</b-nav-item>
    </div>
    <div class="title-section">
      <div class="data-uri-logo1"></div>
      <b-nav-item>title3</b-nav-item>
    </div>
    <div class="title-section">
      <div class="data-uri-logo1"></div>
      <b-nav-item>title4</b-nav-item>
    </div>
  </b-nav>
</div>
</b-sidebar>
</div>
</template>

Here is my current progress:

https://i.sstatic.net/kFXbT.png

I am striving to achieve the same layout as shown in the image below.

https://i.sstatic.net/uQeaJ.png

I have attempted to use flexbox to reach my desired design, but it isn't working as expected. Any assistance would be greatly appreciated! What is the proper approach to accomplish my objective? The b-nav-item in the DOM tree is simply an <li> element with a link. I have also tried inserting images directly into the b-nav-item tag, but they do not render correctly.

Answer №1

#logo {
    margin: 20px auto;
    display: block;
    width: 50%;
    border: none;
}
.nav-item a {
    color: #83888c;
    font-size: 18px;
}
.nav-item {
    justify-content: space-around;
}
.data-uri-logo1 {
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cg id='backup_24px'%3E%3Cpath id='icon/action/backup_24px' fill-rule='evenodd' clip-rule='evenodd' d='M19.35 10.04C18.67 6.59 15.64 4 12 4C9.10999 4 6.59998 5.64001 5.34998 8.04001C2.33997 8.35999 0 10.91 0 14C0 17.31 2.68994 20 6 20H19C21.76 20 24 17.76 24 15C24 12.36 21.95 10.22 19.35 10.04ZM19 18H6C3.79004 18 2 16.21 2 14C2 11.95 3.53003 10.24 5.56006 10.03L6.63 9.92001L7.13 8.97C8.07996 7.14001 9.93994 6 12 6C14.62 6 16.88 7.85999 17.39 10.43L17.6899 11.93L19.22 12.04C20.78 12.14 22 13.45 22 15C22 16.65 20.65 18 19 18ZM10.55 13H8L12 9L16 13H13.45V16H10.55V13Z' fill='black' fill-opacity='0.54'/%3E%3C/g%3E%3C/svg%3E");
    height: 2rem;
    width: 2rem;
    background-repeat: no-repeat;
    justify-content: space-around;
    
    /* -> */ background-position: center;
}

.title-section {
    display: flex;
    
    /* -> */ align-items: center;
}
    <div>
        <b-sidebar id="sidebar" aria-label="Sidebar " no-header width="300px">
            <template #footer="{ hide }">
                <b-button size="sm">Collapse</b-button>
                <b-button size="sm" @click="hide">Logout</b-button>
            </template>

            <div>
                <b-img
                    id="logo"
                    :src="require('./../assets/logo.png')"
                    thumbnail
                ></b-img>
            </div>

            <div>
                <b-nav vertical>
                    <div class="title-section">
                        <div class="data-uri-logo1"></div>
                        <b-nav-item>title1</b-nav-item>
                    </div>
                    <div class="title-section">
                        <div class="data-uri-logo1"></div>
                        <b-nav-item>title2</b-nav-item>
                    </div>
                    <div class="title-section">
                        <div class="data-uri-logo1"></div>
                        <b-nav-item>title3</b-nav-item>
                    </div>
                    <div class="title-section">
                        <div class="data-uri-logo1"></div>
                        <b-nav-item>title4</b-nav-item>
                    </div>
                </b-nav>
            </div>
        </b-sidebar>
    </div>

Primarily, adjust the background image for better aesthetics.

/* -> */ background-position: center;

In addition, ensure the content is centered within the flex layout surrounding the image and text.

/* -> */ align-items: center;

All script snippets can be found above.

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

How is it possible that this React setter is effectively working despite the fact that it is within a stale closure

I've come across this interesting function that I need help understanding. The randomize function seems to be consistent in its behavior despite multiple renders, thanks to being wrapped in a useCallback. Each time the randomize button is clicked, it ...

Combining httpProvider responseInterceptor with $http error callback does not function properly

In my application, I implemented a "loading screen" feature inspired by this post: 'Click' However, I am facing an issue where all $http requests are triggering the "success" callback, even for URLs that do not exist. $http.post("this doesnt ev ...

AngularJS is failing to render elements stored within an array retrieved from MongoDB

My AngularJS application is not displaying the "tracking" entry from the data structure as expected. It appears as an empty array both in the HTML template and when logged to the console. The API returns the following data: [{ "_id": "57e96aaa45b09843a53 ...

Attempting to utilize jQuery for altering the background URL leads to the unexpected removal of the -webkit-background-clip:text; effect

Can the -webkit-background-clip:text; effect be preserved when using jQuery to switch the background url? I am experiencing issues where changing the URL removes the text clipping effect. jQuery(function($) { var whatToSwitch = $('.homepage_ove ...

Adding an <a> tag or icon within Vuetify internationalization: Tips and Tricks

I am currently immersed in a project utilizing Vuetify. My challenge lies in creating an internationalized text that includes both an <a> tag and an icon. While inserting a variable is straightforward as shown below, this.$vuetify.lang.$t('I&ap ...

Using Angular 6 to render an HTML tag using the ngFor directive and incorporating interpolation

I am facing a challenge with template rendering in Angular 6 and a library for creating floating panels called jsPanel 6, which is written in plain JavaScript. Essentially: After my template is rendered, I have a BUTTON that triggers the following functio ...

Embedding an image within an HTML textbox using the textboxfor method

Looking to elevate the aesthetic of my project, I decided to incorporate a watermark into my @html.textboxfor. However, despite successfully adding it, I encountered an issue with compatibility on IE 8. As a solution, I aim to include an image within the @ ...

Convergence phenomenon in SVG when two distinct paths intersect

Working with individual SVG paths and in need of a mitre effect when there is a path join, which is a new concept for me. The SVG shape resembles a polygon, with each side as its own individual path. Although the sample SVG code provided does not display ...

What is the method for implementing absolute paths rather than relative paths in a React or Next.js project?

In my React project, I frequently use multiple components within various higher-order components. This often leads to long import paths like import MyComponent from '../../../../components/MyComponent'. I am aware that there is a more efficient w ...

Send PHP data through AJAX and retrieve it on a different PHP page

I need to send a variable through an AJAX URL to another PHP page and retrieve it using: $id=$_GET['id']; Here's an example where the value is passed, for instance $id=6. <a id="pageid" href="ifsc-bank.php?id=<?=$id?>"><im ...

Utilizing rvest to extract user videos from Twitter

When using rvest to extract data from websites, I found that I am unable to scrape dynamic content. For instance, how can I extract the audience count (44K) from this video post? https://i.sstatic.net/CRXZ9.png Here's what I attempted: library(rves ...

Avoiding "Origin null is not allowed" error in Express.js POST request

I am attempting to send JSON data containing a set of key and values from JavaScript to Express.JS. Following advice from other posts, I have included the use of CORS and also added res.header("Access-Control-Allow-Origin", "*");. When testing the POST r ...

Determining the Number of Sub-Menu Items Using jQuery without Reliance on CSS Classes

I've scoured the depths of Google and SO in search of answers, but nothing quite fits the bill. My mission is to create a submenu without using classes, adding a style attribute to each individual <li> within the sub <ul> that sets a min- ...

Am I using async/await correctly in this code?

Here is the code snippet I am currently working with: var process = async (items: DCXComposite[], session: Session) => { // This function returns a response object with a statusCode property. If the status Code is 200, it indicates a ...

PUT Request Disallowed by Django Rest in Conjunction with Vue.js Frontend

I am attempting to send a PUT request to my RestAPI using Vue.js. It functions perfectly in my ModelViewSet view, but I am facing an issue of Method Not Allowed (PUT) when trying it through Vue.js. Interestingly, I can use "POST" within the same onSubmit f ...

Problem with Jquery HTML CSS Slideshow

Currently I am working on integrating two sliders into one webpage using the demo available at . One of the sliders is customized from the Linking demo and I have named them slider1 and slider2 with different styling using global.css for slider-1 and text. ...

There appears to be a malfunction with WebRupee

I have incorporated the new rupee sign into my website to represent Indian currency. Below is the code snippet I used: For the script, I included " and also added the following: <span class="WebRupee">Rs.</span> 116,754.00 To style it using ...

What is the best way to create a slideshow that automatically starts upon loading and pauses when hovered over?

I have recently set up a div element for my slideshow. I've included a script to enable navigation using next and previous arrows. However, I am looking to add an automatic slideshow feature that stops on hover. As a beginner, I would appreciate any a ...

How can I transfer request headers from Express to index.js in React?

Is there a way to store user-related information received in the request headers of the Express server as a runtime variable accessible in index.js? I need to apply conditional routing based on these parameters. Alternatively, is there a way to pass these ...

Modifying characteristics of a duplicated object will affect every object

After loading an OBJ file, I created a clone of it in an array. However, when I attempt to change the vertex color of one clone, all the clones are affected. How can I create independent clones with unique attributes? var oload = new OBJLoader(); oload.loa ...