tags:

views:

39

answers:

2

I have created an ASP.NET master page as follows:

<body class="MasterStyle">
  <form id="frmMaster" runat="server">
  <div>        
    <asp:Label runat="server" Text="My Site Name" Font-Bold="true" Font-Names="MS-Sans" 
            Style="text-align:right" Width="100%" />

The style is defined as follows:

<style type="text/css">
    .MasterStyle
    {
        width: 100%;
        background: aqua;
    }

The problem is that “My Site Name” is appearing just off the right hand site of the page (just missing the “e” off). Does anyone know why this might be happening?

A: 

Because of text-align:right. Remove from style.

kad1r
But if I do that then it won't allign to the right any more?
pm_2
Opps sorry. I understand your question wrongly.So just put float:left; in your .masterstyle. or try width:99%
kad1r
+1  A: 

The problem is the body margin. Because the margin is taking up space, and you are making the Label 100%, it is not accounting for the margin offset so your text is pushed over by that amount.

To fix it, just change `.MasterStyle to:

.MasterStyle 
{ 
    width: 100%; 
    background: aqua;
    margin: 0 0 0 0;
}

I have tested this and it fixes your issue but it does remove the margin offset which makes things not space from the edges nicely.

If you want to change more you can keep the margin by removing the Width property from your Label and the .MasterStyle and then adding a float: right style to the div.

.MasterStyle 
{ 
    background: aqua;
}

<body class="MasterStyle">
    <form id="frmMaster" runat="server">
        <div style="float: right">
            <asp:Label ID="Label1" runat="server" Text="My Site Name"
                Font-Bold="true" Font-Names="MS-Sans" Style="text-align:right" />

Either way will work, just depending on if you want the margins or not.

Kelsey
Thanks for that! In the end I just reduced the width to 95% which seemed to solve the problem, and let me still keep the width with the style.
pm_2