Showing a numerical value in the bottom-right corner alongside a backdrop of an image

I am attempting to create a container that measures 26x26 pixels and showcases a number at the bottom right corner of this container. Furthermore, I want to include a 24x24 picture as the background of the container.

The code I have written so far is displayed below:

<html>
<style>
body {
    height:26px; 
    width:26px; 
    background-color:red;
}
#bottom {
    vertical-align:bottom; 
    text-align:right; 
    background-color:yellow;
}
</style>

<body>
    <p id="bottom">2</p>
</body>
</html>

For your convenience, here is the link to view the live demonstration on JSFiddle https://jsfiddle.net/n8ku715x/

Upon reviewing the JSFiddle demo, you will notice that it is not functioning as intended. The dimensions are incorrect and there may be other issues present. Any assistance provided would be greatly appreciated.

Answer №1

<style>
  body {
  }
  
  #ctn {
    height: 30px;
    background-color: blue;
    width: 30px;
    position:relative
  }
  #bottom {
    position: absolute;
    bottom: 0;
    right: 0;
    font-size: 10px;
    color: #000
  }
  

</style>

<body>
  <p id="ctn"><span id="bottom">4</span></p>
</body>

Check out this customized container with the number displayed inside - does it meet your requirements?

Answer №2

Give this a shot:

CSS

.box{
width:30px;
height:30px;
position:relative;
background-color:blue;
}
.numeric-box{
position:absolute;
bottom:0;
right:0;
background-color:green;
}

HTML

<div class="box">

<div class="numeric-box">4</div>

</div>

Answer №3

To make an element fixed at the bottom, simply include the classes "bottom-0" and "fixed" in your CSS code

Styling with CSS

#element {  
    background-color: yellow;
    bottom: 0px;
    position: fixed;
}

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

Using various colors to highlight specific sections of a letter or number

I am striving to recreate the unique image shown below, particularly interested in achieving the multi-colored effect on the numbers. This aspect of having different colors for parts of the number is intriguing and I would love to learn how it's done. ...

Selecting JavaScript file on change as default option

Currently, I have an HTML file that prompts the user to select an XML file when the file selection is changed. Is there a way to make it so that by default, only one file is chosen? <form id='fileSelection' action=""> <center> <in ...

View the full desktop version of the website on your mobile device

Which viewport dimensions should be added to the viewport meta tag in order to view a desktop version of a mobile site while browsing? ...

The presence of a Bootstrap addon is resulting in horizontal scrolling on mobile devices within the webpage

I am encountering a peculiar issue with an input-group in my cshtml file which features a Bootstrap addon. The problem arises on mobile devices, where upon focusing on the input field, the page scrolls horizontally to the right, revealing the right margin ...

What is the best way to adjust the height of a container to equal the viewport height minus a 300px height slider?

Forgive me for the rookie question, I know what I want to achieve should be simple but I seem to be having trouble articulating it in my search for solutions. Essentially, I am trying to set a section in HTML to the height of the viewport minus the height ...

Stylish Interactive Menu Item

Having a fixed navigation at the bottom of my website has presented me with an issue. The hover effect, specifically the background slide, triggers before I even place my mouse over the text. Currently, the background slides up when my mouse enters the .it ...

jQuery Accordion not showing up on screen

On my FAQ page, I have integrated a jQuery Accordion with a repeater control nested inside to display various questions and answers. The FAQ page utilizes a master page named LaunchPage.Master. Here is the code for LaunchPage.Master: <html> <he ...

The browser is unable to display an image file that contains the special character "%" in its name

I have an image file named 'a%1.jpg' that is not appearing in the browser. The code for my image tag is <img src="a%1.jpg" id="Image1" />. Is there a way to properly render the image using escape sequences? ...

Warning on React component listing due to key issue originating from the parent component

Alert: It is essential that each child in a list has a distinct "key" prop. Please review the render method of ForwardRef(ListItem). A child from RecipientsList was passed. I have located this issue using the react-components debugger tool on Chrome. I ad ...

Even when applying a class, the CSS link:hover style will only affect the initial occurrence

I've hit a wall on this issue and can't seem to find a solution. I styled a few links using classes, but it seems that only the first link is accepting the :hover and :visited state styling. I made sure to use classes to style all of them. Not su ...

object stored in an array variable

I am looking to find out if there is a way to access a variable or function of an object that has been added to an array. I want to display all the objects in the array on a web page using a function that will return a string containing their content. Thi ...

My draggable item seems stuck in place. Any ideas on how to get it moving again?

I have been trying to implement some code I found on this link. Despite adding all the necessary file links, the code is not functioning as expected. It should be able to move within the bounds of a container, but it's not working properly. var max ...

clicking on the anchor does not trigger the modal to open

Below is an anchor tag I have set up: <a href="#" data-toggle="modal" data-target="#modalTC">terms and conditions</a> Here is the structure of my modal: <!-- Modal --> <div class="modal fade" id="modalTC" role="dialog"> <di ...

Guide to importing scoped styles into a <NextJS> component

When importing a CSS file, I usually do it like this: import './Login.module.css'; In my component located at components/login/index.js, I define elements with classes such as <div className="authentication-wrapper authentication-basic ...

Hiding a parent DIV in JS based on specific content: Here's how

I need help figuring out how to hide multiple parent DIVs based on the content of a specific child DIV. Here's an example: <div class="report-per-day"> <div class="report-day">26 May 2022</div> <div class=" ...

The focus of the input is lost when the value is being edited, specifically in the case where ngFor and ng

I'm facing an issue with a simple list that binds two-way to a parameter hero in my hero.component.ts. Whenever I begin typing in the input field, it seems to lose focus and I have to click on it again. How can I ensure that users are able to edit th ...

Tips for arranging a menu horizontally with buttons in CSS

I am currently working with a dropdown menu that I coded using CSS, similar to the one shown at . My issue is that I have 4 menu items and I want the total width of the parent div to be divided equally among each item, regardless of the resolution. Curre ...

anchor text substitution for hyperlink

I currently have a code snippet that replaces a span class with a hyperlink. The hyperlink contains an abbreviation, and the alternate text for the link also includes the same abbreviation. Now, I am looking to replace the second abbreviation in the alte ...

Item floating in a list

I'm facing a challenging issue that I need help with. It's a bit complicated to explain, but I'll do my best. There's also a picture included to help illustrate the problem. The problem I have is with an ordered list. When the next row ...

How does JQuery handle color parsing in text?

Is there a way to automatically parse colors in text and apply them to CSS? For instance, if I type #40464f, I want the color to be caught and included in some CSS styles. I am familiar with how to achieve this by adding markup: <span data-color=""> ...