Reputation: 35
<!doctype html>
<html>
<head>
<title>OptimisedForum</title>
<link rel="stylesheet" href="../Bootstrap/setup/css/bootstrap.min.css"/>
<script src='../Bootstrap/setup/jquery-3.3.1.min.js'></script>
<script src='../Bootstrap/setup/js/bootstrap.js'></script>
</head>
<body>
<div class='container'>
<form class="form-horizontal">
<div clas="form-group">
<div class="col-sm-12" style="background: #999;">
<textarea class="form-control" placeholder="comment here" rows = 5></textarea>
</div>
<div class="col-sm-4" style="background: yellow">
<input type="text" class="form-control" id="inputPassword3" placeholder="username"/>
</div>
<div class="col-sm-8" style="background: red">
<button type="submit" class="btn btn-default">Submit</button>
</div>
</div>
</form>
<div class="col-sm-12" style="background: #123">
<nav aria-label="Page navigation">
<ul class="pagination">
<li class="page-item">
<a href="#" aria-label="Previous" class="page-link">
<span aria-hidden= "true">«</span>
</a>
</li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item">
<a class="page-link" href="#" aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</nav>
</div>
</div>
</body>
</html>
As the picture shows, it is supposed that the 'submit' button can be on the same row with the 'username' input by the grid system but appearently it can't be anyway. I have tried many ways to do it such as putting these two divs into one '.row' etc but never work. So, I may need your guys' help. Thx
Upvotes: 0
Views: 55
Reputation: 3512
col-sm-4
which means at the small breakpoint, it will apply. Of course, this screen is the big breakpoint. To make them on the same line, just remove the -sm
(make it col-4
). I fixed that in the snippet for you..container > .row > .col
You skippet the .row
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<!doctype html>
<html>
<head>
<title>OptimisedForum</title>
<link rel="stylesheet" href="../Bootstrap/setup/css/bootstrap.min.css" />
<script src='../Bootstrap/setup/jquery-3.3.1.min.js'></script>
<script src='../Bootstrap/setup/js/bootstrap.js'></script>
</head>
<body>
<div class='container'>
<form class="form-horizontal">
<div clas="form-group">
<div class="row">
<div class="col-12" style="background: #999;">
<textarea class="form-control" placeholder="comment here" rows=5></textarea>
</div>
</div>
<div class="row">
<div class="col-4" style="background: yellow;">
<input type="text" class="form-control" id="inputPassword3" placeholder="username" />
</div>
<div class="col-8" style="background: red;">
<button type="submit" class="btn btn-default">Submit</button>
</div>
</div>
</div>
</form>
<div class="col-12" style="background: #123">
<nav aria-label="Page navigation">
<ul class="pagination">
<li class="page-item">
<a href="#" aria-label="Previous" class="page-link">
<span aria-hidden="true">«</span>
</a>
</li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item">
<a class="page-link" href="#" aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</nav>
</div>
</div>
</body>
</html>
Upvotes: 1