How to eliminate text located beneath an image using CSS

Is there a way to position the p tag directly below the user name and not beneath the image, all without relying on padding or margin-left?

Here is the code snippet:

<ul class="comments_list">
  <li>
      <i>
        <img src='{{image_path}}' />
      </i>
      <span>User name</span>
      <p>{{comment_text}}</p>
  </li>
</ul>

Answer №1

Do you think this is the right approach? Can you share your CSS for 'class="comments_list"'? Are you utilizing <i> for italics?

<ul class="comments_list">
  <li>
      <i>
        <img src=http://icons.iconarchive.com/icons/dryicons/simplistica/128/user-icon.png />
      </i>
       </li>
      </ul>
<span>User name</span>
      <p>{{comment_text}}</p>

Answer №2

If you're open to using flexbox, it can simplify a lot of things. Check out this example: http://codepen.io/gc-nomade/pen/mPQeRM

li {
  display: inline-flex;
  flex-flow: column wrap;
  justify-content: center;
  height: 128px;
}
<ul class="comments_list">
  <li>
    <i>
        <img src=http://icons.iconarchive.com/icons/dryicons/simplistica/128/user-icon.png />
      </i>
    <span>User name</span>
    <p>{{comment_text}}</p>
  </li>
</ul>

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

Controlling Javascript events

Currently, I am working on implementing an in-place editor using jQuery. The functionality is such that when you click on the text you wish to edit, it will replace the content with an input field, specifically a select tag. Everything seems to be functio ...

I desire to place a picture atop a carousel within a bootstrap framework

I'd like half of my display picture to overlap the carousel image at the top and be centered. The carousel should serve as a cover page similar to Facebook. .dp-container{ width: 200px; height: 200px; border: 2px solid black ...

Animation transitioning from one page to another

I'm working on a simple jQuery click and scrollTo anchor script. On another page, I'm linking content using URLs like index.php#home, index.php#about, and so on... Is there a way to achieve the scrollTo effect from an external page? One idea I h ...

Generating tags dynamically with a function

Is there a way to showcase dynamic tags with proper line breaks in CSS? The responsive container needs to break gracefully: CSS: .tags { -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; background-color: white; ...

The animated sticky header lacks smooth animation while scrolling upwards

This dynamic menu transitions the logo to the left and the navigation to the right as you scroll down. The animation is smooth when scrolling down, but slightly jerky when scrolling up, especially with the navigation. The animation uses CSS3: transition: ...

What is the significance of using "your-shop" as the action form without a file extension?

I've come across filenames (with file extensions) or URLs inside the action attribute of a form, but I have never seen code like this before: <form action="your-shop" name="shop_name_form" id="shop_name_form" method="post" onsubmit="return check_s ...

Learn how to adjust the background color of a div when the text input field is in focus

When rendering the page, <div id="container" tabindex="0"> <input id = "input" type="text" /> </div> In the CSS stylesheet, #container::focus{ background-color: "red" } I am look ...

Only Google Chrome supports vertical centering using position:absolute

I am trying to create a div with multiple elements in the center of a section that has been set to 100% of screen height. However, I am facing an issue as the solution I implemented only seems to work on Google Chrome and not on other browsers. I have used ...

Guide on validating a dropdown using template-driven forms in Angular 7

Having trouble validating a dropdown select box, possibly due to a CSS issue. Any suggestions on how to fix this validation problem? Check out the demo here: https://stackblitz.com/edit/angular-7-template-driven-form-validation-qxecdm?file=app%2Fapp.compo ...

What is the best way to set the initial state of a Vue v-checkbox as false, rather than an empty

Currently, my code looks like this: <v-checkbox label="Consent?" v-model="form[consent]" ></v-checkbox> form starts as an empty object form: { consent: "" } Instead of an empty string for consent, I would ...

The Bootstrap 4 container class is known for leaving a peculiar dot next to the container

I am utilizing the container class from Bootstrap 4 to arrange my project details based on screen resolution sizes. However, I have encountered a strange dot that remains even after trying to remove it. You can view the HTML code I am currently working o ...

I'm having trouble with my vue props, can you lend a hand in resolving them

Recently, I delved into learning Vue.js and started implementing it in my project. The code snippet in my App.vue file is: In the second line of the code above, I passed a string "hello" as an attribute that is captured in the following code: App.vue: ...

What is the best way to implement an if-else structure in this code?

Can anyone help me with converting this code into an if/else statement? I want it to display certain content if 'Rental' is true, and other content if it's false. The PHP tags are making it difficult for me to follow. <?php if( get_ ...

Adjust text alignment based on the mobile device screen size using Bootstrap 4

On smaller devices, the layout of my horizontal label and text field is not as I expected. It appears like the image below: https://i.sstatic.net/9I8Os.png I am trying to make the First Name label left-aligned on small devices. Here is the code I have be ...

How to use jQuery to target every anchor element within an unordered list

I am trying to manipulate an unordered list structure by changing the class of the anchor tags when a specific link is clicked. For example, when the link in List Item 1 is clicked, I want to change the class of all links underneath List Item 1 to "yes". ...

The conceal feature doesn't appear to be functioning properly on jQuery Mobile

I am facing an issue with a small mobile app built using jQuery Mobile. Within a div, I have three buttons and other content. My goal is to hide these three buttons if the user's device is running on Windows (WP). The buttons are defined as follows: ...

Using Inline Font CSS for FontAwesome 5 Unicode Compatibility

I am currently utilizing a library that does not support the font-weight property. Instead, the font style is defined by the font CSS property as detailed here. After trying to set the font style using the font CSS property with FontAwesome 5, I noticed t ...

Excess space appearing to the right of the text box in Internet Explorer 9 standards mode and Google Chrome

Looking for help on how to eliminate the space between the right side of an input textbox and a red border? Check out these examples: IE: http://jsfiddle.net/fQHGA/ <div style="float:left;border:1px solid red"> <label style="float:left">a ...

Information will not be displayed when using getjson (undefined)

The data from the API is showing as undefined and I'm not sure why. Here is the HTML snippet: $(document).ready(function() { $.getJSON("https://data.iledefrance.fr/api/records/1.0/search/?dataset=repertoire-bibliotheques&q=&refine.typeins ...

The menubar gracefully descends over the rest of the page

I created a navigation bar using a <div> element. When the bar is clicked, the <div> below it slides down. However, I noticed that another content below those two <div>'s also moves down instead of staying in place. You can view an ...