How to place a relative element in front of an absolute element using CSS

I have encountered an issue where I need to display a relative element in front of an absolute element. I am aware that z-index does not work with relative elements. Is there a way for me to show the image in front of the strip?

http://jsfiddle.net/Q9EEv/9/

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Teset</title>
<style>
.container {
      width: 1170px;margin:auto
      }
      .footer-elements{text-align:center;bottom:0;height:15em}
      .footer-elements .content-b{text-align:center;position:relative;height:10em}
      .footer-elements .content-b img.main-img{text-align:center;width:18em;margin-top:-3em}
      .footer-elements .content-b .strip-m{background:#231F20;height:9em;}
      .footer-elements .content-b .strip-border{width:100%;height:1.3em;position:absolute;top:0;left:0%;background-size:auto 100%;
      background:url(http://i666.photobucket.com/albums/vv22/SincerelyBerry/HAIJYNX/backgrounds/stripes.png) repeat-x;}
</style>
      </head>
      <body>

          <!-- container Start -->
          <div class="container">
          <br><br><br><br><br><br><br>
                  <div class="footer-elements">
                        <div class="content-b">
                            <div class="strip-m row">
                                <div class="strip-border"></div>
                                <img src="http://i252.photobucket.com/albums/hh15/liveyourlife815/stripes-1.png" class="main-img" alt="footer">
                            </div>
                        </div>
                  </div>
            </div>
      </body>
    </html>
http://jsfiddle.net/Q9EEv/9/

The absolute element is the strip, and I want it behind the relative image.

Thank you

Answer №1

Well done! Check out this link: http://jsfiddle.net/Q9EEv/10/

.content-b img
{
    position: relative;
}

You figured it out on your own. Remember, z-index only works on elements that are positioned (not static).

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

Creating an HTML Canvas effect where images are placed onto another image

Looking to create a similar effect as seen on this website () On this site, users can upload their images (4000 * 400) and have the option to add Mickey Mouse ears over their image before saving it. The Mickey Mouse ear is resizable from all four sides f ...

What is the information stored inside the div element?

How can I extract the contents of a div using bs4? >>> Doc <div class="document"> <p>Text.</p> <p>More text</p> </div> >>> type(Doc) bs4.element.Tag I am looking to retrieve: <p>Text.</p> ...

Deliver JavaScript and HTML through an HTTP response using Node.js

My attempts to send both a JavaScript file and an HTML file as responses seem to be failing, as the client is not receiving either. What could be causing the client to not receive the HTML and JavaScript files? I am using Nodejs along with JavaScript and H ...

Updating Template in Python Flask upon Button ClickLet's enhance our Python Flask application by

I need assistance with switching templates upon clicking a button. My Python code is as follows: @app.route("/", methods = ['POST', 'GET']) def my_forum_post(): if request.method == 'POST': if reque ...

Strategies for Locating XPath Using Text Content within Table Cells (td / tr)

Need help with searching for specific text within a large HTML table of emails and selecting a button within the element? You can easily find the table body via XPATH by using: //*[@id="reportList"]/tbody Within this table, there are multiple rows (tr). ...

Is it possible to add animated text using anime.js?

var elements = document.querySelectorAll('.content'); anime({ targets: elements, content: 100, }); <script src="https://raw.githubusercontent.com/juliangarnier/anime/master/lib/anime.min.js"></script> <span class="content"> ...

Arranging images in a way that resembles the format of Google image search

Google displays its images in a certain way: However, I encounter this issue when attempting to implement it: It appears that simply using float:left may not be enough, but what else can I do? The images will vary in height and width. I have added a max- ...

Craft a dynamic countdown timer that blinks using CSS

I am attempting to design a blinking countdown timer that starts at 5 seconds and disappears when it reaches 0. CSS: .blinky { transition: 1s opacity; -moz-transition: 1s opacity; -webkit-transition: 1s opacity; } HTML: <div id="count ...

"justify-content-md-end" and "justify-content-center" displaying contrasting behaviors

It seems that my implementation of "justify-content-md-end" and "justify-content-center" is not working as expected. According to my understanding, the content should be positioned towards the right when the window is shrunk and in the center when it' ...

What is causing the content on my webpage to not fill the entire width of the page?

I've encountered an issue with the content on one of my pages not expanding to the full width of the page. Despite placing everything inside a container and setting the max-width of the container to 1500px, the content still doesn't extend all th ...

Basic HTML user interface elements

I'm struggling with some basic HTML/CSS and I'm looking for guidance on what I might be doing incorrectly or if there is a more efficient approach? I'm attempting to create a simple user interface, and while I have put this together, it doe ...

Discovering the true width of elements that have overflow hidden in IE7 using jQuery

I am dealing with a dynamic list that contains around 50 elements, but the exact number may vary. <div style="width:465px;"> <ul> <li>aaa</li> <li>aaa</li> <li>aaa</li> <li>aaa& ...

Ways to enhance a browser's response with soup

I have a script that sends multiple requests to a website using RoboBrowser and retrieves responses, but now I need to filter these responses to exclude any containing the phrase "Case Status Not Available". I attempted to use Beautiful Soup for this purpo ...

Unexpected behavior from Internet Explorer - Span contents remain unchanged despite valid input

I have a simple question because I'm feeling a bit lost. Check out this JSFiddle link It seems that in Internet Explorer, the contents of my span won't update even though the input is valid. However, in other browsers, the span content changes ...

Why is the 'a' element not clickable after the AJAX complete function has executed in JavaScript?

I have a small question regarding my use of AJAX. Everything is working fine, but after the AJAX request completes, I am trying to change the element attributes such as backgroundImage dynamically. Although this process works correctly, the element that wa ...

The dropdown in the HTML tbody section is displayed above the thead

I'm experiencing an issue where my tbody element is appearing above the thead section in my table. I've been unable to identify the cause of this problem. <table id="myTable" class="table table-inverse table-hover"> <thead id = "h ...

Organizing files on a website for collaborative projects involving multiple team members

I am currently constructing a website with the following specifications: Pages are being loaded inline via AJAX. CSS, HTML, JavaScript, and PHP are all separated to facilitate collaboration on projects. While working on creating a dynamic <select> ...

What's the reason my Bootstrap isn't functioning on HostGator's servers?

My bootstrap website works perfectly fine locally, but when I try to upload it to hostgator through cpanel, it just keeps loading. Here is the URL www.universitymmt.com Below is a snippet of the code: <!DOCTYPE html> <html lang="en"> ...

Sending a post request to a Spring controller with ajax: Step-by-step guide

I am having trouble sending a post request to the spring controller using ajax. It seems that something is not working correctly. If anyone can help me figure out what I did wrong, I would greatly appreciate it. $("#myprofile").on('submit&ap ...

Establish a predetermined selection for a drop-down menu

How can I set a default value for a dynamically filled dropdown menu featuring all 12 months in KnockoutJS? I want the default value to be the current month. This is how I am populating the dropdown with information: self.setMonthData = (data ...