如何将面板内的Label设置为右侧 [英] How can I set Label inside a panel to right

查看:58
本文介绍了如何将面板内的Label设置为右侧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 try  
{
display inline;
display block;
margin-left auto;
margin-正确 0px;
text-align right;
}

 <   html     xmlns   =  http:// www。 w3.or g / 1999 / xhtml >  
< head runat = 服务器 >
< title > < ; / title >
< / head >
< 正文 >
< 表格 id = form1 runat = server >
< div style = 身高:254px;宽度:1059px;已移除:相对 >

< asp:Panel ID = Panel3 runat = server 高度 = 131px

< span class =code-attribute> style = position:relative;上:22px; left:29px 宽度 = 401px >
< ; br / < span class =code-keyword>>
< asp:Label ID = Label2 runat = server Text = > < / asp:标签 >

< asp:标签 ID = Label3 runat = server 文本 = > < span class =code-keyword>< / asp:Label >
< br / >
< asp:标签 ID = Label1 runat = server 文本 = > < / asp:Label >

< asp:标签 ID = Label4 runat = 服务器 文本 = > < < span class =code-leadattribute> / asp:Label >
< br / >
< br / >
< br / >
< br / >

< / asp:Panel >

< asp:面板 ID = Panel4 runat = server CssClass = 尝试 ;

< span class =code-attribute> style = position:relative;上:-107px;左:738px;身高:126px;宽度:310px >
< br / >
< asp:Label ID = Label5 runat = server 文本 = > < / asp:标签 >

< asp:标签 ID = Label6 runat = 服务器 文字 = > < / asp:标签 >
< br / >
< ; br / < span class =code-keyword>>
< asp:Label ID = Label7 runat = server Text = > < / asp:标签 >

< as p:标签 ID = Label8 runat = 服务器 文本 = > < / asp:Label >
< br / >
< br / >
< asp:标签 ID = Label9 runat = server 文本 = > < / asp:Label >
< / asp:Panel >

< / div >
< / form >
< / body >
< < span class =code-leadattribute> / html >





我想在面板右侧设置正确的标签,并在面板左侧留下标签。请帮助

解决方案

ASP.NET标签将呈现为一系列跨度...



 try  {
position relative;
top -107px;
left 738px;
height 126px;
width 310px
}

尝试 span {
position 绝对值;
right 0px;
background-color #b0e0e6;
}





 <  < span class =code-leadattribute> asp:panel     id   =  Panel4    runat   =  server    cssclass   = 尝试 < span class = code-keyword>>  
< br / >
< asp:label id = Label5 runat = server text = > < / asp:label >
< asp:label id = Label6 runat = server text = > < / asp:label >
< br < span class =code-attribute> / >
< br / >
< < span class =code-leadattribute> asp:label id = Label7 runat = server text = 正确 < span class =code-keyword>> < / asp:label < span class =code-keyword>>
< asp:label id = Label8 runat = server 文字 = 正确 > < / asp:label >
< br / >
< br / >
< asp:label id = < span class =code-keyword> Label9 runat = server 文字 = 正确 > < / asp:label >
< / asp:panel >





位置相对位置绝对位置会将面板视为容器...

将右属性设置为0将右对齐跨距/标签,而不设置顶部将允许它们流动并遵守您的
标签。



您需要调整.try类的绝对位置以满足您的要求。


.try
{
    display : inline;
    display : block;
    margin-left : auto;
    margin-right : 0px;
    text-align : right;
}

<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

解决方案

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

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



 <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.


这篇关于如何将面板内的Label设置为右侧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆