Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.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 跨多个列设置输入和文本区域的样式(不带div)_Html_Css_Forms - Fatal编程技术网

Html 跨多个列设置输入和文本区域的样式(不带div)

Html 跨多个列设置输入和文本区域的样式(不带div),html,css,forms,Html,Css,Forms,如何设置以下标记的样式以允许如所述的布局 <form> <input name="one"> <input name="two"> <input name="three"> <input name="four"> <input name="five"> <input name="six"> <textarea></textarea>

如何设置以下标记的样式以允许如所述的布局

<form>
    <input name="one">
    <input name="two">
    <input name="three">
    <input name="four">
    <input name="five">
    <input name="six">
    <textarea></textarea>
</form>
这个怎么样

form{
    position: relative;
}
input{
    display: inline-block;
    width: 35%;
}
textarea{
    position: absolute;
    right: 0;
    top: 0;
}

/*or*/
form{
    -webkit-column-count: 4; /* Chrome, Safari, Opera */
    -moz-column-count: 4; /* Firefox */
    column-count: 4;
}

如果您可以使用
引导
,它会更容易


我会使用
div
,但你可以这样做


如果不想使用div,只需使用table即可

td{
显示:块;
}


试试这个,使用table

textarea
{
高度:100px
}

如果您使用
textarea作为第一个元素
,那么您就实现了

表单{
宽度:100%;
显示:表格;
}
输入{
宽度:30%;
显示:内联块;
}
文本区{
宽度:33.33%;
浮动:对;
显示:内联块;
}


为什么没有div?您可以使用表格,但不推荐使用表格,因为您在CSS3中有
display:table cell
和类似的功能。您可以使用textarea的绝对定位来实现这一点-这是您想要使用的吗?使用JavaScript添加包装元素怎么样?div是一种退路,但我更愿意保持标记尽可能干净(如果可以的话),绝对位置也不理想。如果需要使用绝对值,将使用divs。@RyanHipkiss页面的用途是什么?是网站还是内部使用?表单是否已生成?您可以使用JS更改html,还是只使用CSS?@NimrodShory only CSS请问,有没有不使用绝对值的方法?如果您愿意将textarea放在第二个输入之后,我已经尝试了列计数方法,但这会将前两列中的两个输入放在一起,然后将textarea和最后两个输入放在第三列中。
form{
    position: relative;
}
input{
    display: inline-block;
    width: 35%;
}
textarea{
    position: absolute;
    right: 0;
    top: 0;
}

/*or*/
form{
    -webkit-column-count: 4; /* Chrome, Safari, Opera */
    -moz-column-count: 4; /* Firefox */
    column-count: 4;
}
    <!--Below is the inline css code with html... You can also separate it if nedded-->    
    <form style="float:left;width:100%">
        <div style="float:left;width:30%;height:auto">
            <input name="one" style="width:100%">
            <input name="two" style="width:100%">
            <input name="three" style="width:100%">
        </div>
        <div style="float:left;width:30%;height:auto">
            <input name="four" style="width:100%">
            <input name="five" style="width:100%">
            <input name="six" style="width:100%">
        </div>
        <div style="float:left;width:30%;height:auto">
            <textarea style="width:100%"></textarea>
        </div>
    </form>