Ensure that the Bootstrap image element maintains its full height without resizing

While working on my Angular application, I encountered an issue with designing a side list-group of recent blogs using Bootstrap 4. When the aspect ratio is changed to mobile view, the images resize and become smaller to fit into the div as the title length increases. I would like the title to resize and, if it's too long, break and move to the next line, while keeping the image size constant. Additionally, I want the image to take up the full height of the element. Please refer to the image below for a clearer understanding.

HTML:

<div class="container">
  <div class="row">
    <div class="col-12">
      <h6 class="text-muted">Recent Blogs</h6>
      <ul class="list-group" *ngFor="let blog of blogs">
        <li class="list-group-item d-flex justify-content-between align-items-center">
          <div class="image-parent">
            <a [routerLink]="['/blog', blog.blogId]">
              <img src="http://localhost:4000/{{blog.imagePath}}" class="img-fluid" alt="lay">
            </a>
          </div>
          <a [routerLink]="['/blog', blog.blogId]">
            {{blog.title}}
          </a>
        </li>
      </ul>
    </div>
  </div>
</div>

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

Answer №1

Make the following adjustments to your code for better performance:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

<div class="container">
    <div class="row">
        <div class="col-md-12">
            <h6 class="text-muted">Recent Blogs</h6>
            <ul class="list-group" *ngFor="let blog of blogs">
                <li class="list-group-item d-flex justify-content-between align-items-center">
                    <div class="row">
                        <div class="col-md-4">
                            <div class="image-parent">
                                <a>
                                    <img src="https://cdn.pixabay.com/photo/2015/12/01/20/28/road-1072823__340.jpg" class="img-fluid" alt="lay">
                                </a>
                            </div>
                        </div>
                        <div class="col-md-8">
                            <a>
                                Text Test
                            </a>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>

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

Store the checkbox's data in the database for safekeeping

Hey there, I'm working on saving the value of a checkbox using PHP. The twist is that the value is generated through JavaScript. How can I handle this scenario and save the value using PHP? Checkbox: <input type='checkbox' name='ca ...

Tips for showing a form's help text when manually rendering fields in Django forms?

In my Forms.py file, I have the following code snippet: class CustomerForm(forms.Form): name = forms.CharField(max_length=255,required=True,validators=[alphaonly],help_text="Enter your name") I am attempting to render it in an HTML format like ...

What is the best way to add custom styles to Material UI tabs in a React application?

I need help styling my material UI tabs within a react component. I am having trouble getting the styles applied correctly, specifically setting the background color and box shadow of the entire bar, as well as defining the indicator background color and u ...

Is there a way to determine if a certain class link within a DIV has been clicked and then replace the DIV's click functionality?

I have multiple DIV elements like the one below on my webpage: <div class='entry'> This is a statement <a title="Search @travel" class="app-context-link" href="">@travel</a> </div> When a DIV with the class .ent ...

Image missing aria-label attribute

I am facing an issue with getting the aria-label to display on my image. Despite checking my code, I cannot figure out why it is not working. Any ideas on what might be missing? Here is the code from my NextJS app: The svg in my public folder. <?xml v ...

Google Web Fonts: Exploring the World of Font Weight Variations

It's quite puzzling as to why the weight of my Google web font in the navigation menu keeps changing on different pages even though I have specifically set it to 700. The CSS for the menu is exactly the same across all pages. Can anyone shed some ligh ...

What are the benefits of utilizing the useStyles MaterialUI function instead of traditional CSS?

As I develop my MERN application, I am utilizing Material UI components along with inline attributes. However, I find myself questioning the necessity of creating a JavaScript file just to import the makeStyles function, which essentially outputs an obje ...

Fade-In Effect for CSS Background Image

I'm currently learning CSS and I am trying to create an effect where, on hover over some text, the text disappears and an image fades in. I have been experimenting with different methods but haven't quite achieved the desired outcome. The text i ...

Embed a local page into an HTML file using PhoneGap

I attempted to load a page within my phonegap application using Jquery .load(), but it isn't functioning because it's on a local machine rather than a server. When I eventually upload the app to PhoneGap Build, my page will still be located in th ...

Encountering a problem with React components displaying incorrect sizes while utilizing flexbox styling

I am creating a basic test application using NextJS/React. Take a look at the code snippet below: The content of Board.tsx file: import './Board.css'; export default function Board() { return <div className="board"> < ...

What is the best way to apply CSS to a single div without affecting the rest of the code?

After importing the following stylesheet: <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> I noticed that it was affecting other elements on my webpage, like buttons. Is there a way to instruct m ...

Angular routing template failing to execute inline JavaScript code

I'm facing an issue with my Angular.js routing implementation. I have successfully displayed the HTML code in templates using angular.js, but now I am encountering a problem with my template structure: <div id="map_canvas" style="width:95%; heigh ...

Using Javascript, delete all chosen HTML elements containing innerText

Looking to extract certain HTML tags from a block of code in TextArea1 and display the modified output in TextArea2 upon clicking a button. <!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8&quo ...

Substitute a single occurrence of the dollar sign with an HTML tag

I have been attempting to insert an HTML tag into a price on my e-commerce website. Specifically, I am looking to add a tag between the "$" and the numerical value (e.g. $5.00), but I am unable to locate the core file where I can place the code between the ...

The selected jquery script is failing to function as intended

I'm currently implementing jQuery chosen in a select element to enhance user experience, however I'm facing an issue when attempting to copy the chosen div to another div using jQuery $(document).ready(function() { $(".chosen").chosen({}); ...

Issues with creating modal images using only JavaScript

I am facing an issue with modal popup images. I have a collection of images and attempted to implement this code (with some modifications): https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_modal_img However, it seems to only work for the initi ...

<a href> click here to append a new query parameter to the existing ones

Is there a way to create a link that will add a query parameter to the current URL instead of replacing all existing ones? Here's what I'm looking for: If the current URL in the browser is example.com/index.html, clicking on it should lead to ...

Issue with JQuery Ajax form causing unexpected page refresh in Safari but not in Firefox (working properly)

Currently, I am working on an AJAX form that is housed within a JQUERY UI Dialog. Everything runs smoothly in FireFox; however, there seems to be a glitch in Safari as it refreshes the page to: /? If you notice any discrepancies or errors here, please do ...

What is the best way to get my loading screen div to cover the entirety of my screen, including all content beneath it?

In order to create a loading screen, I am utilizing PHP to dynamically load specific services for my website. I attempted to set the height of my wrapper div to 100% but it did not produce the desired results. After that, I experimented with setting the he ...

restructure the HTML based on a jQuery condition

Using jQuery to Refresh HTML Content function(data) { if(data === "importtrue") { $('#rebuildme').//function like .html } else { $('#rebu ...