Align the image vertically with the bottom border of the header by utilizing the features of Bootstrap 4

I'm currently working on a website layout that utilizes Bootstrap rows and columns to separate text content from images.

Here's an example of the structure in my HTML file:

<div class="row">
    <div class="col-sm">
        <h1>A lengthy header with underscore</h1>
        <h3>Subheader goes here</h3>
        <p>Description text is included here</p>
    </div>
    <div class="col-sm">
        <figure class="figure">
            <img src="/assets/contentImage4.jpg" alt="Placeholder" class="img-fluid img-thumbnail content-image">
            <figcaption class="figure-caption">Caption for the image</figcaption>
        </figure>
    </div>
</div>

The CSS code associated with this layout looks like this:

.figure {
  display: block;
  margin: auto;
  margin-top: 45px;
  margin-bottom: 45px;
  width: 40%;
  text-align: center;
}

h1, h2 {
  font-family: 'Work Sans', sans-serif;
  border-bottom: 4px solid black;
}

I've adjusted the top margin of the image by 45 pixels so that it aligns with the underline under the h1 element. However, when the title wraps onto two lines due to its length, the alignment gets disrupted. Is there a way to dynamically adjust this based on how the h1 wraps?

Answer №1

It seems like you may not be fully acquainted with the workings of bootstrap, as your markup lacks specification on the column distribution for each div. The Bootstrap Grid system comprises 12 columns which require explicit allocation to determine their occupancy. For instance:

<div class="col-sm-4">

The above code snippet allocates 4 out of the 12 columns in the bootrap grid to that particular div, leaving 8 columns for the image div.

Regarding Bootstrap 4, it appears that the formatting used implies an equal split between the two divs, effectively translating to 6 columns each.

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

Using AngularJS to create a modal popup within another modal popup

I am attempting to launch a modal popup within another modal popup. However, I am encountering the following error: angular.min-1.2.29.js:93 Error: [$injector:unpr] http://errors.angularjs.org/1.2.29/$injector/unpr?p0=%24modalInstanceNewProvider%20%3C ...

Looking to display a submenu next to its parent element

I have a list that is not in order: <ul> <li>Parent-1 <ul> <li>Child-1</li> <li>Child-2</li> <li>Child-3</li> </ul> </li> <li>Parent-2 <ul> <li>Ch ...

flashing issue with bootstrap selectpicker

Can you rearrange the jQuery code and incorporate popper.js into bootstrap 4? $('.selectpicker').selectpicker(); <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs ...

Having trouble with Gulp JS and CSS minification where existing minified files cannot be replaced

I've hit a roadblock in trying to resolve my search and google issue. My current challenge involves Gulp and cssmin. I can't seem to pinpoint the cause of an error. My aim is to have both the original CSS files and their minified versions in the ...

Prevent drag and drop functionality in QtWebkit

As I work on creating an HTML GUI for my application using Qt's WebKit, everything is going smoothly with one minor issue. I am trying to prevent users from dragging and dropping images from the GUI itself. While I have successfully disabled text sele ...

Guide on invoking a JavaScript function within a jQuery upon a specific event, such as clicking a hyperlink

I have a website page where I display some important information. However, I want to make this text hidden initially and only visible when a user clicks on a specific link or button. I attempted to achieve this functionality using the following code snippe ...

I am facing issues with the functionality of the Bootstrap 4.3.1 tab feature in my

After browsing their website, I almost replicated the code. The tab initialization works perfectly, and new panels activate when clicked on tabs. However, the "active" class doesn't get applied to the activated tab. Here is the code snippet: <ul c ...

What is the best way to customize the appearance of the initial row in each tr cluster?

Looking to add a button for expanding child rows within a datatable, with each group in the table having the same child elements.... The provided CSS currently displays the icon on every row throughout the entire table. td.details-control { backg ...

failure in data transmission causing upload issues

Is there a way for me to prevent the character > from causing issues? I have a combo box with an option listed below. I attempted to replace > with &gt;, but it still isn't uploading correctly. <select name="Category3" id="Category3"> ...

Creating a responsive website can be achieved by utilizing the ul element or incorporating a div with the CSS

When it comes to responsive design, the choice between utilizing ul and div elements is crucial, especially in regards to the navigation bar. After observing many other developers, I initially opted for ul but soon realized that for certain navigation beh ...

What is the process for setting up distinct radio types that will be separated?

I'm attempting to generate two separate questions with radio buttons in HTML. However, whenever I test it, I can only select one option even though I used to separate the questions to prevent interaction. Can anyone assist me? Do you agree? Yes ...

Layering effect for the jumbotron text with parallax scrolling

Trying to make the text in the jumbotron hide underneath the container when scrolling, but it's not working as expected. How can I get 'Main Title Goes Here', 'Subtitle' and the blue box to go under the lorem ipsum text? I tried se ...

Incorporating rounded corners to an embedded YouTube video

Check out this JSFiddle link. The border-radius property appears to be working correctly at first, but then the rounded corners suddenly disappear shortly after loading. Is there a way to apply rounded corners to YouTube videos that are embedded on a webp ...

Whenever the user hits the "Enter" key, a new element will be generated and added to the bottom of an existing element

I am in need of creating a new element at the end of another element. For instance, let's say I have this element: <div id="elmtobetrig">Element that should be followed by another element when the user hits enter after this text. <! ...

What is the best way to incorporate multiple countdown timers on a single HTML page?

I am in the process of developing an online auction site and I need to include the end time and date for each auction. To achieve this, I have created a countdown.js file with the following code: // set the date we're counting down to var target_dat ...

The issue with the modal jQuery in Bootstrap 4 persists

Having an issue with my jQuery code. The problem is that when I click on the link, the modal opens but I am unable to pass the value of data-href to the button inside the modal. Upon clicking the button, nothing happens. Seeking assistance to resolve this ...

JavaScript - Receiving alert - AC_RunActiveContent.js needed for this page to function

When I attempt to open the HTML file in my application, a pop-up message appears stating that "This page requires AC_RunActiveContent.js." However, I have already imported and referenced the AC_RunActiveContent.js file in my package. Can someone assist m ...

"Local dropdown feature functioning correctly, but encountering issues when deployed to the

While developing my website with Symfony 4, I decided to use a bootstrap theme from Everything was working fine when testing it locally. However, once I deployed the site on my OVH server, the dropdown menu stopped functioning. Local Setup: https://i.ss ...

Tips for optimizing Jquery selectors to streamline recurring functions

I have 9 "service node" divs in my HTML code, each containing a hidden div and a button that triggers the rotation of the button by 45 degrees and reveals the hidden div. The challenge I am facing is that I have been using repetitive functions for each ser ...

Utilizing HTML and Javascript for streaming audio and recording voice

Working on a new project that involves streaming audio files (mp3) and recording voice messages. Initially considered using Flash, but the challenge is making the website iPhone-friendly as per the client's request. Is there a technology available th ...