What is the best strategy for positioning an anchor element within a list item using JSX or Bootstrap in a way that maximizes efficiency?

I have the following code snippet

<li className = "list-group-item list-group-item-success" key ={todo.id}>{todo.text}<a style="float:right;" onClick={() => props.onEdit(todo)}
          className="edit-todo glyphicon glyphicon-edit" href="#"></a><a style="float:right;" onClick={() => props.onDelete(todo)}
          className="delete-todo glyphicon glyphicon-trash" href="#"></a>

Is it possible to move the anchor elements to the far right side of the list item? Thank you.

Answer №1

Explore the selection of badges offered by Bootstrap: http://getbootstrap.com/docs/4.1/components/list-group/#with-badges

Here's an example from the documentation:

<ul class="list-group">
  <li class="list-group-item d-flex justify-content-between align-items-center">
    Cras justo odio
    <span class="badge badge-primary badge-pill">14</span>
  </li>
  <li class="list-group-item d-flex justify-content-between align-items-center">
    Dapibus ac facilisis in
    <span class="badge badge-primary badge-pill">2</span>
  </li>
  <li class="list-group-item d-flex justify-content-between align-items-center">
    Morbi leo risus
    <span class="badge badge-primary badge-pill">1</span>
  </li>
</ul>

In response to your question, the flex utilities (

.d-flex .justify-content-between .align-items-center
) offered by Bootstrap are responsible for positioning the badge on the right side of the list item while keeping the text on the left. Any element can be used inside the list item.

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

Utilizing Variants in conjunction with Framer Motion's useAnimation feature

I am facing a challenge with my animation in React when it needs to be triggered as soon as it reaches the viewport. I found a solution on Stack Overflow, which uses the following logic: import { useInView } from "react-intersection-observer"; im ...

My observations on CSS challenges in IE7/8 and the Hashchange plugin

What is causing these float issues in Internet Explorer? Additionally, has anyone had any experience with 'jquery.ba-hashchange.min.js' and know how to make the hashchange function more visually appealing? Thank you! ...

What is the best way to place content in a single div without it being divided into several separate boxes

Here is my code snippet: <div class="col-md-9"> <div id="statbox"> {% for obj in product_type %} {% for obj1 in vastu %} <script type="text/javascript"&g ...

Show an HTML email message on a webpage without disrupting the existing page layout

Looking for a solution to display mail messages on a web page originating from an exchange server with various style elements that might interfere with the existing page layout. Attempting to load these mail messages within a div results in the style elem ...

The state is not being configured accurately

In my ReactJs project, I have a model Component with a picture that is displayed. I want to pass the data of the clicked picture, which can be neither raw data nor a URL. I have implemented a handler that can delete the picture (if pressed with the Ctrl k ...

How can I send dynamic props between pages using Next.js?

I am currently exploring Next.js and attempting to create a page (index.js) that fetches data about different countries and then displays this information. I would like each country element displayed on the page to have a button that leads to another page ...

What is the best way to make a default selection in a headless-ui combobox?

How can I set the first option as selected by default in a dropdown using the Combobox Component? Combobox Component import { useState } from 'react' import { CheckIcon, ChevronUpDownIcon } from '@heroicons/react/20/solid' import { Com ...

Issues with CSS filters affecting the layout of webpage elements

Is there a way to keep a div pinned to the bottom of the viewport while applying a filter to the body in CSS? I tried using position: fixed; bottom: 0px, but it seems to mess up the positioning when a filter is added to the body. body { filter: bright ...

The strange behavior of !important, display:none, and .height()

While working with a piece of JS code yesterday, I stumbled upon something peculiar. There was a div element that was initially hidden using display:none, and I was utilizing its height in some JavaScript calculations. Everything was functioning properly u ...

I possess a tool for generating QR codes and am curious about how I can implement it for direct download within a React environment

After creating a QR code generator, I encountered an issue with the download functionality. Currently, upon pressing the download button, it redirects me to another website where users have to right click and choose "save image as" to download the generate ...

Learn the method for implementing the Tab key as a means to select the current menu item in Downshift, as opposed

This is in relation to: https://github.com/paypal/downshift I have set the onKeyDown handler to detect when the Tab key is pressed and I am successfully retrieving the correct highlightedIndex value, but how can I utilize that to update the inputValue? ...

Error: Uncaught TypeError - The function indexOf is not defined for e.target.className at the mouseup event in HTMLDocument (translator.js:433) within the angular

Upon clicking on an SVG to edit my data in a modal bootstrap, I encountered the following error: Uncaught TypeError: e.target.className.indexOf is not a function at HTMLDocument.mouseup (translator.js:433) This is my SVG code: <svg data-dismiss ...

Tips for creating a responsive graphic using Bootstrap CSS

I am currently trying to determine how to create individual graphics that can be directly loaded via CSS and made responsive. When I resize the screen, the graphics also adjust accordingly. However, on smaller displays such as mobile phones, the graphics ...

What steps do I need to take to extract the date and month from a single datepicker using the code below?

<div class="col-md-3 pull-left" style="padding:9px"> <input type="text" id="datepicker" class="form-control"> </div> The HTML and C ...

What is the best way to resize an image for mobile site optimization?

I've been struggling with resizing an image by its width for different mobile devices even after trying to search on Google. Here's what I have attempted: CSS: img.test { width: 100%; height: auto; } HTML: <html> <head> ...

Why is it that my website in React crashes when I type rapidly in the TextField component?

Whenever I input text quickly into the TextField in my app, it causes my website to crash and display a blank white screen. Below is the snippet of code causing the problem: TextField Code: <TextField label="Item name" ...

The behavior of Datatables varies depending on the screen resolution

In my data table, there are numerous entries with child tables on each row of the main table. I am currently in the process of incorporating this type of functionality into my table, with a few modifications to create a table within the child row. You can ...

At times, the Kendo UI Tooltip may linger on screen longer than expected, failing to disappear as

I've been experimenting with this issue for quite some time now, but I'm stumped. Whenever I quickly move my mouse cursor over a series of links, occasionally a tooltip will linger on the screen even after the cursor has moved away from the link. ...

The sub div houses an everlasting MUI Drawer

I am currently experimenting with ways to ensure that the MUI drawer remains within a specific sub div. It appears to overlap on any content positioned underneath it. I have provided an example of this issue that I have imported on codesanbox https://i.ss ...

A step-by-step guide on simulating a click event on an element in React with the help of jest and react-testing

My component displays the following {list.options && list.options.length > 0 ? ( <div data-testId="MyAlertText" onClick={onAddText}> Add Text </div> ) : null} When testing, I am executing the following it('Ensure Add Text lin ...