【问题标题】:centering a file input form - html/bootstrap/angular居中文件输入表单 - html/bootstrap/angular
【发布时间】:2016-02-09 20:27:12
【问题描述】:

我使用 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>

【问题讨论】:

  • 删除“。”对于类。应该是这样class="form-control"
  • 当我这样做时,它会占据整个页面并且看起来更糟!我试过了。

标签: html css angularjs


【解决方案1】:

对于初学者,你现在不应该使用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

【讨论】:

    猜你喜欢
    • 2021-09-06
    • 1970-01-01
    • 2021-07-05
    • 2016-10-18
    • 2020-11-05
    • 2016-01-07
    • 1970-01-01
    • 2019-02-19
    • 2023-04-01
    相关资源
    最近更新 更多