Position a Font Awesome icon and a paragraph side by side

I'm having trouble getting the green "v" mark icon to align with the paragraph text on the same line. The "v" always appears above the paragraph, and this issue arose when I used flex or grid for spacing between the two elements. I've tried using justify-content, align-items, padding-top, but nothing seems to work. Does anyone know how to fix this?

  <style>
.content {
background: #3494db;
color: #fff;
width: 65%;
margin: auto;
display: grid;
grid-template-columns: 1fr 1fr;
}
.column1{
  color: black;
  line-height: 15px;
text-align: right;
margin-top: 5px;
margin-bottom: 10px;
padding-right: 25px;
}
.column2{
color: black;
line-height: 15px;
text-align: right;
margin-top: 5px;
margin-bottom: 10px;
padding-right: 25px;
}
.column1 i {
display: flex;
justify-content: space-between;
margin-left: 10px;
}
.column2 i {
display: flex;
justify-content: space-between;
margin-left: 10px;
}
.column1 p{
border-bottom: 1px #fff solid;
}
.column2 p{
border-bottom: 1px #fff solid;
}
.content i{
color: rgb(50, 230, 50);
font-size: 18px;
}
</style>


</head>
<body>
  <div class="content"> 
       
    <div class="column1">
          <p><i class="far fa-check-circle"></i> Free for all</p>
    </div>
    
    <div class="column2">
      <p> <i class="far fa-check-circle"></i> Free for all</p>
    </div>
</div>


</body>
</html>

Answer №1

In order to align column1 and column 2 with display: flex; instead of display: float;, I made a small tweak by using float: left; on both elements. This adjustment brings the check marks in line with the paragraph, but there was an issue with the white underline interfering with them. To resolve this, I incorporated 5px of padding-bottom to column1 p and column2 p. The CSS code for these classes appeared as follows:

        .column1 i {
           display: float;
           justify-content: space-between;
           margin-left: 10px;
           float: left;
           }
        .column2 i {
           display: float;
           justify-content: space-between;
           margin-left: 10px;
           float: left;
           }
       .column1 p{
           border-bottom: 1px #fff solid;
           padding-bottom: 5px;
           }
       .column2 p{
           border-bottom: 1px #fff solid;
           padding-bottom: 5px;
           }

If this modification meets your requirements, please confirm!

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

When two rectangles are created at the same coordinates (x, y) in SVG, it results in an unexpected border appearing

.rect-x { fill: red; } .rect-y { fill: pink; } <svg viewBox="0 0 1024 768"> <rect class="rect-x" x="0" y="0" width="100" height="100"></rect> <rect class="rect-y" x="0" y="0" width="100" height="100"></rect> </svg& ...

Chrome's rendering of CSS flex display shows variations with identical flex items

I am facing an issue with my flex items where some of them are displaying incorrectly in Chrome but fine in Firefox. The problem seems to be with the margin-right of the rectangle span within each flex item, along with the scaling of the text span due to f ...

Assign individual heights to multiple iFrames according to their content's height

Dealing with multiple iframes on a single page. Each iframe is sourced from my domain. The goal is to automatically calculate and set the height of each iframe on the page. The current code sets all iframe heights to match that of a specific iframe: fun ...

The div element is persisting despite AJAX attempts to remove it

I am currently developing an application that allows users to post and comment. I have a situation where I need to delete a specific comment by clicking on the associated 'x' button. To achieve this, I am making an Ajax call to the remove-comme ...

How can I retrieve values from HTML5 data attributes using Selenium in Python?

How can I extract the value "165796011" from data-gbfilter-checkbox? I attempted to do so using the following code: element= driver.find_element_by_css_selector('#widgetFilters > div:nth-child(1) > div.a-row.a-expander-container.a-expander-inl ...

Struggling to utilize Mechanize with Python for choosing options from a dropdown menu on an ASP.NET website

Trying to scrape product information from an ASP.NET page (found at ) using Mechanize in Python. The page contains a dropdown menu with various food brands. Here is a snippet of the HTML code: <fieldset class="pulldownfieldset"> <label>. ...

What is the best way to display grouped items horizontally in an ASP.NET ListView?

My ASP ListView currently displays items vertically in columns with GroupItemCount set to 3: A D G B E H C F I Is there a way to adjust the display so that it groups items horizontally in rows like this? A B C D E F G H I This is the ListVi ...

How to position footer at the bottom of Material UI cards - see example below

After getting inspiration from the material-ui example of cards, I wanted to create a grid layout with multiple cards. My goal was to make all the cards have equal height (which I achieved using height:100%) and position the footer at the bottom of each ca ...

Tips for incorporating a local image using file:// in JavaFX WebKit

I am facing an issue with displaying a picture in a JavaFX webview using local HTML. Despite writing the code, I am unable to show the image. The URL of the image is "file:/D:/a.jpg". //Main WebViewBrowser.java public class WebViewBrowser extends Appli ...

Initiate a new line within a flex item

<Popper id={"simplePopper"} open={this.context.loading} style={{display: "flex", alignItems: "center", justifyContent: "center", backgroundColor: 'red',opacity:'0.5',width:'100%',he ...

Thick black border on select list in Internet Explorer version 10

After recently switching to IE10, I couldn't help but notice that all my dropdown lists (select lists) now have a bold black border when in the "dropped down" state, like the example below. Unfortunately, I am unable to inspect the element using IE&ap ...

React: Animate with CSS

How can I make sure that every time a new user is prepended, the first div has a CSS animation? Currently, my code only works for the first prepend and the animation does not trigger on subsequent ones. const [userList, setUserList] = useState<any> ...

There is an issue with the navigation keys not functioning correctly within the cellrenderer input boxes in ag grid

Struggling with an autocomplete input box within the cell renderer component in an ag grid cell. When attempting to use the left/right navigation keys, the input does not move inside the box and instead exits the cell abruptly. Similarly, navigating down ...

Code that achieves the same functionality but does not rely on the

I utilized a tutorial to obtain the ajax code below. The tutorial referenced the library jquery.form.js. Here is the code snippet provided: function onsuccess(response,status){ $("#onsuccessmsg").html(response); alert(response); } $("# ...

Unveiling the hidden secrets of HTML code through scraping

Looking to extract data from the cadastral records in Poland available at . Specifically, I am interested in retrieving information from the element tagged with id 'gfi_0'. The challenge is that this element is not immediately accessible; it only ...

Creating a 3x3 grid with CSS grid is great, especially when you want to place items in specific columns within the grid

I'm attempting to design a layout that has a unique structure: https://i.sstatic.net/dCLoPm.png The blue rectangles are represented by divs. It's like a 3x3 grid, but with spaces in the 3rd and 4th columns of the grid. How can I incorporate th ...

What is preventing me from adjusting the height of this DIV element?

I'm completely stumped by what's happening here. I've been trying to increase the height of a DIV element with an id of #titleStrip, but it just won't budge. It's beyond frustrating. I thought I knew my way around this kind of thin ...

Running JavaScript code on a webpage using Selenium

I'm currently developing an automated script to enter a person's address details on a webpage. It's important to note that I did not create this webpage myself. While filling in the address details, I encountered an option to select the coun ...

Understanding the concept of nested menus in ASP.NET

A table displaying a list of items with their corresponding details is shown below: ItemID MENU ParentID ImgUrl ----------- -------------------- ----------- ----------- 1 Home 0 ...

Datatables jQuery provides the ability to dynamically assign array index values to the 'sClass' property

Consider this code snippet: let dataSet = [ ['1', 'Safari','Mac OS X','13.1','A','N/A'], ['2', 'Chrome','Windows 10','90','B','N/A&a ...