0

i am trying to align the header to the left of the page.but it is aligned to the center of the page.how to align it to the center by using css? is there any css property to align the table header to the left of the page?

my code

<style type="text/css">

body {
   margin: 0;
   padding: 0;
}


#gobutton {
    padding:5px 25px; 
    color:#0000ff;
    font-size:1.1em;
}

</style>
<table align="center">
    <tr>
        <td>
            <h2>
                <img src="lock.jpg"  width="80" height="30"/>
                Login Form 
            </h2>
        </td>
    </tr>
    <tr>
        <td>
            <table>  
                <form name="new" action=""  onsubmit="">
                    <tr>
                        <td> <p>User name:<p> </td>
                        <td><input type="text"></td>
                    </tr>
                    <tr>
                        <td><p>Password:<p></td>
                        <td><input type="text"></td>
                   </tr>
                   <tr>
                       <td colspan="2" align="center">
                           <input id="gobutton" type="submit" value="Go!"/>
                       </td>
                   </tr>
               </form>
           </table>
       </td>
   </tr>
</table>
4

3 回答 3

1

我不知道你为什么还要使用表格,但这里是这个 HTML 的答案

设置 h2 向左对齐

<td>
    <h2 style="text-align:left;">
        <img src="lock.jpg"  width="80" height="30"/>Login Form
    </h2>
</td>
于 2013-10-01T07:22:56.043 回答
1

如果要将表头与页面左侧对齐,请尝试使用 css 属性

text-align:left;

像这样 :

<h2 stlye="text-align:left;"><img src="lock.jpg"  width="80" height="30"/>Login Form</h2>
于 2013-10-01T07:18:40.060 回答
0

尝试这个。

h2{
    text-align:left;
}

<h2 id="h2">
 <img src="lock.jpg"  width="80" height="30"/>Login Form 
 </h2>
于 2013-10-01T07:49:55.537 回答