Is the logo stretching when adding an image in a bootstrap row?

Attempting to utilize Bootstrap 4 for website development, I encountered an issue when adding a logo image and text to the header. The image became stretched, as seen below: https://i.sstatic.net/3qRnE.png

Below is the HTML code used:

<header>
  <div class="container">
    <div class="row">
      <img alt="logo" src="img/udacity.png" id="header-logo" class="col-lg-1 col-md-1 col-sm-1 col-1 img-fluid"/>
      <h1 class="col-lg-11 col-md-11 col-sm-11 col-11" id="header-text">Text</h1>
    </div>
  </div>
</header>

Attempts to set the height in the CSS file didn't yield desired results as it couldn't match the height of the Text precisely, nor did it respond well when using percentages. How can this issue be rectified?

In addition, a border was supposed to be added to the row using

.row {border-bottom: 10px solid #000;}
, but nothing appeared. It seems like I can't override the row class?

When inspecting the logo within Safari, the style properties were as follows:

border-bottom-style: none;
border-left-style: none;
border-right-style: none;
border-top-style: none;
box-sizing: border-box;
color: rgb(33, 37, 41);
display: block;
flex-basis: 8.333333015441895%;
flex-grow: 0;
flex-shrink: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
font-size: 16px;
font-weight: normal;
height: 233px;
line-height: 24px;
max-width: 8.333333015441895%;
min-height: 1px;
padding-left: 15px;
padding-right: 15px;
padding-top: 8px;
position: relative;
text-align: left;
vertical-align: middle;
width: 45px;

Answer №1

One issue at hand is that the img and h1 tags are within the .row class, which acts as a flex container. Consequently, the image tag is forced to conform to the height of its sibling elements.

An easy solution is to enclose both tags within a .col-12 class to ensure they span the full width of the container.

<header>
  <div class="container">
    <div class="row">
      <div class="col-1">
        <img alt="logo" src="img/udacity.png" id="header-logo" class="img-fluid"/>
        </div>
        <div class="col-11">
          <h1 id="header-text">Yutian Wu</h1>
        </div>
      </div>
    </div>
  </div>
</header>

Check out the codepen for a live example: https://codepen.io/monners/pen/rprGpa?editors=1100

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

Tips for transferring the clicked value to the next page

Recently, I started working with Ionic and developed an application using it. Now, I am facing a challenge where I need to pass the value from the first page to the second page. To illustrate this more clearly, I have attached two photos. Here is the imag ...

Is there a faster alternative to using jQuery's indexOf method?

Looking to create a search box for a large set of options (around 2000 options) The indexOf method is very slow...any alternative solutions? Jquery Code : $('#textfortitlesearch').on('keyup', function() { var query = this.value ...

What is the recommended Vue js lifecycle method for initializing the materialize dropdown menu?

https://i.stack.imgur.com/cjGvh.png Upon examining the materialize documentation, it is evident that implementing this on a basic HTML file is straightforward: simply paste the HTML code into the body and add the JavaScript initializer within a script tag ...

Utilizing consistent form elements throughout various tabs

I'm working on an HTML project where I need to replicate form elements across different tabs with each tab having unique values. To achieve this, I found a helpful resource at . Here is what I've attempted: <html> <link rel="stylesheet" ...

Simplest Method to Update Content of 'DIV' Across Entire Website Simultaneously

Some DIVs on a website are typically static... For example, the footer of a page is usually consistent and should remain the same on all pages. In a website's CSS, you may have the following: .FooterDIV { Background: #FFFFFF; Color: #0000 ...

Unable to generate a menu with bootstrap

Hey there, I've been experimenting with creating a responsive menu using Bootstrap, but I'm struggling with the implementation. My vision is to have a logo on the left side and a menu on the right side. Below is the concept for my menu design. ...

Ways to align text within a table cell on a background using CSS

I'm attempting to print jukebox strips with designated corner markings. The code I have written generates the HTML page for displaying the strips, allowing users to then print them. Jukeboxes typically feature selection buttons labeled ABCDEFGHJK and ...

`Display PowerPoint file within your internet browser`

I need assistance with viewing pptx files in a web browser that have been uploaded to a specific location using .net core. (approximately 40 mb) (approximately 4 mb) While attempting to view both files using the code below, I am able to see the MonitorP ...

Integrating image transitions into JavaScript

Could you provide guidance on how to create buttons from the three images within the "fadein" div in order to navigate directly to a specific jpeg? Currently, the three jpgs are displayed in a continuous loop. Thank you. ...

Unable to properly access required file path through HTML source

I have a confidential folder named 'inc' where I store sensitive files such as passwords in php connection files. This folder is located at the same level as the 'public_html' folder. I successfully accessed php files with database conn ...

Update a script that handles input float labels to support textarea elements as well

I am looking to modify a float label script that currently works for input boxes in order to make it work for textareas. I attempted to add $fields.on("textarea", floatLabel) to the script but it did not produce the desired result. Any suggestions or assis ...

Sliding right is done by activating the Switch Function, while sliding to the left can be achieved by deactivating it with the help

My objective is to create a functionality where flipping the switch button will cause it to slide automatically to the right, revealing a red background div. When switched off, it should return to its original position with a yellow background using Jquery ...

Using Bootstrap 5 to display a modal using JavaScript

Creating a sleek gallery using bootstrap 5, and curious about how to activate a bootstrap modal without including "data-bs-..." in the HTML (to prevent repeating those data- attributes multiple times). I have successfully written a functioning JavaScript ...

Which of the dynamically-generated submit buttons has been selected?

In a hypothetical scenario, imagine a webpage with multiple submit buttons generated through a PHP loop. Each button is named after the loop value, resulting in HTML code like this: <input type="submit" name="0" id="0" value="click me"> <input ty ...

How can I align those 3 divs in the center of the body?

Can someone help me with centering those 3 divs in the body? I have tried creating 2 versions of the row, one with an extra outer wrap around the column and one without. Unfortunately, since this HTML was created with a page builder (WP visual composer), I ...

Centering an Image of Unspecified Dimensions Both Vertically and Horizontally with Hover Effect on Anchor

To achieve both horizontal and vertical centering of an image with unknown dimensions, I need to use max-width and max-height to constrain it within a container size of 101x84. Additionally, I want the image to display an icon in the middle when hovered ov ...

How to use Vue.js to automatically redirect to a URL when a button is clicked

I have created a button that, when clicked, should redirect to a URL passed in it. Below is the code snippet: <template> <button type="button" v-on:click="gotosite(modalDetails.final.product_url)">Buy</button> </template> <s ...

How can I remove the unsightly scrollbar caused by overflow: auto?

I've encountered a problem while working on my website. The inner div #content wasn't expanding to the full size of the page, causing the text to overflow messily over the background image and making it difficult to read. I initially used overflo ...

What is the best way to position a div at the bottom of a web page?

I have a question that may seem basic, but I've been struggling to find a solution. Despite searching for answers, none of the suggestions I've come across have worked for me. My application has two main containers - a header and a content div. T ...

Escape sequences do not seem to be functioning properly when using innerHTML

I am facing an issue where a string containing HTML escape characters (such as < and >) needs to be rendered inside a div using innerHTML. The intention is for the escaped characters to appear as text rather than as actual HTML, but they still render ...