div中居对齐文本,宽度为auto [英] Center alignment text in div while width is auto

查看:79
本文介绍了div中居对齐文本,宽度为auto的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我使用移动jquery在该页面中创建了一个母版页。页面包含标题,内容和页脚。在标题中我使用了四个图像按钮和内部标题我想在图像之间显示菜单名称。我在一个asp.net标签控件中尝试了div。我使用了文本对齐和垂直对齐以及行高属性,但文本不是浏览器和移动设备的中心。请任何人帮助我。感谢您提前回复。



Css

Hi friends,

I have created one master page in that page using mobile jquery . page contain header, content and footer.In header I have used four image button and inside header I want to display menu name in between the image. i tried div inside one asp.net label control.I used text align and vertical align and line height attribute also but the text is not center in browser and mobile device aslo. please can any one help me. thanks for advance reply.

Css

.HeaderLine1
{
    color: #00264D;
    font-size:medium;
    font-family: Arial Narrow;
    font-weight: bold;
    padding-left: 0px;
}





html code < br $>




html code

<form id="form1"  runat="server">
<div data-role="page">
    <div data-role="header" class="page">
        <div id="Div1" style="float: left; width: auto; border: 1px solid #300;">
            <div id="Div2"  runat="server" style="width: auto; height: auto; float: left; text-align: center;
                position: relative; margin: 0 auto;">
                <asp:label id="LblApplication" runat="server" cssclass="HeaderLine1" text="Jail Management System" style="vertical-align: middle;
                    line-height: 25px;">
            </div>
        </div>
    </div>

<div data-role="content">
    <asp:contentplaceholder id="MainContent" runat="server" />
</div>

</form>

推荐答案

你可以删除
float: left;

样式属性,因此它将被放置在中心。



此外,将垂直对齐设置为直接容器的中心包含标签的Div。

style attribute so it will be placed in the center.

Also , Set the Vertical align to center in the immediate container Div which contains the label.


这篇关于div中居对齐文本,宽度为auto的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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