steps to overlay an image over another in bootstrap:

I am trying to place an image over another image.

Here is the code I have used:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
    <script src.="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
    <script scr="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrapmin.js"></script>
  </head>
  <body>
    <div class = "row text-center" style="">
      <div class="col-xs-6 text-center" style="background-color:none; margin-top:10px;">
        <img src="1.jpg" width="250" height="250">
        <img src="plus.png" width="50px" height="50px">
      </div>
    </div>
  </body>
</html>

The outcome looked like this:

https://i.sstatic.net/4RI6P.jpg

However, what I actually want is a Plus symbol on top of the image, similar to this example:

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

Answer №1

Give this a go

CSS Code:

.product-holder {
    position: relative;
    display: block;
}

.plus-image {
    left: 50%;
    top: 50%;
    position: absolute;
    margin-top: -25px;
    margin-left: -25px;
}

HTML Markup:

<div class = "row text-center" style="">
    <div class="col-xs-6 text-center" style="background-color:none; margin-top:10px;">
        <div class='product-holder'>
            <img src="1.jpg" width="250" height="250" class='product-image'>
            <img src="plus.png" width="50px" height="50px" class='plus-image'>
        </div>
    </div>
</div>

Answer №2

To position the second image correctly, consider using "position: absolute" and then ensuring it is centered over the other image by adjusting

 top: 50%;
 left: 50%;
 transform: translate(-50%, -50%);

Remember to set the container with position: relative in order to contain the "fixed" image properly.

Answer №3

Apply the position:absolute property to your icon...

then use CSS to reposition it on the image

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

Tips for ensuring that the headers remain fixed in both the horizontal and vertical directions while allowing the data

I have been trying to create a table with a fixed header (meaning the header must be visible both vertically and horizontally). The table should be scrollable It should have a horizontal header The vertical header should match the horizontal header When ...

Querying val results in an empty string being returned

In my application, I have the following HTML code snippet: <tr style="cursor:pointer;"> <td>100101</td> <td>Monkey</td> <td>Nuts<td> <td>Cow</td> <td>Soup</td> <t ...

Implementing Laravel Blade Popup for Supporting Multiple Languages

I'm facing an issue while trying to implement multi-language support in a Laravel project. The problem arises when I try to add a confirmation alert. For instance, onclick="confirm( {{ __('Are you sure you want to remove this method? The ...

Angular is having trouble properly rendering the Array Description

I'm currently working on a project using .net core MVC with an Angular frontend. I am facing an issue where the description of parameter arrays is not displayed in the output, even though single parameters display correctly. How can I resolve this pro ...

Is there a way to eliminate the whitespace beneath the "Brilliant" division?

[Screenshot of white space under div] [1]: https://i.sstatic.net/cO7TV.jpg I'm having trouble figuring out why there is visible white space here. As a coding beginner, I would really appreciate any assistance. I've tried searching for the soluti ...

Adjustable Text Size with HTML5 and CSS3

Looking to enhance the accessibility of a website by implementing text size adjustment buttons ' A A A ' using just HTML5 and CSS3. Avoiding the use of jQuery or Javascript for this task. Inspiration drawn from this link. Appreciate any assistan ...

Error in Angular 2: The app.component.html file triggered an exception at line 1, character 108 due to excessive recursion

After successfully setting up the Angular 2 quickstart and connecting to an express server, I encountered a problem when switching from using the template property to component templateUrl. I have created a Plunker to showcase this issue: Plunker Demo imp ...

Having trouble with the "Corrupted @import" error during grunt build?

As I embark on my journey to create my very first Angular application, I have encountered a roadblock. Using Yeoman and angular-generator, everything seemed to be running smoothly with "grunt serve." However, when I attempted to execute "grunt build," the ...

Obtaining the HTML content of a div element that has been retrieved through an AJAX request to a PHP script

My challenge is to fetch a dropdown menu from a server and then manipulate it using jQuery after loading. Although everything loads correctly, I am unable to interact with the dropdown items because they were dynamically added post AJAX response instead of ...

Encountering a problem with the persistent JavaScript script

I have implemented a plugin/code from on my website: Upon visiting my website and scrolling down, you will notice that the right hand sidebar also scrolls seamlessly. However, when at the top of the screen, clicking on any links becomes impossible unless ...

Boosting the specificity of Material UI override styles

I came across a question about Material UI Overriding styles with increased specificity that seemed related to my issue, but I couldn't apply the solution to my problem. My problem involves a vertical Slider with marks, and I am trying to remove the ...

Why are the UI components (`Card Number`, `MM/YY`, `CVC`) not being displayed in the React app when using Card

Having an issue where the CardElement Ui component is not visible in the image provided. It should appear above the Order Total: $0 next to the payment method. https://i.sstatic.net/NCK5z.png I've attempted various debugging methods without success. ...

Tips for transferring input values from a JavaScript function to a separate PHP page for storage in a database

This code snippet allows dynamic rows to be added to a table when the add button is clicked. Now, the goal is to retrieve the values entered into the text boxes and submit them to the database. <div id="addinput"> <p> <button name=" ...

Insert more text following the existing content

Is it feasible to include text using pseudo-elements ::after or ::before to a specific word? For example, I am interested in placing a PDF icon consistently beside the word "Download". [PDF] Download Alternatively, are there other methods available? ...

Attempting to create an OutlinedInput with a see-through border, however encountering strange artifacts

Struggling to achieve a TextField select with outlined variant and a see-through border. Here's the current theme override I'm using: overrides: { MuiOutlinedInput: { root: { backgroundColor: '#F4F4F4', borderR ...

A guide on integrating a data deletion feature in Angular applications

On our website's edit page, there is a list of mat cards/workspaces with an edit icon in the top corner of each workspace. Clicking on the edit icon will take you to the edit page for that specific workspace. Within this edit page, there is a delete b ...

Text Separation Within a Singular JSON Object

Currently, I am offering my assistance as a volunteer to develop a fast AngularJS App for a non-profit organization. Although I have successfully set up Angular, the main issue I am encountering has to do with parsing JSON data. The JSON object that I am ...

Escaping multiple levels of quotations in a string within HTML documents

Currently, I am developing an application with Java as the backend and AngularJS 1.0 for the frontend. To display data tables, I am utilizing the veasy AngularJS plugin which I have customized extensively for my app. However, I am facing a small issue. I ...

Issues with retrieving the subsequent anchor element using Jquery Slider

(Apologies for the lengthy post. I like to provide detailed explanations.) Just starting out with Jquery, trying my hand at creating a custom image slider from scratch. Got the slider working with fade effects using this code: Javascript: $(document).re ...

Background positioning in IE8 does not display as intended

I'm experiencing an issue with the image background not displaying in IE8. You can view the page here, and the arrows on the accordion are not visible. Here is the CSS: .closed h2.accordion_h3 { background: url(mysource_files/down.png) no-rep ...