0

I plan on relatively positioning a div inside another div in a flexbox container so as to achieve the following result.

In effect, both the photo and relatively positioned div are relative so that I can use their z-index. The parent div of these elements in question is a flexbox element who shares the space within said flexbox container with another div. Both divs have flex-basis of 50% so as to make sure that they each equally share the space in the parent div.

Here is a code example of what the divs look like WITHOUT the relatively placed div:

<div id="intro_container" style=" width: 100%; flex: 1 1 35em; margin-top: 3em; height: 100%">

        <div id="intro" style="margin-left: 4%; margin-right: 4%;
        display: flex; flex-direction: row; justify-content: space-around; height: 100%">

        <div id="photo">
            <img src="field.png" style="width: 27em; height: 35em; align-self:  center; position: relative; left: 46%;
transform: translateX(-50%);  z-index: -1; flex-grow: 1">
            <!--<div style="flex-grow: 1;  position: relative; background: transparent; border-style: solid; border-color: #DB9659; border-width: 0.04em; width: 27em; height: 35em; right: 19.05em; top: -1em; align-self: center;  z-index: 1 "> </div>-->
        </div>

        <div id="intro_text">
             <p style="margin-left: 4em; margin-right: 4em; text-align: center; font-family: Hanuman;
font-style: normal;
font-weight: normal;
font-size: 18px;
line-height: 27px;
letter-spacing: 0.05em;

color: #000000;">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        </p> 
        </div>
      


        </div> 
       
        </div>

As you can see both children equally share the space within the parent.

However, if I add the relatively placed 'frame' div:

<div id="intro_container" style=" width: 100%; flex: 1 1 35em; margin-top: 3em; height: 100%">

        <div id="intro" style="margin-left: 4%; margin-right: 4%;
        display: flex; flex-direction: row; justify-content: space-around; height: 100%">

        <div id="photo">
            <img src="field.png" style="width: 27em; height: 35em; align-self:  center; position: relative; left: 46%;
transform: translateX(-50%);  z-index: -1; flex-grow: 1">
            <div style="flex-grow: 1;  position: relative; background: transparent; border-style: solid; border-color: #DB9659; border-width: 0.04em; width: 27em; height: 35em; top: -37em; align-self: center;  z-index: 1 "> </div>
        </div>

        <div id="intro_text">
             <p style="margin-left: 4em; margin-right: 4em; text-align: center; font-family: Hanuman;
font-style: normal;
font-weight: normal;
font-size: 18px;
line-height: 27px;
letter-spacing: 0.05em;

color: #000000;">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

        </p> 
        </div>
   
        </div> 
       
        </div>

The child with the photo and the "frame" gets larger.

How do I force the parent div here to NOT grow at all no matter what elements I put inside of it ?

Lennuyé
  • 59
  • 1
  • 1
  • 7

0 Answers0