john
john

Reputation: 801

How to center the contents inside of a div

I am trying to center the contents of a tag. This is the div that I am trying to center:

<div class="Paging" style="margin: 0 auto;">
    <div class="PageOfPage" style="display:inline-table;padding: 10px;">

        Page<label id="CurrentPage">1</label> From @Model.CountPage
    </div>
    <div class="RecordsOfRecord" style="display:inline-table;padding: 10px;">
        Record
        <label id="FromRecord">
            @{
                 int i1 = (Model.CurrentPage-1)*Model.CountRecordInPage;
                 if (i1 == 0)
                 {
                     i1 = 1;
                 }

                 string recordFrom = i1.ToString(CultureInfo.InvariantCulture);
             }@recordFrom
        </label>
        To
        <label id="ToRecord">@Model.CountRecordInPage</label>
        From @Model.AllRecord
    </div>
</div>

There must be something that I am missing, but I am out of ideas.

Upvotes: 0

Views: 74

Answers (3)

Vladimir Susinskis
Vladimir Susinskis

Reputation: 1

add a width to the div!! or if you want the text to be centered add text-align:center;

Upvotes: 0

ColoO
ColoO

Reputation: 833

Give a width of your div if you want to use margin: auto

.Paging {
width :70%;
margin : auto;

}

Upvotes: 0

just use

<div class="Paging" style="margin: 0 auto; text-align:center;">

Live Demo

Upvotes: 3

Related Questions