Can't position HTML elements using bootstrap v4 - html

I have header tag inside the header I have one container for logo and one container for login form. I want my logo to be left and my login form to be position top right angle, but when I set float-left to the logo container and float-right to the login form they break. I've made sure the containers to be enough sized to fit in, but they still break.
Here is my code:
<header class="bg-inverse text-white col-sm-12" style="border: 1px solid blue">
<div id="logo" class="col-sm-8"style="border:1px solid red">
<h1 class="font-weight-bold">Somelogo</h1>
</div>
<div id="login-form" class="col-sm-3">
<form class="" style="border: 1px solid blue">
<div class="form-group mb-0">
<label for="username">Username</label>
<input type="text" class="form-control form-control-sm" id="username">
</div>
<div class="form-group mb-1">
<label class="pt-1 mb-0" for="Password" style="border: 1px solid blue">Password</label>
<input type="password" class="form-control form-control-sm" id="password">
</div>
<button type="submit" class="btn btn-primary col-sm-5 btn-sm">register</button>
<button type="submit" class="btn btn-primary col-sm-5 btn-sm">login</button>
</form>
</div>
</header>
This is how to looks like without setting a position Picture 1
This is how it looks when I set float:left to the div with id logo and float:right to the div with id login-formPicture 2
This is with only setting the div with id login-form to float-rightPicture 3
PS: I'm trying to use only bootstrap 4. And please explain what is the problem, why is this happening.

The problem is that you aren's using the Bootstrap grid correctly. This is a common beginner mistake.
Bootstrap rows and columns are designed to work together.
That means: You cannot nest a Bootstrap column directly into another Bootstrap column. If you do, you'll inevitably run into issues as is the case here.
Solution:
When nesting anything inside a Bootstrap column, first put a div (or another suitable HTML element) with the class .row into that column and then put a div with the class .col into that row div.
WRONG:
<div class="container">
<div class="row">
<div class="col">
<div class="col"></div>
</div>
</div>
</div>
RIGHT:
<div class="container">
<div class="row">
<div class="col">
<div class="row">
<div class="col"></div>
</div>
</div>
</div>
</div>
This option would also work fine:
<div class="container">
<div class="row">
<div class="col">
</div>
</div>
<div class="row">
<div class="col">
</div>
</div>
</div>
I suspect the following is the layout you wanted to create:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
<div class="container-fluid">
<div class="row">
<header class="bg-inverse col-sm-12" style="border: 1px solid blue">
<div class="row">
<div id="logo" class="col-sm-8" style="border:1px solid red">
<h1 class="font-weight-bold">Somelogo</h1>
</div>
<div id="login-form" class="col-sm-3 offset-sm-1">
<form class="" style="border: 1px solid blue">
<div class="form-group mb-0">
<label for="username">Username</label>
<input type="text" class="form-control form-control-sm" id="username">
</div>
<div class="form-group mb-1">
<label class="pt-1 mb-0" for="Password" style="border: 1px solid blue">Password</label>
<input type="password" class="form-control form-control-sm" id="password">
</div>
<button type="submit" class="btn btn-primary col-sm-5 btn-sm mb-2 mb-sm-0">register</button>
<button type="submit" class="btn btn-primary col-sm-5 btn-sm">login</button>
</form>
</div>
</div>
</header>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>
Note:
I had added the .container-fluid class and removed the .text-white class in the code snippet above.
P.S. I'm adding another version here that I think is better than the previous but it really depends on what you actually want. Here it is:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
<header class="bg-inverse" style="border: 1px solid blue">
<div class="container">
<div class="row" style="border: 1px solid blue">
<div id="logo" class="col-sm-8" style="border:1px solid red">
<h1 class="font-weight-bold">Somelogo</h1>
</div>
<div id="login-form" class="col-sm-4 col-lg-3 offset-lg-1">
<form class="" style="border: 1px solid blue">
<div class="form-group mb-0">
<label for="username">Username</label>
<input type="text" class="form-control form-control-sm" id="username">
</div>
<div class="form-group mb-1">
<label class="pt-1 mb-0" for="Password" style="border: 1px solid blue">Password</label>
<input type="password" class="form-control form-control-sm" id="password">
</div>
<button type="submit" class="btn btn-primary col-sm-5 btn-sm mb-2 mb-sm-0">register</button>
<button type="submit" class="btn btn-primary col-sm-5 btn-sm">login</button>
</form>
</div>
</div>
</div>
</header>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>

You can try the following solution, using the flex utilities of Bootstrap 4:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" rel="stylesheet"/>
<header class="bg-dark text-white col-sm-12 d-flex justify-content-between align-items-center" style="border: 1px solid blue">
<div id="logo" class="col-sm-8" style="border:1px solid red">
<h1 class="font-weight-bold">Somelogo</h1>
</div>
<div id="login-form" class="col-sm-3">
<form style="border: 1px solid blue">
<div class="form-group mb-0">
<label for="username">Username</label>
<input type="text" class="form-control form-control-sm" id="username">
</div>
<div class="form-group mb-1">
<label class="pt-1 mb-0" for="Password">Password</label>
<input type="password" class="form-control form-control-sm" id="password">
</div>
<button type="submit" class="btn btn-primary col-sm-5 btn-sm">register</button>
<button type="submit" class="btn btn-primary col-sm-5 btn-sm">login</button>
</form>
</div>
</header>
Another solution using .container and .row:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" rel="stylesheet"/>
<header class="container bg-dark text-white col-sm-12" style="border: 1px solid blue">
<div class="row">
<div id="logo" class="col-sm-8 align-self-center mr-auto" style="border:1px solid red">
<h1 class="font-weight-bold">Somelogo</h1>
</div>
<div id="login-form" class="col-sm-3">
<form style="border: 1px solid blue">
<div class="form-group mb-0">
<label for="username">Username</label>
<input type="text" class="form-control form-control-sm" id="username">
</div>
<div class="form-group mb-1">
<label class="pt-1 mb-0" for="Password">Password</label>
<input type="password" class="form-control form-control-sm" id="password">
</div>
<button type="submit" class="btn btn-primary col-sm-5 btn-sm">register</button>
<button type="submit" class="btn btn-primary col-sm-5 btn-sm">login</button>
</form>
</div>
</div>
</header>

Related

Cannot set input and submit form in the middle of container

I want to align a form in the middle of a container. Then set input bar to be as wide as half of that container. Here is my code.
<div id="sub" class="col-6 d-flex justify-content-center">
<div class="d-flex">
<form id="form" action="https://www.freecodecamp.com/email-submit.">
<div class="form-group">
<input id="email" class="form-control text-center" type="email" placeholder="Enter your email">
</div>
<div class="d-flex justify-content-center pt-3">
<input id="submit" class="btn btn-primary" type="submit">
</div>
</form>
</div>
</div>
Can you try to put your code into row?
<div class="container">
<div class="row d-flex justify-content-center">
<div id="sub" class="col-6">
<div class="d-flex">
<form id="form" action="https://www.freecodecamp.com/email submit.">
<div class="form-group">
<input id="email" class="form-control text-center"
type="email" placeholder="Enter your email">
</div>
<div class="d-flex justify-content-center pt-3">
<input id="submit" class="btn btn-primary" type="submit">
</div>
</form>
</div>
</div>
<div>
</div>
This should help.
#sub{
width:100%;
border:1px solid #ccc;
height:400px;
align-items:center;
}
.form-wrapper{
width:50%;
}
input{
width:100%;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<div id="sub" class="d-flex justify-content-center align-items-center">
<div class="form-wrapper">
<form id="form" action="https://www.freecodecamp.com/email-submit.">
<div class="form-group">
<input id="email" class="form-control text-center" type="email" placeholder="Enter your email">
</div>
<div class="d-flex justify-content-center pt-3">
<input id="submit" class="btn btn-primary" type="submit">
</div>
</form>
</div>
</div>

How to delete the space between these two elements with bootstrap grid

Here is the code of a login form on which I'm working on:
<main>
<div class="container-fluid">
<div class="row d-flex justify-content-center align-items-center">
<div class="col-6">
<h3 class="display-3">Sign In<h3>
<form class="justify-content-md-center">
<div class="col-md-auto">
<input type="text" required placeholder=" Username"
style="font-family:Arial, FontAwesome">
</div>
<div class="col-md-auto">
<input class="margin-25px" type="password" requires
placeholder=" Password"
style="font-family:Arial, FontAwesome">
</div>
<div class="container-fluid row justify-content-md-center">
<div class="col-sm">
<img class="icon" src="images/check-box.svg"
alt="check-box">
</div>
<div class="col-auto">
<p>Forgot your password?</p>
</div>
</div>
<button class="login__button btn btn-primary" type="submit">
LOGIN
</button>
</form>
</div>
</div>
</div>
</main>
I tried to do the layout with bootstrap grid, but can't find how to nest these two object, which are image with the class icon and the paragraph.
how it looks in chrome
You may use the following lines:
#login .container #login-row #login-column #login-box {
margin-top: 120px;
max-width: 600px;
height: 320px;
border: 1px solid #9C9C9C;
background-color: #EAEAEA;
}
#login .container #login-row #login-column #login-box #login-form {
padding: 20px;
}
#login .container #login-row #login-column #login-box #login-form #register-link {
margin-top: -85px;
}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<body>
<div id="login">
<h3 class="text-center text-white pt-5">Login form</h3>
<div class="container">
<div id="login-row" class="row justify-content-center align-items-center">
<div id="login-column" class="col-md-6">
<div id="login-box" class="col-md-12">
<form id="login-form" class="form" action="" method="post">
<h3 class="text-center text-info">Login</h3>
<div class="form-group">
<label for="username" class="text-info">Username:</label><br>
<input type="text" name="username" id="username" class="form-control">
</div>
<div class="form-group">
<label for="password" class="text-info">Password:</label><br>
<input type="text" name="password" id="password" class="form-control">
</div>
<div class="form-group">
<label for="remember-me" class="text-info"><span>Remember me</span> <span><input id="remember-me" name="remember-me" type="checkbox"></span></label><br>
<input type="submit" name="submit" class="btn btn-info btn-md" value="Login">
</div>
<div id="register-link" class="text-right">
Forgot your password ?
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
I already found it in the codepen and I can't remember the author's name to mention here.

Html: Bootstrap form alignment in center

I'm currently working on a simple login system and I have some Front-End difficulties. I'm trying to make a center-based login form with some inputs and a button. So basically right now I was able to make few inputs inside the center, but when I tried adding a button, then I got result like this:
Note: I need the button to be in the center of the form. Also, am I doing the form in the center correctly?
My HTML code:
<div class="container">
<h1 class="page-header text-center apie_m_cga">~ Support Desk ~</h1>
<hr>
<div class="row justify-content-center">
<div class="form-group col-md-3 col-md-offset-7 align-center ">
<br>
<input type="text" id="inputUsername6" placeholder="Username" class="form-control mx-sm-3 text-center">
<br>
<input type="password" id="inputPassword6" placeholder="Password" class="form-control mx-sm-3 text-center">
<br>
<button type="button" class="btn btn-primary btn-lg">Login</button>
</div>
</div>
<br>
</div>
add text-center class to the div that contain form-group class:
<div class="container">
<h1 class="page-header text-center apie_m_cga">~ Support Desk ~</h1>
<hr>
<div class="row justify-content-center ">
<div class="form-group col-md-3 col-md-offset-7 align-center text-center">
<br>
<input type="text" id="inputUsername6" placeholder="Username" class="form-control mx-sm-3 text-center">
<br>
<input type="password" id="inputPassword6" placeholder="Password" class="form-control mx-sm-3 text-center">
<br>
<button type="button" class="btn btn-primary btn-lg">Login</button>
</div>
</div>
<br>
</div>
Just add a text-align: center; to your form-group
.form-group {
text-align: -webkit-center;
text-align: center;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container">
<h1 class="page-header text-center apie_m_cga">~ Support Desk ~</h1>
<hr>
<div class="row justify-content-center">
<div class="form-group col-md-3 col-md-offset-7">
<br>
<input type="text" id="inputUsername6" placeholder="Username" class="form-control mx-sm-3 text-center">
<br>
<input type="password" id="inputPassword6" placeholder="Password" class="form-control mx-sm-3 text-center">
<br>
<button type="button" class="btn btn-primary btn-lg">Login</button>
</div>
</div>
<br>
</div>
You just need to add .text-center add on parent DIV
<div class="container">
<h1 class="page-header text-center apie_m_cga">~ Support Desk ~</h1>
<hr>
<div class="row justify-content-center">
<div class="form-group col-md-3 col-md-offset-7 align-center text-center">
<br>
<input type="text" id="inputUsername6" placeholder="Username" class="form-control mx-sm-3 text-center">
<br>
<input type="password" id="inputPassword6" placeholder="Password" class="form-control mx-sm-3 text-center">
<br>
<button type="button" class=" btn-primary btn-lg">Login</button>
</div>
</div>
<br>
</div>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
I'll suggest you make the button the same length with the input fields, it'll make the form look better.
Try this:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<div class="container">
<h1 class="page-header text-center apie_m_cga">~ Support Desk ~</h1>
<hr>
<div class="row justify-content-center">
<div class="form-group col-md-3 col-md-offset-7 align-center ">
<br>
<input type="text" id="inputUsername6" placeholder="Username" class="form-control text-center">
<br>
<input type="password" id="inputPassword6" placeholder="Password" class="form-control col-12 text-center">
<br>
<button type="button" class="btn col-12 btn-primary">Login</button>
</div>
</div>
<br>
</div>
I think the class of your button "btn-lg" is influenced in position. Basically there is no any special errors on your script except for it.
Please remove it in class and try again

Vertical center align for a button in panel header with Bootstrap

I'm working on a Bootstrap 4 HTML page. I put a button in a panel header:
I need to put the button (and the title) in the middle of the panel header. How can I achieve this goal?
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="container p-4 ">
<div class="card">
<div class="card-header">
<p class="float-left display-4">Administrator</p>
<a href="#" class="btn btn-primary float-right" style="align-items: center" routerLink="../list" role="button">
<i class="fa fa-arrow-left"></i> Indietro</a>
</div>
<div class="card-body">
<form>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email">
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd">
</div>
<div class="form-group">
<label for="displayName">Display name:</label>
<input type="displayName" class="form-control" id="displayName">
</div>
<button type="submit" class="btn btn-primary float-right">Salva</button>
</form>
</div>
</div>
</div>
Thanks
Try using display: flex; for your card header which is available in bootstrap and also instead of using float-right you can use ml-auto to move the button to the right (With the use of flex there is no need to use float properties). Hope this code helps
<!--
Bootstrap docs: https://getbootstrap.com/docs
-->
<div class="container p-4 ">
<div class="card">
<div class="card-header d-flex flex-row align-items-center">
<p class="float-left display-4">Administrator</p>
<a href="#" class="btn btn-primary ml-auto" style="align-items: center" routerLink="../list" role="button">
<i class="fa fa-arrow-left"></i> Indietro</a></div>
<div class="card-body">
<form>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email">
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd">
</div>
<div class="form-group">
<label for="displayName">Display name:</label>
<input type="displayName" class="form-control" id="displayName">
</div>
<button type="submit" class="btn btn-primary float-right">Salva</button>
</form>
</div>
</div>
</div>
Just add display flex to your card-header class, then align-items: center
.card-header {
padding: .75rem 1.25rem;
margin-bottom: 0;
background-color: rgba(0,0,0,.03);
border-bottom: 1px solid rgba(0,0,0,.125);
display: flex;
justify-content: space-between;
align-items: center;
}

Putting text next to boostrap input not working

So I have a form and I'm using the Bootstrap framework and on every input type of this form I want to have text on the left showing what the input is for but what happens the text gets above the input like this:
Picture of how forms looks like right now:
<div class="container">
<br>
<center> <h3> Jongere toevoegen </h3> </center>
<br>
<?php echo form_open('index.php/Addjongere/Add_jongere'); ?>
<form>
<div class="form-group row">
<label>Roepnaam:</label>
<input class="form-control" name="roepnaam" id="roepnaam" placeholder="Roepnaam" type="text">
</div>
<div class="form-group row">
<label>Tussenvoegsel:</label>
<input class="form-control" name="tussenvoegsel" id="tussenvoegsel" placeholder="Tussenvoegsel" type="text">
</div>
<div class="form-group row">
<label>Achternaam:</label>
<input class="form-control" name="achternaam" id="achternaam" placeholder="Achternaam" type="text">
</div>
<div>
<button class="btn btn-primary" name="Add_jongere" >Toevoegen</button>
</div>
</form>
</div>
Does anyone know what I can do?
Any kind of help is appreciated
Is this what you are trying to get? Remove the class="form-inline" from your form and to your form-group divs add class row.
I also added a container around the form to keep it in a good size.
edit
I forgot to add class="col-sm-4" to the labels and class="form-control col-sm-8" to the inputs. So they were not next to eachother.
label{
text-align: center;
}
h3, .container button{
display: block;
margin: 0 auto;
text-align: center;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<div class="container">
<h3> Jongere toevoegen </h3>
<br>
<form>
<div class="form-group row">
<label class="col-sm-4">Roepnaam:</label>
<input class="form-control col-sm-8" name="roepnaam" id="roepnaam" placeholder="Roepnaam" type="text">
</div>
<div class="form-group row">
<label class="col-sm-4">Tussenvoegsel:</label>
<input class="form-control col-sm-8" name="tussenvoegsel" id="tussenvoegsel" placeholder="Tussenvoegsel" type="text">
</div>
<div class="form-group row">
<label class="col-sm-4">Achternaam:</label>
<input class="form-control col-sm-8" name="achternaam" id="achternaam" placeholder="Achternaam" type="text">
</div>
<div>
<button class="btn btn-primary" name="Add_jongere">Toevoegen</button>
</div>
</form>
</div>
You can put the entire form inside a responsive col, and adjust the label/input widths accordingly...
https://www.codeply.com/go/vdQSHJUalP
<div class="container">
<div class="row">
<form class="col-12 col-md-8 mx-auto">
<div class="form-group row">
<label class="col-5 col-sm-3 text-truncate">Roepnaam:</label>
<input class="form-control col" name="roepnaam" id="roepnaam" placeholder="Roepnaam" type="text">
</div>
<div class="form-group row">
<label class="col-5 col-sm-3 text-truncate">Tussenvoegsel:</label>
<input class="form-control col" name="tussenvoegsel" id="tussenvoegsel" placeholder="Tussenvoegsel" type="text">
</div>
<div class="form-group row">
<label class="col-5 col-sm-3 text-truncate">Achternaam:</label>
<input class="form-control col" name="achternaam" id="achternaam" placeholder="Achternaam" type="text">
</div>
<div class="form-group row">
<div class="col-12 text-center">
<button class="btn btn-primary" name="Add_jongere">Toevoegen</button>
</div>
</div>
</form>
</div>
</div>
try this:
.formcontrol {width: 50%; float:right;}