I'm trying to center a div, which is the Microsoft pubCenter AdControl for Windows 8 apps in HTML5/JavaScript.
<div id="myAd" style="; top: 0%; width: 292px; height: 60px; z-index: 1"
data-win-control="MicrosoftNSJS.Advertising.AdControl"
data-win-options="{applicationId: 'exampleAdId', adUnitId: 'exampleAdUnit'}">
</div>
How would I center a div horizontally so it is always in the middle of a page?
Add margin:auto
in your style=""
tag and that should do the trick.
Other possibility, align=center
you can use css only
left:50%;margin-left:-146px;
the point is to set margin left as half of the div width
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With