Html css是如何做到这一点的

Html css是如何做到这一点的,html,css,Html,Css,css是如何做到这一点的 text | input text text | input text | input input text text text | input 其中text是输入字段input UPD通常您可以在用户注册表单中看到这样的布局取决于HTML代码。你可以玩float:left,浮动;右和清除:例如,两者都。但如果没有至少一些HTML代码,就不可能给出完整的解决方案 这里有一

css是如何做到这一点的

                text | input
           text text | input
                text | input input
      text text text | input
其中
text
是输入字段
input


UPD通常您可以在用户注册表单中看到这样的布局

取决于HTML代码。你可以玩
float:left
浮动;右
清除:例如,两者都
。但如果没有至少一些HTML代码,就不可能给出完整的解决方案

这里有一个小例子:

HTML:

<div>
    <label for="input1">Input 1</label>
    <input name="input1" />
    <label for="input2">Some long Input 2</label>
    <input name="input2" />
    <label for="input3">Input 3</label>
    <input name="input3" />
    <label for="input4">short</label>
    <input name="input4" />
    <label for="input5">Input 5</label>
    <input name="input5" />
</div>

取决于HTML代码。你可以玩
float:left
浮动;右
清除:例如,两者都
。但如果没有至少一些HTML代码,就不可能给出完整的解决方案

这里有一个小例子:

HTML:

<div>
    <label for="input1">Input 1</label>
    <input name="input1" />
    <label for="input2">Some long Input 2</label>
    <input name="input2" />
    <label for="input3">Input 3</label>
    <input name="input3" />
    <label for="input4">short</label>
    <input name="input4" />
    <label for="input5">Input 5</label>
    <input name="input5" />
</div>
CSS:

HTML:

text
文本文本
文本
文本
CSS:

HTML:

text
文本文本
文本
文本
另一种方法

HTML:

耶尔斯:

您还可以将
ul
ol
li
一起使用另一种方法来执行此操作

input {
    border: 1px solid #ccc;
    background: #f5f5f5;
    padding-left:5px;
}
label {
    display: block;    
    width:auto;
    width: 100px;
    float: left;
    margin: 2px 6px 6px 4px;
    text-align: right;
    font-weight:bold;
    color:#555;
}
br{
    clear:both;
}
HTML:

耶尔斯:

您还可以将
ul
ol
li
一起使用

input {
    border: 1px solid #ccc;
    background: #f5f5f5;
    padding-left:5px;
}
label {
    display: block;    
    width:auto;
    width: 100px;
    float: left;
    margin: 2px 6px 6px 4px;
    text-align: right;
    font-weight:bold;
    color:#555;
}
br{
    clear:both;
}

检查工作示例

检查处的工作示例,参见


标签{
显示:内联;
浮动:左;
宽度:10em;
文本对齐:右对齐;
}
输入{
左侧边缘:15em;
显示:块;
}
文本
文本
文本
文本文本文本
请参见


标签{
显示:内联;
浮动:左;
宽度:10em;
文本对齐:右对齐;
}
输入{
左侧边缘:15em;
显示:块;
}
文本
文本
文本
文本文本文本
<div class='form'>
    <p><label>Test</label><input /></p>
    <p><label>Longer test</label><input /></p>
    <p><label>Even longer test</label><input /></p>
</div>
.form p {
    clear: both;
    float: none;
}
.form p label {
    display: block;
    float: left;
    text-align: right;
    width: 10em;
}
.form p input {
    float: left;
}
input {
    border: 1px solid #ccc;
    background: #f5f5f5;
    padding-left:5px;
}
label {
    display: block;    
    width:auto;
    width: 100px;
    float: left;
    margin: 2px 6px 6px 4px;
    text-align: right;
    font-weight:bold;
    color:#555;
}
br{
    clear:both;
}
<html>
    <head>
        <title></title>
        <style type="text/css">

            label {
                display: inline;
                float: left;
                width: 10em;
                text-align: right;
            }

            input {
                margin-left: 15em;
                display: block;
            }

        </style>
    </head>
    <body>

        <fieldset>

            <label>text</label>
            <input type="text" style="width:10em;" />

            <label>text</label>
            <input type="text" style="width:10em;" />

            <label>text text</label>
            <input type="text" style="width:20em;" />

            <label>text text text</label>
            <input type="text" style="width:10em;" />

        </fieldset>

    </body>
</html>