I have a div contentinside a div main. contentcontains a table whose contents will be loaded from the database. Therefore, the width of the tables may vary. Just below the second column of the table I want to place a button. Thus, the position of the buttons should be automatically adjusted.
I currently solved it with a fixed position, but I would like to avoid using fixedit since the width of the column may change. In addition, the layout will not “respond” in this way.
This is my approach:
<style>
div{
border: 1px solid;
}
#main{
height: 500px;
}
#content{
overflow: auto;
height: 200px;
}
table, tr, td{
border: 1px solid;
}
button{
position: fixed;
left: 80px;
}
</style>
<div id="main">
<div id="content">
<table>
<tr><td>Column 1</td><td>Column 2</td></tr>
<tr><td>Column 1</td><td>Column 2</td></tr>
<tr><td>Column 1</td><td>Column 2</td></tr>
<tr><td>Column 1</td><td>Column 2</td></tr>
<tr><td>Column 1</td><td>Column 2</td></tr>
<tr><td>Column 1</td><td>Column 2</td></tr>
<tr><td>Column 1</td><td>Column 2</td></tr>
<tr><td>Column 1</td><td>Column 2</td></tr>
<tr><td>Column 1</td><td>Column 2</td></tr>
<tr><td>Column 1</td><td>Column 2</td></tr>
<tr><td>Column 1</td><td>Column 2</td></tr>
</table>
</div>
<button>OK</button>
</div>
Here's what it looks like:

Here is https://jsfiddle.net/p58d731e/1/
Is there a better way?