I am facing an issue with a div (div1) nested inside other divs. I want this div to span the full width of the display but maintain the same height and position as its parent div (div2). I have experimented with using position: absolute; on div1, but encountered difficulties in achieving the desired layout.
- One approach involved setting the body to position: relative; to enable div1 to occupy 100% width while struggling to synchronize its height with that of div2.
- Alternatively, setting the parent div (div2) to position: relative; allowed div1 to fill 100% height but presented challenges in matching its width with that of the body.
It would be beneficial if CSS offered functionality like:
.div1 {
height: 100%(.div2);
width: 100%(body);
position: 0(.div2);
}
Or something similar
JSFiddle showcasing the relevant details: https://jsfiddle.net/Hamleyburger/fqe5o46c/1/#&togetherjs=K02DaSO2nR
- My goal is to have the div ".selectable" contain a sub-div (inside?) that appears on hover, aligning in height with ".selectable" (its parent) and spanning the entire width of the body.
Additional information that may be pertinent: I incorporate Bootstrap and (Jinja2) templating. The widths of the existing divs derive from a wrapper container (.main) in my base template which is intentionally set narrower than the body for responsive design. If I were to eliminate .main div, adjusting individual div widths becomes necessary. While this solution might work by making non-div1 divs narrower, it lacks DRYness. SASS is utilized in my workflow.