Display an SVG image and text in a row using Bootstrap

Looking to display a button with an SVG image and text side by side in a row.

This is how I am currently doing it:

<button class='btn btn-primary' style='background-color:purple; display: flex;'>
    <div style='text-align:center;'>
        <img src="assets/icons/Icon awesome-crown.svg" class="img-fluid" width="20px" height="20px">
    </div>
    Top Pick
</button>

As of now, the output looks like this:

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

However, my goal is to achieve this look:

https://i.sstatic.net/2OMgT.png

Answer №1

To center align items, use the code align-items:center in combination with display:flex. Additionally, add a margin-right to the icon by using margin-right.

<button class='btn btn-primary' style='background-color: purple; display: flex; align-items: center;'>
    <div style='text-align: center;'>
        <img src="https://vaibhavvijay.me/images/envelope-white.svg" class="img-fluid" style='margin-right: 8px;' width="20px" height="20px">
    </div>
    Top Pick
</button>

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

Is there a way to verify if a checkbox has been checked?

Having trouble with this code: if($('#primayins').prop('checked')) { $("#tx_nm0x0_pricingplan").val(1); } else { $("#tx_nm0x0_pricingplan").val(2); } It keeps returning false consistently ...

I am facing issues with the CSS in my EJS file when it is being rendered within an if statement

Having trouble applying CSS to this EJS file, no matter what styling I use. Here's the code snippet: itemEdit.ejs <%- include("partials/header.ejs", {title: ` - Items`, body_id: `items`} )%> <%- include("partials/navbar.ejs&qu ...

Issue with Bootstrap 5 offcanvas when placed inside a fixed div

I am currently incorporating the bootstrap navbar with offcanvas functionality. All nested within a fixed positioned div. The styling of the div is outlined below: .whiteHeader { position: fixed; display: flex; align-items: center; height: ...

Tips for preventing duplicate content in bootstrap

I want to showcase a clickable phone number on my website for mobile users. Here's the code snippet: class MyGrid extends React.Component { constructor(props) { super(props); this.state = { phone: "123" }; } render() { return ( ...

Is there a more efficient approach to applying a basic function to multiple elements within a DIV and having it activate only upon a click event using jQuery?

This solution works, but I am looking for a more professional approach in order to adhere to the principle of "don't repeat yourself." $("document").ready(function(){ $(".child").each(function(index){ $(this).click(func ...

retrieve the chosen option from the dropdown menu

Whenever I try to display the input type based on the selection from a select element, I encounter an issue Here is the select element within my view: <select id="type" name="type_id" class="form-control" required> @foreach($type as $row) & ...

Ways to acquire all elements of a webpage

As a newcomer to webpage scraping, I have been using YouTube videos and online resources to kickstart my journey. Currently, my focus has been on extracting webpage elements from the following site: This is what I have achieved so far: from requests_html ...

Having trouble incorporating Bootstrap 5's SASS variables into my project's SASS files

I'm attempting to utilize Bootstrap 5 variables in my custom styles.scss file. I have integrated the entire Bootstrap 5 source code into my project. I have noticed that I need to import specific .scss files in my styles.scss file for it to function co ...

JavaScript stylesheet library

What is the top choice for an open-source JavaScript CSS framework to use? ...

What is the best way to achieve a live text update in a div element using JavaScript?

Here's a code snippet I'm working with: <textarea id="input" onkeydown="pressed()"></textarea> <div id="output"></div> <script> function pressed() { var input = document.getElementById('input').value; ...

Unable to define the color of icons path using CSS in Vue 3

When using the iconify library for VueJS, the icons' paths automatically have "currentColor" as their fill color. The issue arises when trying to set a path's color via CSS, as it seems to be ineffective. Even with "!important", the color won&apo ...

Adding alpha or opacity to the background image will give it a unique and

Is there a way to darken the background image while keeping the text color the same? Check out this code snippet on JSFiddle div { display:block; background:url('http://placehold.it/500x500') 0 0 no-repeat; background-color:rgba(0 ...

Tips for extracting website language using Selenium in Python

When configuring the language in Selenium, I use: chrome_options.addargument("--lang=en"). During testing, I must verify that the language is indeed set to English. Perhaps I can confirm this by checking the value inside <html lang='... ...

Is there a way to verify the content inside the :before selector using Jasmine within an Angular 6 application?

Looking to test whether the content of a label changes based on the checkbox being checked using Jasmine in an Angular 6 project. Is this feasible? Code snippet: HTML <input id="myCheck" class="checkbox" type="checkbox" /> <label for="myCheck" ...

What is the best way to conceal a CSS div through PHP if the div is empty?

I need some help refining my previous question to ensure clarity. Is there a straightforward method for hiding a div when it doesn't contain any information, without causing confusion for the client? This specific div receives information from Jooml ...

The issue with Angular 2's Parameterised router link component not fully refreshing

I'm trying to figure out how to show a set of images when I click on a specific menu item. The menu structure looks like this: <ul id="demo23" class="collapse"> <li> <a [routerLink]="['image-gallery','Picasso ...

Eliminate any unnecessary spaces in the text of a link following the breaking of a word

While working on a navigation menu, I noticed that in large screens the navigation looks fine but in laptop view, the words are breaking up and it's acceptable. However, I want to remove the extra spacing after the text. In the large screen: https:/ ...

jQuery's searchbar alert feature notifies users when there are no search results found,

I've created a simple search bar for my application. Currently, it searches users by data attribute, but if there is no match, it displays nothing. I would like to show an error message when no user is found. I tried using an if statement, but the err ...

Prevent submission by deactivating the button if a file has not been

I need help implementing a solution to disable a submit button until a file is selected. I found a working example online, but I'm not sure if the issue lies with the script type. Here's the example I'm referring to: disable submit button u ...

Issues with the aligning of buttons using the justify-content property

The issue I'm facing involves a parent container with 3 buttons nested inside. The parent container is set to display:inline-flex, however, the justify-content: space-between property is not behaving as expected. Each button has a defined max-width in ...