Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
CSS
.try
{
    display : inline;
    display : block;
    margin-left : auto;
    margin-right : 0px;
    text-align : right;
}
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div style="height: 254px; width: 1059px; removed: relative">
    
        <asp:Panel ID="Panel3" runat="server" Height="131px" 
            style="position: relative; top: 22px; left: 29px" Width="401px">
            <br />
            <asp:Label ID="Label2" runat="server" Text="Left"></asp:Label>
             
            <asp:Label ID="Label3" runat="server" Text="Left"></asp:Label>
            <br />
            <asp:Label ID="Label1" runat="server" Text="Left"></asp:Label>
             
            <asp:Label ID="Label4" runat="server" Text="Left"></asp:Label>
            <br />
            <br />
            <br />
            <br />
            
        </asp:Panel>
    
        <asp:Panel ID="Panel4" runat="server" CssClass = "try";
            style="position: relative; top: -107px; left: 738px; height: 126px; width: 310px">
            <br />
            <asp:Label ID="Label5" runat="server" Text="Right"></asp:Label>
             
            <asp:Label ID="Label6" runat="server" Text="Right"></asp:Label>
            <br />
            <br />
            <asp:Label ID="Label7" runat="server" Text="Right"></asp:Label>
             
            <asp:Label ID="Label8" runat="server" Text="Right"></asp:Label>
            <br />
            <br />
            <asp:Label ID="Label9" runat="server" Text="Right"></asp:Label>
        </asp:Panel>
    
    </div>
    </form>
</body>
</html>


I want to set right labels to the right side of the panel and left labels to the left side of the panel. Please help
Posted
Updated 18-Mar-15 23:54pm
v2
Comments
Tushar sangani 19-Mar-15 8:18am    
you use table or applying css to the table or Label

1 solution

An ASP.NET label will render as a series of spans...

CSS
.try { 
    position: relative;
    top: -107px; 
    left: 738px; 
    height: 126px; 
    width: 310px"
}
.try span {
    position: absolute;
    right: 0px;
    background-color: #b0e0e6;
}


ASP.NET
 <asp:panel id="Panel4" runat="server" cssclass="try">
    <br />
    <asp:label id="Label5" runat="server" text="Right"></asp:label>
    <asp:label id="Label6" runat="server" text="Right"></asp:label>
    <br />
    <br />
    <asp:label id="Label7" runat="server" text="Right"></asp:label>
    <asp:label id="Label8" runat="server" text="Right"></asp:label>
    <br />
    <br />
    <asp:label id="Label9" runat="server" text="Right"></asp:label>
</asp:panel>


A position absolute inside a position relative will treat the panel as a container...
setting the right property to 0 will right align the spans/labels, not setting a top will allow them to flow and obey your
tags.

You will need to adjust your absolute positions for the .try class to suit your requirements.
 
Share this answer
 
v2
Comments
partha143 22-Mar-15 23:11pm    
Thank you very much sir. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900