I am trying to create a 'section' div with a header, this header has a centred title and may or may not have a jquery UI button on its right hand side. The width of the 'section' div is determined by its parent.
My trouble is that the title with button centre alignment is taking the button's width into account.
Html:
<div style="width: 600px;">
<div class="section purple">
<div class="sectionHeader">
<div>Normal Title</div>
</div>
<div class="sectionContent"></div>
</div>
<div class="section blue">
<div class="sectionButtonIcon"> <a id="btnExample">Jquery UI Button</a>
</div>
<div class="sectionHeader">
<div>Title With Button</div>
</div>
<div class="sectionContent"></div>
</div>
</div>
See jsFiddle for css: http://jsfiddle.net/agAgeas50/uL9Uc/8/
Note: this is not a duplicate of Center inline-block div in parent while ignoring floating elements . If you look at jsfiddle's in the accepted answer, wrap the parent in another div and give the top level div a fixed width, the right hand element appears outside the parent.