When utilizing the bootstrap CDN in conjunction with another bootstrap CSS example file located in the static directory, I encountered an issue while attempting to create a file input and submit button for a form. Despite my efforts, I was unable to adjust the width of these two elements, causing them to span across the entire page on my laptop screen. I experimented with various solutions but none seemed to resolve the problem.
Code:
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>