I have to create this look (from a mockup):
Based on what I read here [CSS: center element within a <div> element, I tried this:
.textaligncenter {
text-align:center;
}
.platypuscenter {
margin:auto;
}
<div class="row">
<div class="col-md-6">
<div class="containerforproact leftmarginbreathingroom platypuscenter">
<h4 class="leftmarginbreathingroom">PRODUCE USAGE (report spans up to 13 months)</h4>
<label class="leftmarginbreathingroom">From</label>
<select class="dropdown" id="produsagefrom" name="produsagefrom">
@for (int i = 1; i <= maxMonthsBackBegin; i++)
{
if (i == 13)
{
<option id="selItem_@(i)" value="@i" selected="selected">@i</option>
}
else
{
<option id="selItem_@(i)" value="@i">@i</option>
}
}
</select>
<label>months back</label>
<label>to</label>
<select id="produsageto" name="produsageto">
@for (int i = 1; i <= maxMonthsBackEndNormal; i++)
{
<option id="selItem_@(i)" value="@i">@i</option>
}
</select>
<label>months back</label>
<br />
<button class="btn btn-sm orange textaligncenter" id="btnTestProduceUsageSettings">TEST SETTINGS</button>
</div>
</div>
. . .
...but that produces this (everything centered):
Moving the "textaligncenter" class to just the button (the only element I want to center) like so:
<div class="row">
<div class="col-md-6">
<div class="containerforproact leftmarginbreathingroom">
<h4 class="leftmarginbreathingroom">PRODUCE USAGE (report spans up to 13 months)</h4>
<label class="leftmarginbreathingroom">From</label>
<select class="dropdown" id="produsagefrom" name="produsagefrom">
@for (int i = 1; i <= maxMonthsBackBegin; i++)
{
if (i == 13)
{
<option id="selItem_@(i)" value="@i" selected="selected">@i</option>
}
else
{
<option id="selItem_@(i)" value="@i">@i</option>
}
}
</select>
<label>months back</label>
<label>to</label>
<select id="produsageto" name="produsageto">
@for (int i = 1; i <= maxMonthsBackEndNormal; i++)
{
<option id="selItem_@(i)" value="@i">@i</option>
}
</select>
<label>months back</label>
<br />
<button class="btn btn-sm orange textaligncenter platypuscenter" id="btnTestProduceUsageSettings">TEST SETTINGS</button>
</div>
</div>
. . .
...produces this (nothing centered):
How can I get the button, the whole button, and only the button, to center within the container?