Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/34.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 - Fatal编程技术网

Html 将居中Div容器中的元素左对齐

Html 将居中Div容器中的元素左对齐,html,css,Html,Css,我希望在一个居中的div容器中将元素向左对齐。我发现的问题是,我使用了text align将整个div居中,但当我尝试创建另一个内容容器和text alignleft时,它并没有将我的内容在居中div中左对齐 HTML: 可以使用此选项将div居中: #bar-fields { width: 50%; margin: 0 auto; } 然后在需要时使用文本对齐:left 阅读更多信息:我添加了一个新的Div,带有Css属性text align:left。它通过检查链接工作 #

我希望在一个居中的div容器中将元素向左对齐。我发现的问题是,我使用了
text align
将整个div居中,但当我尝试创建另一个内容容器和
text align
left时,它并没有将我的内容在居中div中左对齐

HTML:


可以使用此选项将div居中:

#bar-fields {
    width: 50%;
    margin: 0 auto;
}
然后在需要时使用
文本对齐:left


阅读更多信息:

我添加了一个新的
Div
,带有Css属性
text align:left
。它通过检查链接工作
#bar-fields {
    text-align: center;
}


#bar-description-field textarea {
    height: 100px;
    width: 250px;
    vertical-align: middle;
}


#bar-fields input[type="button"] {
    margin-bottom: 20px;
}

#bar-fields input[type=text] {
    font-size: 27px;
    margin-bottom: 20px; 
}

#bar-fields select {
    margin-bottom: 20px;
}
#bar-fields {
    width: 50%;
    margin: 0 auto;
}