如何在HTML页面中添加选项卡

时间:2014-01-02 21:23:25

标签: html css

我的网页顶部有菜单栏。

我知道将标签放在HTML中,可以这样做:

<p style="text-indent: 5em;">
The first line of this paragraph will be indented about five characters, similar to a tabbed indent.
</p>

但我的问题是如何在菜单栏中做类似的事情?这是我的代码。

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<html>
<head>
<title></title>

<style>
    div.ex
    {
        width:300px;
        padding:10px;
        border:5px solid gray;
        background: white;
        margin-left:auto;
        margin-right:auto;
        margin-top: 200px;
        position: relative;
    }
    p.x {
        color: white;
        font:25px arial,sans-serif;
        position:relative;
        left:20px;
    }
    .align {
        position: absolute;
        left: 8em;
    }
    body
    {
        background-color: #ebebeb;
        top: 55px;
    }
    #rectangle {
        width: 100%;
        height: 70px;
        background: deepskyblue;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 20;
    }
    input[type=button]
    {
        background-color: lawngreen;
        color: white;
    }
    #text {
        padding-top: 80px;
    }
</Style>
</head>
<body>
<div id="rectangle">
<p class="x">Home Page <a href="personal?id=${id}"><input type="button" name="sign up" value="Sign Up"/></a>
 <a href="hello">Home</a> </p>
</div>
<h1 id="text">Hello world, this is your home page.</h1>
<div class="ex">
<h1>签订</h1>
<hr>
${errorMessage}
<form action="register" method="post">
    <p>
        <label>
            ID:
            <input type="text" name="id" value="${person.id}" class="align"/>
        </label>
    </p>
    <p>
        <label>
            密码:
            <input type="password" name="password" class="align"/>
        </label>
    </p>
    <p>
        <label>
            确认密码:
            <input type="password" name="password" class="align"/>
        </label>
    </p>
    <p>
        <label>
            姓名:
            <input type="text" name="name" value="${person.name}" class="align"/>
        </label>
    </p>
    <p>
        <label>
            地址:
            <input type="text" name="address" value="${person.address}" class="align"/>
        </label>
    </p>
    <p>
        <label>
            电话:
            <input type="text" name="phoneNumber" value="${person.phoneNumber}" class="align"/>
        </label>
    </p>
    <input type="submit" value="注册"/>
</form>
</div>
</body>
</html>

换句话说,我想在“注册”按钮和“主页”超链接之间添加标签。两者都放在蓝色矩形中。

如果有人能帮助我,我感激不尽。

2 个答案:

答案 0 :(得分:1)

似乎通过“tab”,你的意思是水平间距。在这种情况下,在某个元素上设置合适的水平边距,例如

<input type="button" name="sign up" value="Sign Up" style="margin-right: 5em"/>
<a href="hello">Home</a> 

(您的代码需要修复。例如,a元素不得包含input元素。但这不会影响间距问题。)

答案 1 :(得分:0)

您使用的是错误的HTML模式。

使用无序列表并将INPUT移到LABEL之外。

<ul>
  <li>
      <label for="name">Name</label>
      <input id="name" />
    </li>
  <li>
      <label for="address1">Address</label>
      <input id="address1" />
    </li>
  <li>
  ....
</ul>

CSS:

label, input {
  display: inline-block;
}

请参阅:http://alistapart.com/article/prettyaccessibleforms