Tips on aligning elements and incorporating icons in Bootstrap list items

Struggling to center an icon with text? Trying to achieve alignment of SVG + text while utilizing Bootstrap? You're not alone. Don't worry - I have the solution. Check out my before and after samples: Before After But here are some questions that need answers:

  • How can the text be perfectly centered?
  • How do you align the svg icon with the text seamlessly?

Thanks


<section class="perks">
    <img src="./media/blueCircle.svg" alt="" />
    <div class="container">
        <div class="row">
            <div class="col perksFirst">Perks of Meetlete</div>
            <div class="w-100"></div>

            <div class="row perksList">
                <div class="col">Access to our secure video platform!</div>
                <div class="col">
                    <img src="./media/2.svg" alt="" />Calls are executed through our App!
                </div>
                <div class="w-100"></div>

                <div class="col">Meetlete calls take place on your time!</div>
                <div class="col">None of your information is shared!</div>
                <div class="w-100"></div>

                <div class="col">Build loyalty with your fans!</div>
                <div class="col">Make lifetime memories!</div>
                <div class="w-100"></div>

                <div class="col">Earn up to 10x more than other platforms!</div>
                <div class="col">Meetlete calls are timed!</div>
            </div>
            <div class="w-100"></div>
            <div class="col">
                <button class="earlyAccess btn">Early access</button>
                <div class="launchDate">Launching 2/14/21!</div>
            </div>
        </div>
    </div>
</section>


.perks {
    display: flex;
    margin-top: 310px;
    position: relative;
}

.perks .earlyAccess {
    margin-top: 117px;
}
.perks img {
    position: absolute;
    left: 0;
    top: -50%;
}

.perks .row {
    justify-content: center;
}

.perksList {
    max-width: 860px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.perksList .col {
    font-weight: 600;
    font-size: 18px;
    display: flex;
    align-items: center;
    display: flex !important;
    text-align: start;
    margin-top: 26px;
}

.perksFirst {
    margin-bottom: 77px;
    font-size: 24px;
    font-weight: 700;
}

.launchDate {
    font-weight: 700;
    font-size: 18px;
    margin-top: 26px;
}

Answer №1

To make sure your icons are aligned perfectly with the text, consider grouping them together within a container div. Alternatively, you can utilize the powerful features of the Bootstrap grid system https://getbootstrap.com/docs/4.6/layout/grid/. This allows for dynamic rendering by organizing your content into a structured list.

For centralized alignment, apply text-align: center to the outer container div. If needed, adjust the style to text-align left within the inner element (perklist) to maintain proper text alignment.

Answer №2

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.container {
  justify-content: center;
  margin: auto;
  text-align: left;
  margin-top: 10px;
}

.heading {
  text-align: center;
  padding: .5rem;
}

.heading h3 {
  font-size: 24px;
  font-weight: 700;
  text-transform: capitalize;
}

.card {
  background: whitesmoke;
  padding: 2rem;
  border: darkgrey
}

span {
  display: flex;
  vertical-align: middle;
  padding-top: 1rem;
}

span img {
  display: inline-flex;
  height: 2rem;
}

span a {
  font-size: 18px;
  font-weight: 600;
  line-height: 2rem;
  padding-left: .5rem;
}
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Creative Solutions by Tarak</title>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  <link rel="stylesheet" href="new.css">
</head>

<body>
  <div class="container">
    <div class="row">
      <div class="col-xl-1"></div>
      <div class="card col-xl-10 col-sm-12">
        <div class="row">
          <div class="heading col-12">
            <h3>Benefits of Creative Platform</h3>
          </div>
        </div>
        <div class="row">
          <div class="col-xl-6 col-md-12">
            <span><img src="./your-image.svg" /><a>Customize your video experience!</a></span>
            <span><img src="./your-image.svg" /><a>Interact on your terms!</a></span>
            <span><img src="./your-image.svg" /><a>Engage with your audience!</a></span>
            <span><img src="./your-image.svg" /><a>Go above and beyond for your fans!</a></span>
          </div>
          <div class="col-xl-6 col-md-12">
            <span><img src="./your-image.svg" /><a>Experience seamless calls through our App!</a></span>
            <span><img src="./your-image.svg" /><a>Your privacy is our priority!</a></span>
            <span><img src="./your-image.svg" /><a>Create lasting memories!</a></span>
            <span><img src="./your-image.svg" /><a>Time your creative calls!</a></span>
          </div>
        </div>
      </div>
    </div>
  </div>
</body>

height of span img == line-height of span a (for it to be inline center)

change svg of your choice.

get creative with styles.

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

Firefox not supporting position fixed within relative parent

Two columns are displayed here, with the left column showing a list and the right column displaying information based on the selected element from the list. Due to the large size of the list, I implemented a feature where the right column stays fixed at t ...

Is there a way to display the output of jQuery in an input box rather than a span?

I need to display the result of this function in an input box instead of a span tag because I plan to utilize the result in the following form. function checkChange(){ $.ajax({ url: "ordercalculate.php", data: $('form').seria ...

Preventing jQuery from matching multiple elements

I'm currently working on implementing a rollover effect using jQuery. I've encountered an issue due to the fact that I'm trying to execute a mouseover event on an object containing a link. The specific scenario involves a level-2 navigation ...

Issues encountered with Angular validation when trying to implement HTML5 validation

I am currently utilizing AngularJS for data binding and attempting to validate data using HTML5 validation features, but encountering issues. Below you can find the code snippet I am using: @using (Html.BeginForm("Ask", "Question", null, FormMethod.Post, ...

React component failing to display CSS transitions

The task at hand requires the component to meet the following criteria: Items in a list should be displayed one at a time. There should be two buttons, Prev and Next, to reveal the previous or next item in the list. Clicking the Back/Next button should tr ...

Beginner in html, css, and javascript: "Tips for saving jsfiddle demos?"

Recently, I developed an interest in JavaScript and CSS and came across some impressive examples on jsfiddle. I was wondering if there is a way to "export" these examples to my computer. Simply copying and pasting doesn't seem to work. How can I modi ...

Display the hidden element using jQuery with the !important rule

There is a specific element that has been given a class with the following CSS styling: .cls { display:none !important; } Despite attempting to display this element using jQuery $(".cls").show(); This method does not seem to be effective. Is ...

Arranging DIV elements into rows and columns within a table

After working all night to fix a problem, my goal is to create this timetable: https://i.sstatic.net/dAt1J.png Specifically, I'm struggling to find a solution for rows 5, 6, and 7 in the first column. The image is from a program that only runs in IE ...

Creating unsightly class names using Node.js

Is it possible to automatically create random and unattractive class names? For example, is there a tool or plugin that can substitute the .top-header class with something like .a9ev within my CSS code? It would also be ideal if the class name in the HTML ...

troubleshoot clientWidth not updating when CSS changes are made

Summary: When I adjust the size of a DOM element using CSS, its directive fails to acknowledge this change even with a watch on the size. Aim I have multiple custom directives (simple-graph) each containing an svg. My goal is to enlarge the one under the ...

Understanding how to extract a specific value key from a JSON object in Typescript while utilizing Angular can greatly

I'm currently facing a challenge in Typescript with Angular where I need to retrieve a specific value from a JSON constant. While I am aware of the performance implications, I am wondering if there is a more efficient way to access this value within t ...

What could be causing the video to extend beyond the limits of the container?

When extending the result window, the video ends up overlapping the section below it. I am looking to keep the video within the confines of the section's height, which is set to height:100vh. Is there a way to accomplish this? Check out this jsFiddl ...

Constantly showing false values in AngularJS Firebase array objects

Encountering an issue with retrieving data from Firebase. When viewing console.log($scope.statusbaca), it shows 2 queries, true and false. However, in the app it only displays false. Apologies for any language barriers as English is not my first language. ...

Notify when the button value changes to "submit"

I recently added a jQuery form wizard to my website. I want users to receive an alert in JavaScript when they reach the end of the form. To achieve this, I inserted a simple JavaScript code at the beginning of my page within <head>..some code</hea ...

Determine the total cost based on the quantity purchased

I created a webpage for employees to select an item from a dropdown menu, and it will automatically display the price of that item. Check out my code below: <script> $(document).ready(function() { $('#price_input').on('change' ...

I am interested in implementing a logout feature using a button in PHP

<?php session_start(); ?> <form> <input type="button" id="logout" value="logout" name="logout"> </form> After initializing the session during login, I am seeking to terminate it using a button rather than via <a href="">l ...

Using Bootstrap 4 to create a dropdown button with the functionality of a regular

I'm struggling with the layout of my table header buttons. Whenever I add a dropdown button, it messes up the alignment and makes the whole thing look unattractive. Here's the code for my dropdown button: <div class="dropdown"> ...

AngularJS HTTP POST request encountering issue with success function not functioning as expected

I am currently working on implementing a basic HTTP post request to insert data into my database. The following pages are involved: register.php contains the registration form. maincons.js houses the application controllers. sqlregister.php include ...

How to customize the font size in three.js CSS3DRenderer

I am trying to use threejs's CSS3DRenderer to display text in my 3D view. However, I am facing issues with controlling the font size. Despite setting font-size: 1px in CSS, the text remains large. I also attempted to adjust the scale of the css3dobjec ...

What is the best way to rearrange the order of navbar items when working with two nav bars and a single toggle in bootstrap 4?

I am looking to implement a design with two navigation bars that share a single toggle. The first navbar should include the logo, email icon, and a search box, while the second navbar is reserved for additional links. On smaller screens, when the toggle ...