我用 Angular 指令创建了一个文件输入,但由于某种原因似乎很难将它居中:
这是我的 HTML,感谢您的任何见解。
<form class=".form-control">
<center style="border: blue">
<input class=".form-control" type="file" file-input="files" multiple>
</center>
<br>
<br>
<button class=".form-group" ng-click="upload('/upload')">Upload</button>
<button class=".form-group" ng-click="upload('/upload/save')">
Save New Profile Picture
</button>
<li ng-repeat="file in files">{{file.name}}
<img ng-src="{{imageData}}" style="max-height: 200px; max-width: 200px">
</li>
</form>
最佳答案
对于初学者,您现在不应该使用 center
,它已经过时了。现在,您可以这样做:
<input class="form-control center" type="file" file-input="files" multiple>
CSS
.center {
margin: 0 auto !important; /* I have added the !important attribute just for debugging, you can remove it. */
}
另一个有效的技巧是使用 flexbox:
<form class="form-control flex">
CSS:
.flex {
display: flex;
justify-content: center;
align-items: center; /* Optional */
}
阅读更多关于 flexbox 的信息 here .
关于html - 居中文件输入表单 - html/bootstrap/angular,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33604946/