After considering a few comments and editing a question, here is an updated approach.
The most straightforward way to achieve this is by utilizing Flexbox. Please refer to the CSS notes below.
.container {
display: flex;
flex-direction: row; /* keep items side-by-side (default behavior) */
align-items: center; /* vertically align items */
max-width: 100%;
}
form#new_sensor_button {
margin-left: auto; /* right-align form/button */
}
button {
width: 100px;
height: 40px;
background: lightblue;
}
<div class="container">
<h1>Sensors</h1>
<form id="new_sensor_button">
<button value="New Sensor" id="ajax" styleClass="ui-priority-primary"></button>
</form>
</div>
If targeting the form directly is not feasible, follow this alternative method:
.container {
position: relative;
max-width: 100%;
}
button#ajax {
position: absolute;
right: 0;
top: 50%;
width: 100px;
height: 40px;
transform: translateY(-50%);
background: lightblue;
}
<div class="container">
<h1>Sensors</h1>
<form id="new_sensor_button">
<button value="New Sensor" id="ajax" styleClass="ui-priority-primary"></button>
</form>
</div>