Utilizing Flexbox in column formation to align elements perfectly on a single line

When my page receives data from an API, it dynamically generates item cards using this code snippet:

$('body > #cards_daily').append('<div class="card"> ' + item.items[0].name + ' <br> ' + item.finalPrice + '<img src="https://fortnite-api.com/images/vbuck.png" height="28px">' + ' <br> ' + '<img id="image" src="' + item.items[0].images.icon + '"></img>' + '</div>');

Below is the CSS I'm using for styling these cards:

.card {
    display: flex;
    background-color: rgb(148, 148, 150);
    width: 250px;
    height: 350px;
    border-radius: 15px;
    padding: 0px 10px;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    color: white;
    font-family: 'Poppins', Arial;
    font-size: 20px;
    margin: 15px 10px;
    text-align: center;
}

Currently, the small icon image is appearing on a separate line after the item price due to the flex-direction set to column in the card. Is there a way to position the image next to the price instead of below it?

You can view the website here:

Answer №1

If you want to add a small icon next to the price in HTML, here's how you can do it:

<div class="row"><span>1200 <img src="https://fortnite-api.com/images/vbuck.png" height="20px"></span></div>

Alternatively, you can use this code snippet:

<div class="card"> ' + item.items[0].name + ' <br> <div class="row"><span>' + item.finalPrice + '<img src="https://fortnite-api.com/images/vbuck.png" height="28px">' + '</span></div> <br> ' + '<img id="image" src="' + item.items[0].images.icon + '"></img>' + '</div>'

You can check out the screenshot here.

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

External CSS file unable to load background image as referenced

I am facing an issue with this code in my external CSS file as it doesn't seem to work at all. Strangely, when I move it internally, everything functions perfectly. Any thoughts on what could be causing this discrepancy? html { background-image:url(i ...

Is it possible to eliminate certain JavaScript code by clicking on something?

I've been searching for a solution to this issue without any luck. Currently, I have two main JavaScript functions running on a website I'm developing. One is for lazy loading images and the other is for smooth scrolling to an anchor link at the ...

What is the method for triggering a function from an input tag without actually typing into it?

Currently, I am utilizing the angular2 color picker which updates the value of the input element when a color is chosen instead of typed. My task now is to trigger a function once the value of that input tag changes. Unfortunately, keyup and keydown method ...

"Adding a PHP associative array to an HTML element with jQuery AJAX - a step-by-step

In my quest to retrieve this JSON data and populate it in a select box, I have crafted the following code snippet in my controller: public function getDistrictById() { $StateId=$this->input->post('StateId'); ...

communication platform similar to a messenger

Currently, I am in the process of developing a chat server using PHP. The functionality is similar to Facebook's one-to-one chat feature. However, I'm facing an issue with displaying messages between two users who are engaged in a conversation. D ...

Trouble persists with Semantic-ui themes remaining unchanged even after running gulp build

I've been attempting to modify the semantic-ui theme in the theme.config file, but I'm not seeing any changes take effect. There are no errors showing up in gulp or anything. Even after deleting the semantic.min.css file and rebuilding it, chang ...

Executing code on the server-side (back-end) using Javascript: A step-by-step guide

Imagine wanting to execute JavaScript on the server side instead of exposing the code to the client. For example: Starting with the JS native window Object from the browser. Performing all JavaScript processing in the backend by passing the window Object ...

Unable to choose an input form within a CSS div

Just installed a jQuery responsive menu tab but encountering issues with selecting forms to input values. It seems like a CSS problem that I cannot identify. Please assist me in resolving this issue. Below is the HTML code snippet: <div class="contai ...

Using Internet Explorer will display a vastly different blueprint site compared to what you see on Firefox or

I've been utilizing the Blueprint CSS framework for my website development in order to ensure compatibility across different browsers, but unfortunately it's not rendering properly in IE. The main body is off-center, the image positioning is inco ...

Using jQuery to retrieve the content of a span element by its class name

Is there a way to retrieve the value of a span using just the class name? There is only one matching span in the document. My attempt with $('span.foo').text(); did not work. Any suggestions on how to accomplish this? ...

Ways to incorporate transparency into the background color

Is there a way to make the following CSS statement partially transparent? background: none repeat scroll 0 0 #205081; If CSS2 doesn't support it, how can I add an opacity declaration in CSS3? ...

Include the <script> tag in the HTML code for an iframe without running it

Currently, I am working on an HTML code that involves memory for an Iframe. Interestingly, whenever I use the append function, it not only executes the code but also carries out its intended task. html = $(parser.parseFromString($("#EHtml").val(), "text/h ...

data-set contains an undefined value

I am encountering an issue while trying to retrieve the value of a data-set using JQuery. It seems to return undefined and I am unsure about the reason behind this problem: <option class="option" value="<?php echo $art["id_art"]; ?>" ...

What could be causing the top navigation bar's background color to not display properly?

Currently working on a website and trying to implement a top navigation bar. However, encountering an issue where the background-color is not displaying properly and appearing transparent. CSS: body { margin: 0; font-family: "Century Gothic", Cent ...

CSS/HTML leading to incorrect paragraph rendering

One thing I'm struggling with on my website cur-mudg-eon.com is getting a paragraph to display correctly. When you land on the main page, you'll see that "Paragraph #1" appears to the right of H2 "[ker-muhj-uhn]" instead of aligning left below th ...

Achieving Vertically Centered Alerts with Responsive Functionality in Bootstrap 5

I have implemented an alert that looks like this: <div id="success-alert" style="display: none; color: darkgreen; text-align: center; top: 50%; z-index: 9999" class="alert alert-success alert-autohide" role="al ...

Can you control the order of rendering for specific divs in a ReactJS application?

I need assistance with developing a mobile app using ReactJS and react bootstrap that can dynamically resize itself based on the screen size. One specific part of the app requires calculations to determine its dimensions based on the remaining space on the ...

Revising table content utilizing Django and Ajax

I am currently working with a pandas dataframe that I need to display in a Django Template. This is how I am doing it: In my views.py file def display(request): if request.method == 'POST': temp_df_path = './temp_match.csv&apos ...

Techniques for parsing a String in Objective-C

I am looking to parse a string to replace certain elements within it. If the string contains an <ol> tag, I want to specifically focus on replacing the <li> elements with numbers. I understand that I can utilize the rangeOfString method to c ...

Ways to send a notification every time there is a modification in the back-end data?

We are dealing with a simple JSON structure like the following: { name: "Johnson" } My strategy involves utilizing AJAX to display the name as shown below: $.ajax({ url: /info.json, success: function(data) { $('<span><b ...