bootstrap 4等效于form-control-feedback

时间:2018-11-13 22:40:03

标签: css twitter-bootstrap bootstrap-4

form-control-feedback似乎不是引导程序4的一部分。使用引导程序4来获得以下结果(文本框中的图标)的最佳方法是什么?

<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
    <div class="container">
        <form class="form-horizontal">
            <div class="form-group has-warning has-feedback">
                <div class="col-sm-10">
                    <input type="text" class="form-control">
                    <span class="form-control-feedback"><i class="fa fa-rotate-right"></i></span>
                </div>
            </div>
        </form>
    </div>
</body>

1 个答案:

答案 0 :(得分:1)

您可以只使用css类并应用它(请注意v4 cdn),但要减去固定的大小调整约定,例如;

.form-control-feedback {
    position: absolute;
    top: .5rem;
    right: 1.5rem;
    z-index: 2;
    display: block;   
    text-align: center;
    pointer-events: none;
}
<head>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
    <div class="container">
        <form class="form-horizontal">
            <div class="form-group has-warning has-feedback">
                <div class="col-sm-10">
                    <input type="text" class="form-control">
                    <span class="form-control-feedback"><i class="fa fa-rotate-right"></i></span>
                </div>
            </div>
        </form>
    </div>
</body>

但是,请注意,如果进入并使用用于输入大小设置的sass设置等,则需要相应地调整topright的值以及可能添加的字体大小。 / p>