What is the method for inserting text next to an image in a Bootstrap card?

Struggling to position text next to an image within a Bootstrap card? Despite using CSS to resize the image to half its width, the text keeps appearing on a separate line. What additional CSS code can be implemented to make the text float to the right of the image?

.card-img-top {
        height:150px;
        width:150px;
}

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

Answer №1

You have the option to utilize the flexbox utility classes to achieve the desired layout in this scenario.
Listed below is a sample code snippet demonstrating the use of .d-flex .align-items-center to centrally align an image and text. Your specific implementation may vary based on your requirements, however, this serves as a starting point.

<div class="card w-50">
    <div class="card-img-top d-flex align-items-center bg-light">
        <div>
            <img class="img-fluid" src="http://via.placeholder.com/150x150/1f1a38/ffffff?text=Image" alt="Card image cap">
        </div>
        <p class="col p-2 m-0">Text next to the right side of the image</p>
    </div>

    <div class="card-body">
        <h5 class="card-title">Card title</h5>
        <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
    </div>
</div>


<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" rel="stylesheet"/>

Answer №2

Give this a shot using html:

<div>
   <p .... >
</div>
<h2> Text.... </h2>
<blockquote> Text.... </blockquote>

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

Error encountered on Facebook Like button: The large button is failing to show the total number of likes received

Despite functioning flawlessly for months, the large Facebook Like button has suddenly stopped showing the number of "Likes". Strangely, the compact version is still working fine, but the larger button is concealing the count. I am using a Mac and have obs ...

steps for aligning an enlarged div in the middle upon hovering?

This situation presents a unique challenge. Below is the HTML code. <div class="foo"> <div class="bar"> <div class="a"> <h2>Luigi's Mansion1</h2> <small> ...

Selector for the Nth child element

Struggling with the nth child selector. Here is the HTML snippet: HTML <div class="container"> <ul class="mh-menu"> <li> <a href="#"> <span>Chairman of the Board</span> <spa ...

Angular neglects the specified animation timing

I created a sidebar component that relies on the sidebarExpanded state passed through Input(). Despite the correct animation trigger upon input change, the width adjustment happens abruptly. Interestingly, the same animation code works flawlessly in anothe ...

An illustration using Bootstrap 5: Cover page design featuring a fixed-top navigation bar and smoothly scrolling content

Struggling with customizing the bootstrap 5 cover page example. I really love the design, especially the header and footer (without toggle, brand staying on a single line, etc.). Want a page with more content scrolling in the middle, while keeping the nav ...

Elevate Your Design: How to Vertically Align Navigation Links as Logo Expands Navbar Height in Bootstrap

As a newcomer to the Bootstrap 4 framework, I find myself a bit stuck despite going through all the documentation and existing B4 questions on platforms like StackOverFlow. The issue I am facing is with my navigation bar. I have inserted an SVG logo with ...

Difficulties Arising in Flex Layout Usage Due to ngFor Loop Implementation

Despite my efforts, I couldn't locate a question quite similar to mine. If an answer already exists somewhere, I apologize. I'm trying to create a simple flex layout in row format where 2 containers are placed side by side. Inside another compon ...

The "flickering" effect of the div is like a dance, moving gracefully between fade outs and

I am encountering a similar issue as described in this thread: same problem (fiddle: original fiddle). However, I am still learning JavaScript and struggling to apply the solution provided because my HTML code is slightly different. Can someone please assi ...

Steps for removing the footer from WordPress with the "powered by WordPress" message:

I am curious about how to delete the footer that says "powered by wordpress". I created this page and at the bottom of it, there is a mention of "powered by wordpress". Website ...

Creating a basic popup with jQuery: A step-by-step guide

Currently in the process of creating a webpage. Wondering how to create a popup window with an email label and text box when clicking on the mail div? ...

Tips for employing Flex-grow alongside the behavior of "justify-content: start"

I am working with a flex container setup like this: .container { display: flex; flex-flow: row wrap; justify-content: start; width: 100%; } .item { border: 1px solid red; flex: 1 1 33%; height: 100px; } <div class="container"> <d ...

Guide to Wrapping Inner or Wrapping All Elements Except for the Initial Div Class

I am looking to enclose all the elements below "name portlet-title" without including other elements within the "div class name portlet-title". I have attempted the following methods: 1) $("div.item").wrapAll('<div class="portlet-body"></div ...

Is there a way to use jQuery to verify if an LI element contains a parent LI element?

Struggling with customizing the comments section of a WordPress theme? Utilizing jQuery for styling can be tricky, especially when dealing with nested UL elements like admin comments. The challenge lies in traversing the DOM structure to target specific el ...

Using Jquery Simplyscroll to incorporate images on both the left and right side within a container or clip

I am currently utilizing Jquery Simplyscroll (http://logicbox.net/jquery/simplyscroll/) and I am seeking a way to incorporate a faded png image on both the left and right sides to prevent my images from appearing "cut off" while sliding through. Below is ...

Exploring the challenges of applying styles to buttons using the :first-child and :last-child selectors, especially when

I successfully applied rounded corners to the first and last elements of a styled button using CSS. Here is how it looks: https://i.sstatic.net/A62Kl.png The issue arises when I dynamically insert new buttons using Angular's ng-if. The new buttons ...

Add a class when there is no content available

I am trying to determine if the src attribute of an img tag is empty, and then add a class to another element. Below is the HTML snippet: <span class="page-icon"><img src="" width="40" height="40" alt="Privacy" /></span> If the src att ...

What is the best way to divide a Modal Header column into two separate sections?

Is there a way to center the text in the Modal Header and have the H1 and P tags occupy one row each? Applying d-block to each creates two columns. I also tried increasing the Height in the Modal Header without success. If you have a solution, please hel ...

Create a CSS border with a stylish downward arrow design

Recently, I came across a specific requirement that I need help with. You can see the image https://i.sstatic.net/j4Qdf.png. I found a helpful resource on how to create triangles using CSS on https://css-tricks.com/snippets/css/css-triangle/. However, I a ...

Enhancing Nativescript elements with pseudo selectors

Is there a way to apply the button:hover effect in Nativescript Buttons? I attempted the following code: Button:highlighted{ background-color: red; } Button:hover{ background-color: red; } Button:touch{ background-color: red; } ...

Tips on creating a dropdown menu with a fontawesome icon

I'm brand new to coding and struggling to create a drop-down menu similar to the one used in fonawsome fa fa-ellipsis-v While I'm attempting to code it here, I'm not sure why the class is being overridden. *{ margin: 0; padding : ...