Using Bootstrap to wrap text around an image on small screens: A step-by-step guide

Recently starting my journey with Bootstrap, I've included a screenshot of my progress below.

This is the CSS I'm using:

.snippet img{
width: 150px;
max-width: 100%;
height:auto;


 }

@media(max-width: 767px) {
.snippet img{

    width:100px;
    float: right;
    max-width: 100px;
    height: auto;
    margin-left: 10px;
    margin-right: 10px;
    }
}

Here's the HTML snippet:

<h2>About the venue</h2>
<div class="media-body snippet" >
    <a class="pull-right" href="venue.php">
            <img  src="images/venue.jpg" alt="illustration"></a>
    <p>this is the paragraph ... </p>       
</div>

I want the image layout to be as shown in larger screens. However, on smaller devices, I aim for the text to wrap around the image nicely. How can this be achieved?

Your assistance would be greatly valued!

Answer №1

Have you considered using this option? It's a more efficient choice ;) http://getbootstrap.com/components/#thumbnails-custom-content

UPDATE

Below is the code snippet from the Bootstrap documentation:

<div class="row">
<div class="col-sm-6 col-md-4">
    <div class="thumbnail">
        <img data-src="holder.js/300x200" alt="...">

        <div class="caption">
            <h3>Thumbnail label</h3>

            <p>...</p>

            <p><a href="#" class="btn btn-primary" role="button">Button</a> <a href="#" class="btn btn-default" role="button">Button</a></p>
        </div>
    </div>
</div>

Answer №2

You might want to give this a try:

<style>
    .snippet {width: 250px;}
    .snippet img{ width: 150px; height:auto; float: left; }

  </style>
 </head>
 <body>
<div class="media-body" >
    <div class="snippet">
        <a class="pull-right" href="venue.php"><img  src="https://i.sstatic.net/Fa34B.png" alt="illustration"></a>
        <p>Here is the text content... </p>      
    </div>
</div>

Answer №3

Give this a shot

<div style="width: 150px;">
<img src="https://i.sstatic.net/Fa34B.png" align="left" width="100" height="100"> Check out this text - it's full of interesting content and ideas that will keep you engaged for hours on end. Don't miss out on all the exciting details packed into this message!
  </div>

Answer №4

For a nice layout, I rely on using float and a touch of padding for aesthetics:

<div class="float-right pl-3 pb-3">
    <img src="https://i.pinimg.com/474x/4a/c7/3b/4ac73b5c8ef5d397ab535ac1631642a7.jpg" class="shadow img-fluid">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularized in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>

Answer №5

Please include the following CSS line

display:inline;

Answer №6

To ensure responsiveness and alignment, make sure to include the class "img-responsive pull-left" in your HTML code.

Here is an example of how to implement it:

<img  src="IMG/img.jpg" alt="about image" class="img-rounded img-responsive pull-left">

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

CSS guidelines specifically for when two classes are required to exist simultaneously

Is there a specific effect that can only be achieved when two classes are present simultaneously? For example: .positive{ color:#46a546; } .positive:after{ content: "\25b2"; } .negative{ color:#F00; } .arrow:after{ content: "\25bc"; ...

Epiphany poses a challenge when it comes to adjusting the height of a child item to match the height of a flex item using Flex

I am facing an issue with a grid of blocks that also contain flex blocks. The height is being ignored in the children of the flex-item of the grid in the Epiphany browser. The display is correct in Firefox and Chromium. In Epiphany, the first block appea ...

What is the process for designing a unique page in Wordpress with a custom stylesheet?

I'm a beginner with wordpress and I'm facing some challenges. I have 4 custom page templates that I need to create: Home, Portfolio, About, Contact. Each of these new pages requires a unique CSS file. I have enqueued my script portfolio.css lik ...

The Issue of Horizontal Scrolling - None of the elements are out of

I am facing an issue with an unwanted horizontal scroll on my website and I can't seem to identify the cause. The header of my site is quite simple, utilizing display: flex, justify-content: center, marin-top: 5vh, along with some padding on the logo ...

Having trouble centering elements correctly with Bootstrap 5

Just dipping my toes into the world of bootstrap and experimenting with some code. Encountered an issue when trying to center elements properly within columns: <div class="container"> <div class="row"> <div class= ...

Changing the position of a sprite using jQuery

Looking for assistance in moving the scroll location onClick of another div using jQuery. The image is a sprite. .top-background{ background: url("../images/mainall.jpg") no-repeat scroll 0px 0px transparent; height: 888px; width:1024px; } ...

Revamp the website to create a more streamlined and compact version that mirrors the functionality of the desktop website

My goal is to make my website responsive on all mobile devices. I want the mobile version to look exactly like the desktop version, just smaller in size. I attempted using transform but it didn't have the desired effect. I aim to achieve the same con ...

Image not showing up in MUI React

When trying to showcase my images using the itemDate.js file: const itemData = [ { img: "../assets/photos/photoportrait.jpeg", title: 'Breakfast', }, and calling it within my Portfolio component: import * as React f ...

Bootstrap offers an improved method for arranging elements in columns and rows, especially when you need to omit certain ones

Is there a more efficient method for aligning elements using Bootstrap? Here is my current approach: <div className="row"> <div className="col-3 font-weight-bold"> Item Name ...

The Clash of Bootstrap Spanning: Firefox Takes on Chrome and Safari

I am experiencing some strange issues with spacing in different browsers when using Bootstrap. Firefox is showing the spans correctly, but Chrome and Safari are spanning the items across the full width of the page, which I know is a responsive behavior of ...

Mystery of the Unresponsive MD Ripple Button

While working on creating a CSS button, I wanted to incorporate the Material Design ripple or wave effect into it. I came across a simple script on codepen that works well by adding the class "ripple" to various elements such as divs, buttons, images, and ...

Leveraging AngularJS to enhance the dynamic HTML content within Datatables

My angular application includes a Datatable where I alter cell content to include HTML elements. In the given code snippet, I specifically modify the cell content of the 5th column to incorporate links. Additionally, I intend to implement a tooltip featur ...

Is there a way for me to have a background image behave like an img element with img-fluid class as shown in the

Showing 2 rows The issue lies with the first row, as it is not displaying properly and does not resize responsively like the second row. I have tried everything but nothing seems to work. I am attempting to do this because the text and elements in the ...

Why isn't the parent div stretching alongside its child divs?

Take a look at this example: wthdesign.net/website/olaf&co/index.php I am currently working on creating a responsive layout, but I am struggling to figure out how to make the "#content" div stretch with its child div when there is more content than ex ...

Customize CSS class in ASP.Net

Here's the CSS code I am currently using: LinkButton:hover { color:White; background-color:Gray; } .myClass { color:Blue; } The issue I'm facing is that I have a LinkButton with the CssClass .myClass, and when I hover over it, the b ...

Using DIV to "enclose" all the elements inside

I need assistance with my HTML code. Here is what I have: <div id="cover" on-tap="_overlayTapped" class$="{{status}}"> <form method="POST" action="/some/action"> <input required id="name" name="name" label="Your name"></input> ...

Utilizing Electron to save editable user data in a .txt file

I am making an electron app that converts data from .txt files to Javascript arrays. This data is stored inside a folder called faces in the main directory. I also have a button in my app which, when clicked opens file explorer at the faces folder so the u ...

Utilizing ng-class with Boolean values in AngularJS

On my page, I have a pair of buttons that control the visibility of elements using ng-hide and ng-show. <a ng-click="showimage=true" ng-class="{ 'activated': showimage}" class="button">Images</a> <a ng-click="showimage=false" ng-c ...

Feeling lost on the intricacies of threejs functionality

I have incorporated a sample code into this html/css document that utilizes a script to generate a 3D cube using three.js. Upon opening the HTML file, I am presented with a blank page in chrome displaying only, "canvas { width: 100%; height: 100% }" Belo ...

Adjusting the Aspect Ratio of an Embedded YouTube Video

<!DOCTYPE HTML> <head> <style> body { overflow: hidden; margin:0; } </style> </head> <body> <iframe id="video" src="https://www.youtube.com/embed/U4c9bBeUe4M?modestbranding=1&sh ...