Reputation: 3945
I have two headings, 'CompanyName' which appears top left, and 'Date' displays top middle.
I am having difficulty getting them horizontally aligned. I've tried putting them inside a div, but to no effect... How can I fix this problem?
<div>
<h1>CompanyName</h1>
<h1 style="text-align:center">Date @Html.DisplayFor(model => model.TodaysDate)</h1>
</div>
Upvotes: 0
Views: 4331
Reputation: 81
Try:
<div style="display:table">
<h2 style="display:table-cell">test1</h2>
<h2 style="display:table-cell">test2</h2>
</div>
Upvotes: 1
Reputation: 26979
div {
text-align:center;
background:green;
}
div h1 {
display: inline-block;
background: red;
margin: 0 auto
}
h1:first-child {
display:inline-block; float:left
}
Upvotes: 1
Reputation: 4648
Try
<div style="clear: both">
<h2 style="float: left;width: 40%;">CompanyName</h2>
<h2 style="/* float: right; *//* text-align: center; */">Date @Html.DisplayFor(model => model.TodaysDate)</h2>
</div>
Upvotes: 1
Reputation: 379
Try adding a lineheight to your div and a vertical align.
vertical-align: middle;
line-height: 40px
Upvotes: 0