I am looking to arrange my top headers in a table so that the red square icon is always next to the first span without using absolute positioning. Is there a way to achieve this without using absolute position?
table.dataTable thead span.sort-icon {
display: inline-block;
padding-left: 5px;
width: 16px;
height: 16px;
background-color: red;
}
table.dataTable thead .sorting span.sort-icon { background: url('http://cdn.datatables.net/plug-ins/3cfcc339e89/integration/bootstrap/images/sort_both.png') no-repeat center right; }
table.dataTable thead .sorting_asc span.sort-icon { background: url('http://cdn.datatables.net/plug-ins/3cfcc339e89/integration/bootstrap/images/sort_asc.png') no-repeat center right; }
table.dataTable thead .sorting_desc span.sort-icon { background: url('http://cdn.datatables.net/plug-ins/3cfcc339e89/integration/bootstrap/images/sort_desc.png') no-repeat center right; }
table.dataTable thead .sorting_asc_disabled span.sort-icon { background: url('http://cdn.datatables.net/plug-ins/3cfcc339e89/integration/bootstrap/images/sort_asc_disabled.png') no-repeat center right; }
table.dataTable thead .sorting_desc_disabled span.sort-icon { background: url('http://cdn.datatables.net/plug-ins/3cfcc339e89/integration/bootstrap/images/sort_desc_disabled.png') no-repeat center right; }
.dataTable thead th {
position: sticky; top: 0;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b6d4d9d9c2c5c2c4d7c6f68398879885">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<table class="table dataTable table-hover display nowrap no-footer pb-5" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr >
<th data-key="from">
<span>Firstaname</span>
<span class="sort-icon datatable-span"/>
</th>
<th data-key="to">
<span class="datatable-span" data-key-translate="common.to">Lastname</span>
<span class="sort-icon datatable-span"/>
</th>
<th data-key="creator">
<span style="" data-key-translate="common.auctionCreator">Demand</span><br>
<span style="" data-key-translate="common.internalOnly">Duration (min)</span><br>
<span style="" data-key-translate="common.internalOnly">Date of demand</span>
<span class="sort-icon datatable-span"/>
</th>
</tr>
</thead>
<tbody></tbody>
</table>