Text wrapping to the right of an image in Bootstrap columns

I'm struggling with getting a large block of text to display correctly on the right side of an image. The text keeps dropping below the image when it reaches a certain size or if no width is specified. Adding a fixed width to the text column seems to be a solution, but isn't the essence of bootstrap to avoid using fixed widths?

In my CSS, all I have for the p element is word-wrap: break-word;. I had to set a height on the image because it was too large - ideally, I'd like to limit the image size to fit within the bootstrap column. I've tried various CSS combinations without success. Creating two columns in a row, one with an image and one with text should be simple, right? But I'm struggling to get it right. This might be a common issue, and I've tried multiple solutions suggested by others. How do I achieve this layout effectively? Your help would be much appreciated. Note that I am working on a Laravel project with Bootstrap loaded and the necessary CSS available.

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

<div id="banner" class="12u" >
    <div class="container">
        <div class="row">
            <div class="col-4">
                <img src="{{ asset('images/fun.jpeg') }}" alt="Picture" height="400em" >
            </div>
            <div class="col-8">
                <p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Dicta provident, dolore, voluptas aspernatur officiis nisi deserunt perspiciatis vero beatae assumenda est nobis odio blanditiis ratione, rem consectetur facere reprehenderit repellendus.</p>
            </div>
        </div>
    </div>
</div>

Answer №1

To ensure the image is responsive, I included the img-fluid class which sets the image width to 100% and height to auto. This allows the image to adjust proportionally based on the container it is placed in.

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

<div id="banner" class="12u">
  <div class="container">
    <div class="row">
      <div class="col-4">
        <img class="img-fluid" src="https://images.unsplash.com/photo-1494548162494-384bba4ab999?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80" alt="Picture" height="400em">

      </div>
      <div class="col-8">
        <p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Dicta provident, dolore, voluptas aspernatur officiis nisi deserunt perspiciatis vero beatae assumenda est nobis odio blanditiis ratione, rem consectetur facere reprehenderit repellendus.</p>
      </div>
    </div>
  </div>
</div>

Answer №2

It seems like you're on the right track, but make sure to include width="100%" in your img tag for optimal display.

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

<div id="banner" class="12u" >
    <div class="container">
        <div class="row">
            <div class="col-4">
                <img width="100%" src="https://images.unsplash.com/photo-1590412513773-fa30db27b485?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60" alt="Picture">
            </div>
            <div class="col-8">
                <p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Dicta provident, dolore, voluptas aspernatur officiis nisi deserunt perspiciatis vero beatae assumenda est nobis odio blanditiis ratione, rem consectetur facere reprehenderit repellendus.</p>
            </div>
        </div>
    </div>
</div>

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

Recaptcha Request exceeded time limit within the bootstrap modal dialogue box

I am encountering an issue with the reCaptcha on my website. The first one, located on a regular page, is functioning properly. However, the second one is placed within a modal popup that appears after clicking a button. Upon inspecting the browser consol ...

Activate Bootply libraries with Bootstrap data toggle tab

Greetings! I am excited to be sharing my first post here and although I am a newcomer, I am eager to expand my knowledge. Before reaching out with my question, I did some research here because I found myself a bit stuck. Allow me to provide an example of ...

Transferring HTML5 Video data by breaking it into segments and streaming it through several HTTP/

Looking for ways to speed up the loading time of an html5 video? Is there a method to make a browser process each webm video fragment as individual TCP streams, in order to take advantage of HTTP/2's enhanced parallelization? ...

Tips for animating a clicked list item from its current location to the top position and simultaneously hiding all other list items

Is it possible to create a dynamic list where clicking on an item will move it to the top position using jquery animate and hide the rest of the list items simultaneously? $(document).ready(function() { $(".menu").click(function() { $("li").animat ...

Generate a catalog of individual files within nested folders

I have a structure: [catalogues] [catalogue-name-1] [data_html] name-1.html - table of posted values from another form name-2.html - table of posted values from another form name-3.html - table of posted values from another form ... name-n.html - ta ...

What is the best way to align this button beside my form field instead of having it appear two lines below?

I am currently in the process of learning Django as I work on creating a website. However, my knowledge of HTML, CSS, and JavaScript is limited. To tackle this issue, I decided to use a website builder to generate a template for me, which I can then modify ...

A CSS3 property that does not have a vendor prefix, followed by properties that do have vendor prefixes

As discussed in a response on Stack Overflow, one reason for the necessity of vendor prefixes in CSS properties is to prevent web pages from breaking even if the final specification varies from the implementation by different browsers. In a recent reading ...

Retrieve information from a SQL database table and present the output in an HTML table format

I am trying to display the result of a query to a remote ODBC SQL database in an HTML table using PHP. I have successfully established the connection with the database, but when I attempt to execute a query and display it in a table, nothing appears. I am ...

Styling Fonts in Safari with CSS

Because FixedSys doesn't appear correctly in Chrome or Safari, I switch it to Lucida Console. While this solution works for Chrome, I encounter a problem with Safari. Unless Lucida Console stands alone, the font will not display as desired. If there a ...

The function getSelection().focusNode does not function properly within a specified ID

My current code allows for text to be bolded and unbolded using Window.getSelection(). I found the initial solution here: Bold/unbold selected text using Window.getSelection() It works perfectly without any issues. However, when I tried to modify the code ...

How can I bring the toolbar to the forefront of the page in an Angular/HTML environment?

I am currently facing an issue with bringing the toolbar to the forefront of the page. When I scroll down, the elements on the page end up covering the toolbar which is not the desired behavior. Below is the CSS code for the toolbar: .maintoolbar.mat-tool ...

What is the best way to conceal a dropdown menu when the page first loads?

I have a dropdown menu that is displaying like this: <ul> <li class="dropdown open"> <a aria-expanded="true" href="#" class="dropdown-toggle waves-effect waves-button waves-classic" data-toggle="dropdown"> <spa ...

Margin challenge in CSS

Just starting out with CSS, so please be patient with me. I'm currently working on customizing a form and everything is looking good, except for the confirmation label which is located in a div. I've managed to create space between other elements ...

Don't forget to retain the checkboxes that were chosen in the

I am looking for a solution to a specific scenario. When I open a modal box and check some checkboxes, I want those same checkboxes to be selected the next time I open it. Below is an example of my code. Main Controller modal function function openModa ...

Revamping the Jquery Waypoint

Greetings, I am currently delving into the world of Jquery waypoints and facing a bit of challenge getting it to work. My goal is to have an "alert" pop up once an element becomes visible on the screen, but for some reason, the alert doesn't show up w ...

Having an issue with deleting a table row using jQuery when the button is clicked

I am facing an issue where clicking on a button does not delete the table row despite both the tr id and button id having the same value. Can someone please guide me on what might be going wrong? <tr id="<?php echo $result->id;?>"> <t ...

The left and right arrows maintain their visibility even when they are outside of the image

I am a beginner in the world of web development and I am trying to implement left and right navigation for images using arrows. My goal is to have the arrows fade in when the mouse hovers over the image and fade out when it's moved away. However, I am ...

Deactivate a radio button group based on the selection of a previous group

When submitting a pay change request for an employee in the HR Department, there are 2 sets of radio buttons to consider. The 2nd group should only be enabled if "Yes" is selected in the first group. However, if the user switches from "Yes" to something in ...

Steps to dynamically adjust the height of a div based on the height of the browser window

My question revolves around a fixed position div element whose height varies based on its content. In order to enable auto scrolling, I have applied the CSS property overflow-y: auto and assigned a fixed height. Is there a method to dynamically adjust the ...

Struggling to extract information from HTML code through Python web scraping techniques

Hello there! I'm currently in the process of extracting dividend history data for a specific stock from a website using web scraping in Python. However, being new to Python, I'm facing some challenges in retrieving the data. Below is a snippet of ...