引导按钮未调整大小

saucypanda

我在静态中使用引导CDN以及另一个引导CSS示例文件。在尝试为表单创建文件输入和提交按钮时,我无法降低两个标签的宽度。它们跨越了我笔记本电脑的整个页面。我尝试了几种方法来解决此问题,但似乎没有任何效果。

码:

html,
body {
  height: 100%;
}

body {
  display: -ms-flexbox;
  display: -webkit-box;
  display: flex;
  -ms-flex-align: center;
  -ms-flex-pack: center;
  -webkit-box-align: center;
  align-items: center;
  -webkit-box-pack: center;
  justify-content: center;
  padding-top: 40px;
  padding-bottom: 40px;
  background-color: #f5f5f5;
}

.form-upload {
  width: 80%;
  max-width: 330px;
  padding: 15px;
  margin: 0 auto;
}
.form-upload .checkbox {
  font-weight: 400;
}
.form-upload .form-control {
  position: relative;
  box-sizing: border-box;
  height: auto;
  padding: 10px;
  font-size: 16px;
}
.form-upload .form-control:focus {
  z-index: 2;
}
.form-upload input[type="email"] {
  margin-bottom: -1px;
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}
.form-upload input[type="password"] {
  margin-bottom: 10px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.file-block .btn-block {
  width: 25%;
}
<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

        <title>Skin Lesion Classifier</title>

        <link href="../static/css/form-upload.css" rel="stylesheet">
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
        integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
        integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

        <style>
            body {
                background-image: url('https://www.wchcd.org/wp-content/uploads/2014/04/healthcare-background.jpg');
            }
        </style>
    </head>

    <body class="text-center">
        <div class="form-upload">
            <form enctype="multipart/form-data" action="predictImage" method="post" class="form-upload">
                {% csrf_token %}

                <img class="mb-4" src="https://cdn4.iconfinder.com/data/icons/artificial-intelligence-64/512/ai-healthcare-artificial-intelligence-512.png" width="80" height="80">
                <h1 class="h3 mb-3 font-weight-normal">Upload the Image to Classify</h1>

                <input type="file" name="filePath" id="image" class="form-control file-block" required autofocus>
                <button class="btn btn-lg btn-primary btn-block" type="submit">Predict</button>

                <br> <br>

                <img src={{filePathName}} alt='imagename' width="400" height="300">
                <h3 class="h3 mb-3 font-weight-normal">Type of Skin Lesion: {{predictedLabel}}</h3>
            </form>
        </div>
    </body>
</html>

advertmanagerpro.com

您遇到的问题是因为您在按钮html中使用了它

class="btn-block"

引导程序4按钮有三种默认大小

<button type="button" class="btn btn-primary btn-lg">Large button</button>
<button type="button" class="btn btn-primary btn-sm">Small button</button>
<button type="button" class="btn btn-primary btn-lg btn-block">Block level button</button>

您也可以尝试使用CSS样式自定义尺寸

style="width:80px;"

你可以这样使用

<button type="button" class="btn btn-primary" style="width:80px;">Custom button</button>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章