Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 通过css进行水平对齐_Html_Css - Fatal编程技术网

Html 通过css进行水平对齐

Html 通过css进行水平对齐,html,css,Html,Css,我试图通过CSS水平对齐一些内容 <asp:Label ID="idWelcome" runat="server" style="position:absolute; margin-left:40%"></asp:Label> <asp:Label ID="idName" runat="server" style="position:absolute; margin-left:80%">Name</asp:Label> 名称

我试图通过CSS水平对齐一些内容

<asp:Label ID="idWelcome" runat="server" style="position:absolute; margin-left:40%"></asp:Label>        
<asp:Label ID="idName" runat="server" style="position:absolute; margin-left:80%">Name</asp:Label>

名称

有人能告诉我应该添加什么样式,这样无论屏幕的分辨率如何,标签Welcome都会显示在右角吗

使用绝对位置:

position:absolute;
right: 0; 
top: 0;

<asp:Label ID="idWelcome" runat="server" style="position:absolute; right:0"></asp:Label>
位置:绝对位置;
右:0;
排名:0;

指定元素的
属性,该属性为
位置:绝对

<asp:Label ID="idWelcome" runat="server" style="position:absolute; right:0"></asp:Label>

尝试以下代码:-

<div style="position: absolute; right: 0;">
    <asp:Label ID="idWelcome" runat="server"></asp:Label>        
    <asp:Label ID="idName" runat="server">Name</asp:Label>
</div>

名称

如果您想在任何时候都将“欢迎…”文本放置在右上角,您必须使用CSS位置:fixed;属性,但首先用DIV将其包装,以便还包括名称,然后将DIV放置在右上角:

<div id="wrap-div">
  <asp:Label ID="idWelcome" runat="server"></asp:Label>        
  <asp:Label ID="idName" runat="server">Name</asp:Label>
</div>

#wrap-div{
  postion: fixed;
  top: 0;
  right: 0;
}

你怎么能拒绝投票呢?两者都有。请检查此链接:
#warp-div{
  position: absolute;
  top: 0;
  right: 0;
}