Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3723896
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T06:26:32+00:00 2026-05-19T06:26:32+00:00

I have two divs, and I just want the second one to be under

  • 0

I have two divs, and I just want the second one to be under [in z-index] the first one, I read about it here and I figured out that I have to use the following JQuery script:

<script type="text/javascript">
    $('#secondDiv').insertBefore('#firstDiv');
</script>

I tried it, but it didn’t work with me, Any help!!

<DetailedTemplate>
<div id="firstDiv" style="background-color:Black">
    <asp:ImageButton ID="SelectButton" Visible='<%# org.SelectedValue == null || Container.DataElement("ID").ToString() != org.SelectedValue.ToString() %>' runat="server" CommandName="Select" CommandArgument='<%# Container.DataElement("ID") %>'
      OnPreRender="SelectButton_PreRender" style="border-style:none; Height:58px; width:113px; cursor:hand"  ImageUrl="~/Contents/Images/item-background.png"/>
</div>

<div id="secondDiv" style="background-color:Red" >
    <center style=" margin: 5px; padding-top: 5px; padding-right: 5px; padding-left: 5px;">
        <asp:LinkButton ID="lnkTitle" ForeColor="#6c1b24" Font-Bold="true" runat="server"
            Text='<%# Container.DataElement("Name") %>' NavigateUrl="http://google.com">
        </asp:LinkButton>
        <div runat="server" visible='<%# Convert.ToInt32(Container.DataElement("NumOfChildren")) > 0 %>'
            style="border: 1px solid #6c1b24; width: 15px; text-align: center; height: 15px;
            margin-top: 25px; background-color: #fddb73; font-size: larger; font-family: Courier New;">
            <asp:LinkButton ID="btnExpand" runat="server" ForeColor="#6c1b24" CommandArgument='<%# Container.DataElement("ID")%>'
                CommandName="Expand" Font-Underline="false" Text='<%# Container.NumberOfChildren > 0 ? "-" : "+" %>' />
        </div>
    </center>
</div>

<script type="text/javascript">
    $('#secondDiv').insertBefore('#firstDiv');
</script>
</DetailedTemplate>

Note: I can’t put my divs as absolute in my situation.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T06:26:34+00:00Added an answer on May 19, 2026 at 6:26 am

    You don’t need any javascript or jQuery for this, it can be done easily with pure css

    You can see an example here: http://jsfiddle.net/MQgAM/ but there are lots of otehr ways to do it, in pure css…

    Remember that when you position elements in css you do it based on the nearest parent that is also positioned or the body tag if none exists. that why i wrapped the two inner divs in an outer that ahs position relative – setting an element to position relative will not change where it is on the page, it will work as any other inline or block level element, but it will reset the starting point for all children of it, that is positioned, so this way you can contain positioned elements.

    You can learn more about css positioning here

    If you absolutely cannot use position absolute, you can do the same trick with position relative, it will just take a bit of math on your side 🙂

    Lastly, if you don’t position your elemnts, z-index has no effect, and this cannot be done, unless you change your markup so the top elements lives inside the bottom element

    In general try not to use javascript if you can do it by pure css, it will make your web application much better 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://jsfiddle.net/pC6fC/1/ I have two divs, one above the other. When the first animates, which
I have two DIVs, first one has a link in it that contains the
I have two divs with width 100%. I want one to always be on
ASP.NET MVC I have one page Index.aspx where I'm loading two usercontrols into divs.
I have two div's one has textbox in it and other just plain text.
i have two divs one floated to the left and the other to the
i have two divs with the same ids but one has display=none and the
I have a page that i want to remain static with two divs that
I have two divs in my app and I want them to have custom
for example : I just have two divs in a body, body's height is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.