How to display a background image in an li element using CSS

I am attempting to display an image inside a customized circular list item. Specifically, I want to display a success tick image within that list item. Here is the CSS I am using:

span.round-tabs {
    width: 50px;
    height: 50px;
    line-height: 50px;
    display: inline-block;
    border-radius: 100px;
    background: white;
    z-index: 2;
    position: absolute;
    left: 0;
    text-align: center;
    font-size: 25px;
}

li.success span.round-tabs.one {
    background-image: url('img/if_Tick_Mark_Dark_1398912.png');
}
 
    
<li class="success">
  <a href="#" aria-controls="home" id="DivPatientDetails" name="PatientDetails" >
      <span class="round-tabs one">
          <i class="icon icon-profile-male"></i>01
          <h4>Patient's Details</h4>
      </span>
  </a>
</li>

However, the result I am getting is different from what I expected. Instead of the correct image, I am seeing this:

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

But I actually wanted it to look like this:

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

What could be causing this discrepancy?

Answer №1

To properly position an image, you can either use

background-position: center center;
or utilize background-position-y or background-position-x.

Once the positioning is set, ensure the size is accurate by applying the background-size rule in CSS. If you share a jsfiddle link, I'd be more than happy to help implement this solution for you to preview.

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

What steps should I follow to build a single page application with a navigation bar?

For my latest project, I am working on a single page application that features a dynamic navbar. The purpose of this application is for a music review site where genres like 'Pop', 'HipHop' and 'Jazz' will be showcased in the ...

There are additional elements that can be toggled, but I prefer to only toggle the one that I have selected

Every time I click on a table a, intending to toggle the .info inside the same div, it also toggles the .info in other divs. Can someone provide assistance with this issue? function info() { $('.table a').click(function() { $('.info ...

Struggles with aligning a hyperlink vertically in an unordered list

Here is a simple code I am using to vertically center a hyperlink within a UL. The style is applied to the hyperlink instead of the li because I need the entire list element to be clickable. Although my code works as intended, there seems to be a slight i ...

The KeyboardAvoidingView disrupts the structure of the flexbox layout

Check out this code snippet: return ( <KeyboardAvoidingView style={{ flex: 1 }} behavior="padding" enabled> <View style={style.flex1}> <View style={style.imageContainer}> <Image style={style.image} ...

Unexpected behavior observed with Mui theme breakpoints

I have defined breakpoints for my MUI React-based app like so export const lighttheme = createTheme({ palette: palette, typography: typography, breakpoints: { values: { xs: 0, sm: 600, md: 900, lg: 1200, xl: 1536, ...

jquery - issue with google analytics not loading in the footer

I have been attempting to integrate Google Analytics into all of my HTML pages. The specific page I am focusing on is rates.html. <html> <head> <title></title> <script src="//code.jquery.com/jquery-1.10.2.js"></scri ...

Alternative content can be pasted into the webpage

After finding out a peculiar phenomenon related to copy and paste, I decided to share it. If you head over to the Diablo 3 website () and scroll down to the bottom of the page, you will notice: ©2012 Blizzard Entertainment, Inc. All rights reserved A ...

What steps should be taken to avoid an event from occurring when an error message is encountered?

I have a dropdown list of cars where an error message is displayed if any of them becomes inactive. When the error message is shown, clicking on the Route Car button should prevent any event from occurring, i.e., no modal popup should be displayed. How ca ...

Issue with Vue's v-autocomplete component not clearing the user's typed text when an item is selected from

I have implemented a vue v-autocomplete component on my page. I am unsure if the current behavior is as expected, as I cannot find similar examples demonstrating this functionality. The issue arises when a user begins typing in text and the autocomplete ...

The alignment of divs can be disrupted in a Nested Grid system

I am working with a 16 grid system where I have two 8 column divs positioned side by side. In one of the 8 column divs, I am trying to include a 5 column div on the left and two three columns divs stacked on top of each other on the right. I have tried v ...

Safari is giving me trouble with this code, even though it's working flawlessly on all

Encountering an issue with Safari 8: var link = document.createElement('a'); link.href = 'http://10.4.3.40:3000/sample_product_list'; link.download = 'sample_product_list'; document.body.appendChild(link); link.click(); Whil ...

How can I make tooltipster display tooltips properly?

I have been struggling to customize tooltips using a library called tooltipster. Here is what I currently have: Head of index.html: <head> <!--TOOLTIP CSS--> <link rel="stylesheet" type="type/css" href="node_modules/tooltipster-master ...

html table displaying incorrect data while using dynamic data in vue 3

example status 1 Hello there! I'm trying to create a table (check out example status 1 for guidance). Here's the code snippet I am using: <table> <tr> <th>Product</th> <th>Price</th> <th>Av ...

Adjust the top margin of a div to match the height of the screen within an iframe, ensuring cross-browser

Trying to adjust the margin-top of a div to 100% of screen height within an iframe seems to be causing issues with jQuery, as it either returns 0 or inaccurate values. While CSS3's 100vh can work as an alternative, it may not be supported in older an ...

What could be causing the lack of functionality when defining a CSS role using :host ::ng-deep within an Angular component's stylesheet?

My knowledge of Angular and CSS is limited, and I am facing a problem when trying to define a CSS style for a specific component in the .css file. If I use the following code snippet: .p-column-title { display: none; } it works perfectly. However, wh ...

javascript alter css property display to either visible or hidden

I am struggling with a CSS id that hides visibility and uses display: none. The issue arises when I want the element to be visible upon clicking a button, but removing the display:none property is causing design problems due to it being an invisible elemen ...

create a gentle appearance for an element

I am looking to replicate the visual appearance of each page on this particular website: There is something about the lighting that I really admire. I have attempted to recreate the animation, but I have been unsuccessful in my attempts. Any assistance wo ...

Conceal the nearest parent element above using JavaScript (or jQuery)

I need to implement a functionality where clicking a button hides a specific HTML class. The structure of the HTML is as follows: <thead> <tr class="employee-list"> <th> <button class="show-emp">S ...

Creating a CSS style that automatically adjusts the font size within a container that spans the full height of the

Issue: I have a container set to 100vh, but as the screen size changes, I want the font size to adjust accordingly and always stay within the container without overflowing. Thoughts: While I understand this can be achieved easily with @media CSS rules, I& ...

What is the most effective method for starting an application from a web browser, regardless of platform or browser used?

Forgive me if this question has been asked before in a similar way. I have multiple test applications that operate on different platforms such as Windows 95, Windows XP, SUSE, RedHat, and other variations of UNIX. Currently, the process involves a native a ...