This is conceptual right now, but I want to do something that feels complicated: place an element (like a <p>
so that it is fixed next to another <p>
) but still make it responsive if other elements are added to the page.
Here's what I mean. For reference, I am using Bootstrap 4's grid to create two columns. Let's say my HTML was:
<div class="col-md-9">
<h1>Header</h1>
<h3>Ipsum Industries Subheader</h3>
<p>This is the left column text</p>
</div>
<div class="col-md-3">
<p>This is where I want the text to constantly be next to the <p> element in the left column</p>
</div>
Is there any way that I can "nest" this second <p>
element to directly next to the left column <p>
regardless of other content?
Possible Questions
Why not just use absolute positioning? This is answered a lot, like here, on how to place two divs together. This is different - the reason I am thinking about this is that I am building an application in which Javascript will add elements into that first div. If I use a fixed/absolute location for this second element, it will look jumbled after, say, an <h4>
is appended before it.
In short, I want to know if it's possible to create a relationship between elements like this that will work in a dynamic way?
Do you need to use the grid? No, I am using the Bootstrap grid as a starting point, but then I realized this issue with how the positioning will break when a new element is added ahead of the <p>
. I can ditch the grid if necessary.