What is the best way to ensure a logo image is properly scaled to fit its parent container using Bootstrap 4

I am struggling with my navigation bar, which consists of a simple logo and a few links.

The issue I am facing is that the logo image is too tall for the parent container, which has a fixed height.

It's clear that the logo with the gray background exceeds the desired height of the div:

<nav class="menu-nav container-fluid" style="max-height:50px; background-color:gray;">
    <div class="row ">
        <a href="#" class="logo-img col h-100 ">
           <img src="img/bruke-logo.png" class="mw-100" alt="logobruke">
        </a>

        <div class="col-7 h-100">
              Menu
        </div>
        <div class="col-2 h-100">
            <div class="row ">
                <div class="col-6"><i class="fas fa-bell"></i></div>

                <p class="col-6 text-right mb-0"><i class="fas fa-user"></i></p>
            </div>
        </div>
    </div>
</nav>

Answer №1

.logo-image {
  background: url(https://i.sstatic.net/DHJvc.jpg) no-repeat;
  background-size: auto 100%;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet" />
<nav class="menu-navigation container-fluid" style="max-height:50px; background-color:gray;">
    <div class="row ">
        <a href="#" class="logo-image col">
           
        </a>

        <div class="col-7 h-100">
              Navigation Menu
        </div>
        <div class="col-2 h-100">
            <div class="row ">
                <div class="col-6"><i class="fas fa-bell"></i></div>

                <p class="col-6 text-right mb-0"><i class="fas fa-user"></i></p>
            </div>
        </div>
    </div>
</nav>

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 attempt to unserializing the configuration schema in Yii2 was unsuccessful

My brain feels scrambled... I am attempting to insert an image in HTML within Yii2. I retrieve it from the database and place it into the view file, but when I try to display it using HTML tags, an error is thrown. However, the image is being added perf ...

Maintain the tab order for elements even when they are hidden

Check out this demonstration: http://jsfiddle.net/gLq2b/ <input value="0" /> <input id="test" value="1" /> <input value="2" /> By pressing the TAB key, it will cycle through the inputs in order. If an input is hidden when focused, press ...

Truncating text with ellipsis in CSS when wrapping on a nested div structure

Here is a 3-tier nested div tree structure with the outer node having a maximum width where I want the ellipsis wrapping to occur. I've almost achieved the desired result, but the issue arises when the inner nodes are not trimmed to accommodate as mu ...

JavaScript code for opening and closing buttons

I created a button that successfully opens, but I am struggling to figure out how to close it. Can someone assist me with this? Additionally, I have one more query: How can I remove the border when the button is clicked? document.getElementById("arrowb ...

How can I position a div element inside another fixed div element?

I'm working on a layout with a fixed gradient div that contains all my content. However, I want the content to be scrollable instead of fixed. How can I make this happen? Here is the current structure: <body> <div class="wrappe ...

Interactive Text Transformation on Mouse Over

My goal is to create a sleek and clean Index page featuring a simple white background with text centered in the middle. The initial text will be: USEStudio Upon hovering the mouse, the text will transform into: ...

Creating an arrow icon alongside a pseudo:hover::before element

This is my custom code snippet: .privacycheck1 { position: relative; top: 265px; background-color: #CF0000; width: 24px; height: 24px; left: 843px; border-radius: 50px; border: 5px #E60000; } .privacycheck1::before { position: relative ...

Creating a layout with two divs displayed next to each other using CSS

Just when I thought I had it figured out, my two side-by-side divs are not behaving as intended inside the parent div. Why is the orange "Content" div ending up below the navigation bar? Can anyone spot what I did wrong here? Thank you in advance! CSS: ...

A guide to adjusting the width without affecting the td element

Currently, I am facing a challenge while coding in HTML. I am trying to create a table with a header (time range) that fits on a single line without affecting the width of the td elements. Below is the code snippet: <table style="border:1px solid #8c ...

Can a Dashcode Webkit Web app be transformed into traditional HTML and CSS?

I have developed a blog using Dashcode, incorporating HTML, CSS, and Javascript to pull data from an xml file. It's pretty simple... My perspective on this is: 1. JavaScript should be compatible with all browsers (with some variations). 2. I may need ...

Align two DIVs in the correct layout: One as a sidebar that remains fixed, and the other as an expanding element

I am currently working on a code snippet to build a basic website featuring two main sections: a sidebar and the main content: html, body { height: 100%; margin: 0; } .container { display: flex; flex-direction: row; height: 100%; } .sidebar { ...

Adjust the Bootstrap class based on the state of a React component

Hey there! I've been working on a react component called NavBar, and I need your help with something. The NavBar component receives a variable called "pageMode" from another component (App.js), which determines whether the page is in dark mode or not. ...

Using JQuery to trigger CSS3 animations on one element when clicking on another

My Rails app has a feature similar to reddit where users can upvote or downvote content. I'm currently working on creating a CSS3 animation that triggers when a user clicks the downvote button. Here's how I'm using JQuery: <div class="a ...

How can I position a div in the center of a fullpage.js slide?

I'm currently utilizing the fullPage.js plugin sourced from this link: . I have successfully implemented vertical slides by using the following HTML code: <div class="section" id="section2"> <div class="slide" id="slide1"> ...

Extracting text from a JSON file and populating text fields: A step-by-step guide

Utilizing this JSFIDDLE to duplicate text fields has been quite helpful. I am now looking to create JSON data based on the input from all the text fields. When it comes to updating a page, I need to extract the JSON data and accurately populate the corresp ...

Positioning of bottom navigation bars

Is there a way to ensure that the bottom navigation bar remains fixed at the bottom of the screen, regardless of the device's screen size? position: absolute; bottom: 0; width: 100%; While this solution works, it has been observed that when th ...

Using an aria-label attribute on an <option> tag within a dropdown menu may result in a DAP violation

Currently, I am conducting accessibility testing for an Angular project at my workplace. Our team relies on the JAWS screen reader and a helpful plugin that detects UI issues and highlights them as violations. Unfortunately, I've come across an issue ...

Iterating through a nested array in order to dynamically generate elements using JavaScript/jQuery

Seeking assistance with a specific issue I am facing. Despite extensive research on this platform, I have not found a solution to my problem. Recently, I successfully used jQuery each to loop over objects. However, I am currently struggling to iterate thro ...

Struggling with getting the Encore Webpack Bootstrap4.5 navbar to function properly

I am currently diving into the world of Symfony, and I have chosen to leverage bootstrap for styling my page. Interestingly, when I include the link, <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_ema ...

Classic design of the shadow element

I have main.js and index.html below class CustomTagA extends HTMLElement { constructor() { super(); const shadow = this.attachShadow({mode: 'open'}); const wrapper = document.createElement('h1'); ...