showing the words directly beside the symbol

I am attempting to show the text alongside the icon:

Here is the icon:

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

When I position the text next to the icon, the first line that reads "testing: is simple dummy...." ends up in the middle of the icon, while the following line saying "an unknown printer...." appears below the icon. I desire for the second line to be positioned underneath the first line. Please refer to the image below:

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

This is how my code appears:

<div class="row" style="display:flex;">
            <div class="col">
                <img src=" https://i.sstatic.net/Ir7Kl.png" height="50px" width="50px" />
            <span style="font-size:20px;font-weight:bold">Testing:</span> 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  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.<br />
            </div>
        </div>

I also attempted to write the code like this:

<div class="row" style="display:flex;">
    <div class="col-auto">
        <img src="https://i.sstatic.net/Ir7Kl.png" height="50px" width="50px" />

    </div>
    <div class="col-auto">
        <span style="font-size:20px;font-weight:bold">Test test1:</span> 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  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.<br />
    </div>
</div>

The above code did not yield the desired result. With this code, the entire text appeared underneath the image.

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

I wish for the text to appear right next to the image rather than below it.

Answer №1

Whether the entirety of the text should align with the image or if the text should float depends on the desired layout.

Version 1: Float:

img {
  float: left;
  margin: 0 10px 2px 0;
}
<div class="row" style="display:flex;">
  <div class="col">
    <img src=" https://i.sstatic.net/Ir7Kl.png" height="50px" width="50px" />
    <span style="font-size:20px;font-weight:bold">Testing:</span> 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 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.<br />
  </div>
</div>

Version 2: Separate blocks (using display: contents on the span to include it as part of the second flex child):

.col.x>img {
  margin: 0 10px 0 0;
}

.col.x {
  display: flex;
}

.col.x>span {
  display: contents;
}
<div class="row" style="display:flex;">
  <div class="col x">
    <img src=" https://i.sstatic.net/Ir7Kl.png" height="50px" width="50px" />
    <span style="font-size:20px;font-weight:bold">Testing:</span> 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 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.<br />
  </div>
</div>

I would suggest adjusting the HTML structure to eliminate the need for display: contents on the span. Instead, create a shared container for the entire text that will act as the second flex child:

.col.x>img {
  margin: 0 10px 0 0;
}

.col.x {
  display: flex;
}
<div class="row" style="display:flex;">
  <div class="col x">
    <img src=" https://i.sstatic.net/Ir7Kl.png" height="50px" width="50px" />
    <div>
      <span style="font-size:20px;font-weight:bold">Testing:</span> 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 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.<br />
    </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

ACF repeater - implement unique data for the final row in each repeater setting

I have implemented the ACF repeater feature in my WordPress website. Currently, each repeater item is displayed within a col-md-6 column. I am looking to feature the last item in a wider col-md-12 column. <div class="container"> ...

Make the jQuery toggle() function work like a regular radio button when selecting multiple options at a time

I have recently created two radio buttons using <i> font icons. Previously, I had successfully used the same code to create a checkbox, so I applied it to the radio buttons as well. After fixing the positioning, everything seemed fine when interactin ...

The functionality of a nestable tree is unable to properly function within a modal user interface created with the < script> < / script> of Bootstrap

I am facing an issue where the tree structure does not display properly in a modal Nestable UI-Bootstrap. The select and expand/collapse buttons are not functioning correctly when injected into the ui-modal-bootstrap using jquery.nestable.js. How can I r ...

Modify/Change the Class Name of a Link using jQuery within a Navigation List Item Header 4 in a Navigation Menu

In a row, I have 5 link items enclosed within an h4, which is then nested within an li element. The li element is finally nested within a ul, located inside a nav element. Currently, when one of the links is clicked (thanks to a helpful example found here ...

Detecting collisions with spheres using Three.js Raycaster

I came across an example from a previously answered question on this site: Three Js Object3D Button Group Detect Single Object Click While Mouse Movement Causes Object3D Button Group Zoomi As I tried to customize it to fit my needs, I encountered a few is ...

Challenges with navbars and Bootstrap

Just started using twitter-bootstrap and I'm trying to customize the navbar by removing borders and padding, adding a hover effect for links with a different background color, and setting margins of about 10px on the left and right. However, I'm ...

Tips for effectively passing a parameter in @url.Action

I stumbled upon this piece of code: <button type="button" class="btn btn-inverse btn-danger" onclick="@("window.location.href='" + @Url.Action("ActionName", "ControllerName") +"'");"> Link </button> for redirecting- it works gre ...

The grid is evenly populated with icons

Is it possible to evenly distribute the icons by only using CSS? I'm aiming to achieve a result similar to this (unfortunately, I can't post images due to my lack of reputation). You can find an example solution that uses JavaScript here: _htt ...

Ways to verify if the length of a string is zero in Angular JS

An array was created and initialized with various fields, including targaauto. Within the add function, there is a check for an error alert if the length of the car plate is equal to 0. However, this functionality does not work correctly as the alert doe ...

Label the Kendo Switch device

While using the Switch Component from Kendo UI for Angular, I ran into an issue. The default labels "On" and "Off" were missing on my switch component even though they appeared in the documentation default switch. Upon further investigation, I found the "o ...

Implementing a Popover Notification When Clicked

I'm a beginner at this. I came across an example of a popover message box in the link provided below. I attempted to implement it, but for some reason, it's not working. Could I be overlooking something? Alternatively, is there a simpler way to ...

Creating a social media icon effect similar to Squarespace: A step-by-step guide

I am attempting to create social icon effects similar to those found on Squarespace for my project. You can see examples of what I mean by visiting: If you look at the social icons, when you hover over one icon, the others become transparent or turn grey ...

I am having trouble aligning my div perfectly and ensuring its responsiveness

I am working on a school project using HTML and CSS. The upper parts above the buttons are centered and responsive, but I am having trouble with the buttons. They are not centered (I adjusted the width to 60%) and they are not responsive. Any assistance wo ...

Mapping a single value to multiple IDs

I am facing a scenario where I have two dropdown menus. The selection of a value in the second dropdown should automatically select related values in the first dropdown. However, the challenge here is that there are duplicate values in the second dropdown ...

Functionality of selecting dates using a datepicker

Currently, I have a single-page web app that includes a datepicker function in the HTML. However, I am facing an issue where the date field remains selectable even when the page is loading to fetch data from the backend (DB). This results in the user bei ...

Storing multiple HTML elements in a variable with React allows for easy manipulation and

Looking to optimize some repeated code in a React component that renders HTML elements. Trying to save the repetitive html parts in a variable and then return them, but running into issues. const renderAddress = event => { if (event.venue.address.a ...

When my screen measures 1700px wide, a width of 100% in CSS appears significantly narrower than a width of 500px

Currently, I am working on designing a responsive layout for a 3D globe. The code snippet that stores the structure is as follows: <div class="text-center main"> <canvas id='globe' width='100%' height='100%'> ...

Why won't divs align vertically in the center?

I'm struggling to create a navigation bar layout where the icons are centered both horizontally and vertically within their cells. http://jsfiddle.net/digorydoo/j2v5m7gr/ I can't seem to pinpoint what's causing the issue with my current la ...

Unusual Box-shadow glitch experienced exclusively when scrolling in Chrome 51

While working on my website, I encountered a peculiar issue with the box-shadow in Chrome 51. My site has a fixed header with a box-shadow, but when I scroll up or down, the box-shadow leaves behind some marks (horizontal gray lines): https://i.stack.imgu ...

Parallax scrolling and Swiper slider, a match made in digital design

Currently facing an issue with Swiper Slider and Simple Parallax Scrolling. Whenever I switch slides, the same image is displayed repeatedly. I suspect the problem lies in the fixed position of the image within the parallax effect. Attempted to resolve b ...