How i can add a button inside an input box using bootstrap - html

I am trying to find a way to enter a button inside input field as follow:-
can anyone advice ?

There is no native bootstrap solutions. You can do this with custom code.
.custom-search {
position: relative;
width: 300px;
}
.custom-search-input {
width: 100%;
border: 1px solid #ccc;
border-radius: 100px;
padding: 10px 100px 10px 20px;
line-height: 1;
box-sizing: border-box;
outline: none;
}
.custom-search-botton {
position: absolute;
right: 3px;
top: 3px;
bottom: 3px;
border: 0;
background: #d1095e;
color: #fff;
outline: none;
margin: 0;
padding: 0 10px;
border-radius: 100px;
z-index: 2;
}
<div class="custom-search">
<input type="text" class="custom-search-input" placeholder="Enter your email">
<button class="custom-search-botton" type="submit">Subscribe</button>
</div>
Bootstrap mixed solution, according to bootstrap styles.
.custom-search {
position: relative;
}
.custom-search-input {
width: 100%;
padding-right: 100px !important;
box-sizing: border-box;
}
.custom-search-botton {
position: absolute;
right: 3px;
top: 3px;
bottom: 3px;
line-height: 1 !important;
z-index: 4;
}
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<div class="input-group custom-search">
<input type="text" class="form-control custom-search-input" placeholder="Enter your email">
<button class="btn btn-primary custom-search-botton" type="submit">Subscribe</button>
</div>

You cant put a button inside a input field with bootstrap only but you can use custom css to move the button inside the input field. I created a small example for you (I used bootstrap 4):
input[type="text"] {
width: 200px;
height: 50px;
padding-right: 50px;
}
.example {
margin: 5px -90px 5px;
height: 40px;
width: 80px;
z-index: 100;
}
.test-div {
width: 200px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="test-div">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search for...">
<button class="btn btn-outline-secondary example" type="button">Button</button>
</div>
</div>

I changed your source and use font awesome. I think it became more nice, isn't it?
.custom-search {
position: relative;
}
.custom-search-input {
width: 100%;
padding-right: 100px !important;
box-sizing: border-box;
}
.custom-search-botton {
position: absolute;
right: 35px;
top: 1px;
bottom: 3px;
line-height: 1 !important;
z-index: 4;
border: none;
border-radius: 50px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.12/css/all.css" integrity="sha384-G0fIWCsCzJIMAVNQPfjH08cyYaUtMwjJwqiRKxxE/rx96Uroj1BtIQ6MLJuheaO9"
crossorigin="anonymous">
<div class="input-group custom-search" >
<input type="text" (keyup.enter)="onSearch()" class="form-control custom-search-input" placeholder="Search" aria-label="Search">
<i class="btn fas fa-search custom-search-botton" type="button"></i>
</div>

Related

split homepage into two columns

I'm creating a homepage for my website and want a logo (avatar) to appear on the left hand side of the page and a login form to appear on the right hand side. My current code displays a centered login box and avatar. The avatar is directly above the login box (and slightly offscreen).
Ideally I'm looking to replicate facebooks homepage theme (facebook.com)
Any ideas?
html
{% load static %}
{#<link rel="stylesheet" type="text/css" href="{% static 'homepage/style.css' %}">#}
<html lang="">
<head>
<title>Login Form</title>
<link rel="stylesheet" type="text/css" href="{% static "homepage/style.css" %}">
<body>
<div class="rows">
<div class="logo">
<img src="{% static "homepage/images/my_logo.png" %}"
class="avatar"
alt=""
width=""
height="">
</div>
<div class="login-box">
<h1>Login</h1>
<form>
<p>Username</p>
<input type="text" name="" placeholder="Enter Username">
<p>Password</p>
<input type="password" name="" placeholder="Enter Password">
<input type="submit" name="" value="Login">
Forgot password?<br>
Sign-up<br>
</form>
</div>
</div>
</body>
</html>
css
body {
margin: 0;
padding: 0;
background-size: cover;
background: black center;
font-family: sans-serif;
}
.avatar {
float: left;
width: 200px;
height: 200px;
border-radius: 50%;
position: absolute;
top: -75px;
left: calc(50% - 100px);
}
.login-box{
float: right;
width: 320px;
height: 420px;
background: #000;
color: #fff;
top: 50%;
left: 50%;
position: absolute;
transform: translate(-50%, -50%);
box-sizing: border-box;
padding: 70px 30px;
}
h1 {
margin: 0;
padding: 0 0 20px;
text-align: center;
font-size: 22px;
}
.login-box p {
margin: 0;
padding: 0;
font-weight: bold;
}
.login-box input {
width: 100%;
margin-bottom: 20px;
}
.login-box input[type="text"], input[type="password"] {
border: none;
border-bottom: 1px solid #fff;
background: transparent;
outline: none;
height: 40px;
color: #fff;
font-size: 16px;
}
.login-box input[type="submit"] {
border: none;
outline: none;
height: 40px;
background: #ffc107;
color: #fff;
font-size: 18px;
border-radius: 20px;
}
.login-box input[type="submit"]:hover {
cursor: pointer;
background: lightgray;
color: #000;
}
.login-box a {
text-decoration: none;
font-size: 12px;
line-height: 20px;
color: darkgrey;
}
.login-box a:hover {
color: #ffc107;
}
Here is a basic example of placing two items side by side across the screen. The first uses display grid, and outlines 2 columns, the second is using flex.
img{
height: 50vh;
}
.grid-container{
display: grid;
height: 50vh;
grid-template-columns: auto 1fr;
}
.flex-container{
display: flex;
height: 50vh;
}
.login {
display: flex;
flex-direction: column;
}
<div class="grid-container">
<img src="https://picsum.photos/seed/picsum/200/200" alt="">
<div class="login">
<h1>Login</h1>
<form>
<div>
<label for="email">Email</label>
<input type="text" name="email">
</div>
<div>
<label for="paswd">Password</label>
<input type="password" name="passwd">
</div>
</form>
</div>
</div>
<div class="flex-container">
<img src="https://picsum.photos/seed/picsum/200/200" alt="">
<div class="login">
<h1>Login</h1>
<form>
<div>
<label for="email">Email</label>
<input type="text" name="email">
</div>
<div>
<label for="paswd">Password</label>
<input type="password" name="passwd">
</div>
</form>
</div>
</div>

making form with buttons inline

I have 2 buttons and a form with input type inside of it. I want all of them be inline , but I can't do that.
This is what I have:
.btn-registerLayout {
background-color: #425fab;
font-size: 10px;
outline: none;
text-align: left;
cursor: pointer;
height: 22px !important;
width: 50px !important;
padding: 0 !important;
margin: 0 !important;
}
.btn {
color: #fff !important;
}
/* Search Section*/
.header-search .header-search-box {
position: relative;
width: 100%;
}
.header-search-input {
width: 100%;
background: #f0f0f0;
font-size: 12px;
height: 20px;
transition: .2s;
color: darkgreen;
outline: none;
display: inline;
border: 1px solid red !important;
position: relative;
overflow: hidden;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="d-inline pl-5" style="float:left">
<div class="d-inline">
<form asp-action="Index" asp-controller="Products" class="form-inline" method="get">
<input type="search" class="header-search-input" name="SearchKey" placeholder="Search">
</form>
</div>
<button class="btn btn-registerLayout d-inline" style="width:28px !important">
<i class="ml-2 bi bi-person-plus-fill"></i>
</button>
<button class="btn btn-registerLayout d-inline">
<i class="ml-2 bi bi-box-arrow-in-right"></i><span style="padding-left:5px"> Login</span>
</button>
</div>
but I can not make form inline with buttons and result is like this:
Add d-inline-flex on the parent to get the elements inline, then you can use spacers or ml to space out the buttons from the input.
.btn-registerLayout {
background-color: #425fab;
font-size: 10px;
outline: none;
text-align: left;
cursor: pointer;
height: 22px !important;
width: 50px !important;
padding: 0 !important;
margin: 0 !important;
}
.btn {
color: #fff !important;
}
/* Search Section*/
.header-search .header-search-box {
position: relative;
width: 100%;
}
.header-search-input {
width: 100%;
background: #f0f0f0;
font-size: 12px;
height: 20px;
transition: .2s;
color: darkgreen;
outline: none;
display: inline;
border: 1px solid red !important;
position: relative;
overflow: hidden;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="d-inline-flex pl-5">
<div class="d-inline-block mx-auto">
<form asp-action="Index" asp-controller="Products" class="form-inline" method="get">
<input type="search" class="header-search-input" name="SearchKey" placeholder="Search">
</form>
</div>
<button class="btn btn-registerLayout d-inline ml-2" style="width:28px !important">
<i class="bi bi-person-plus-fill"></i>
</button>
<button class="btn btn-registerLayout d-inline ml-2">
<i class="bi bi-box-arrow-in-right"></i><span> Login</span>
</button>
</div>
.btn-registerLayout {
background-color: #425fab;
font-size: 10px;
cursor: pointer;
}
.btn {
color: #fff !important;
}
/* Search Section*/
.header-search .header-search-box {
position: relative;
width: 100%;
}
.header-search-input {
width: 100%;
background: #f0f0f0;
font-size: 12px;
height: 20px;
transition: .2s;
color: darkgreen;
outline: none;
display: inline;
border: 1px solid red !important;
position: relative;
overflow: hidden;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons#1.8.1/font/bootstrap-icons.css">
<div class="d-inline pl-5" style="float:left">
<div class="d-inline">
<form asp-action="Index" asp-controller="Products" class="form-inline" method="get">
<input type="search" class="header-search-input" name="SearchKey" placeholder="Search">
</form>
</div>
<div class="btn-wrap"><button class="btn btn-registerLayout d-inline">
<span>Login<i class="ml-2 bi bi-box-arrow-in-right"></i></span>
</button>
<button class="btn btn-registerLayout d-inline">
<i class="ml-1 bi bi-person-plus-fill"></i>
</button>
</div>
</div>
</div>
Always works a bit better grouping buttons like that in a wrapper of some sort.

How to add search and mic button in input text?

I want to add a search icon on the left side of the input text and a speaker icon on the right side.
Something like this
Currently my I have :
Here is my code :
.search-bar {
width: 20%;
position: relative;
}
.search-bar input {
width: 100%;
height: 30px;
text-align: center;
border: none;
border-radius: 18px;
outline: none;
}
.search-ico {
position: absolute;
left: 10px;
}
<!--Search Bar-->
<div class="search-bar">
<input type="text" name="search" placeholder="Search" />
<i class="fa-solid fa-magnifying-glass search-ico"></i>
</div>
How can I achieve this? Thanks.
In addition to the answer above you can add pointer for the icon for simulate mouse with cursor:pointer; like:
body {
background: #333;
marging: 0;
}
.search-bar {
width: 30%;
position: relative;
}
.search-bar input {
width: calc(100% - 60px);
height: 30px;
text-align: center;
border: none;
border-radius: 18px;
outline: none;
padding: 0 30px;
}
.search-ico {
position: absolute;
left: 10px;
top:8px;
cursor: pointer; // add cursor
}
.microphone-ico {
position: absolute;
right: 10px;
top: 8px;
cursor: pointer; // add cursor
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!--Search Bar-->
<div class="search-bar">
<input type="text" name="search" placeholder="Search" />
<i class="fa fa-search search-ico"></i>
<i class="fa fa-microphone microphone-ico"></i>
</div>
If you use bootstrap 4 you can use input group like:
.input-group-text i{
cursor:pointer;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<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="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-search search-ico"></i></span>
</div>
<input type="text" class="form-control" aria-label="Search here">
<div class="input-group-append">
<span class="input-group-text"><i class="fa fa-microphone microphone-ico"></i></span>
</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/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
You are going the right way, using position: absolute set the icons
body {
background: #333;
marging: 0;
}
.search-bar {
width: 30%;
position: relative;
}
.search-bar input {
width: calc(100% - 60px);
height: 30px;
text-align: center;
border: none;
border-radius: 18px;
outline: none;
padding: 0 30px;
}
.search-ico {
position: absolute;
left: 10px;
top:8px;
}
.microphone-ico {
position: absolute;
right: 10px;
top: 8px;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!--Search Bar-->
<div class="search-bar">
<input type="text" name="search" placeholder="Search" />
<i class="fa fa-search search-ico"></i>
<i class="fa fa-microphone microphone-ico"></i>
</div>

How to make boostrap button full width?

I have trouble making my button full width in the form.
Also I want the button to be aligned with the forms bottom, so it takes 100% of white space in width and in the bottom.
I suppose Im having some sort of trouble with some of the containers so it cant be scaled properly with standard full width options?
body {
font-family: 'Open Sans', sans-serif;
width: 100%;
text-align: center;
margin: 20px 0px 20px 0px;
}
.forma {
margin: 0 auto 0 auto;
max-width: 450px;
width: 450px;
height: 700px;
}
.fa-container {
float: left;
background-color: #0975BB;
width: 10%;
height: calc(1.5em + .75rem + 2px);
position: relative;
}
i {
color: white;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.form-control {
border-radius: 0%;
float: left;
width: 90%;
margin-bottom: 25px;
}
.btn {
border-radius: 0%;
width: 100%;
background-color: #0975BB;
border-style: hidden;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" type="text/css " integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<link rel="stylesheet" href="styles.css" type="text/css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="js/script.js"></script>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" 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.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<script src='https://kit.fontawesome.com/a076d05399.js'></script>
<div class="forma shadow p-3 mb-5 bg-white rounded">
<img class="top-logo" src="images/csd.png">
<form>
<div class="form-group">
<div class="fa-container">
<i class="fas fa-key"></i>
</div>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Šifra">
</div>
<div class="form-group">
<div class="fa-container">
<i class="fas fa-lock"></i>
</div>
<input type="password" class="form-control btn-block" id="exampleInputPassword1" placeholder="Lozinka">
</div>
<button type="button" class="btn btn-primary ">Sign In</button>
</form>
</div>
Bootstrap 4 has a class pre-defined for this add "btn-block" to the button class
btn-block adds the below CSS styles
display: block;
width: 100%;
Below is an example of how to get it close to what you have linked
body {
font-family: 'Open Sans', sans-serif;
width: 100%;
text-align: center;
margin: 20px 0px 20px 0px;
}
.forma {
margin: 0 auto 0 auto;
max-width: 450px;
width: 450px;
height: 300px;
}
.fa-container {
float: left;
background-color: #0975BB;
width: 10%;
height: calc(1.5em + .75rem + 2px);
position: relative;
}
i {
color: white;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.form-control {
border-radius: 0%;
float: left;
width: 90%;
margin-bottom: 25px;
}
.btn {
border-radius: 0%;
width: 100%;
background-color: #0975BB;
border-style: hidden;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<body style="margin-top: 200px;">
<div class="forma shadow mb-5 bg-white rounded">
<img class="top-logo" src="images/csd.png">
<form>
<div class="form-group p-3">
<div class="fa-container">
<i class="fas fa-key"></i>
</div>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp"
placeholder="Šifra">
</div>
<div class="form-group p-3">
<div class="fa-container">
<i class="fas fa-lock"></i>
</div>
<input type="password" class="form-control btn-block" id="exampleInputPassword1" placeholder="Lozinka">
</div>
<button type="button" class="btn btn-primary ">Sign In</button>
</form>
</div>
The CSS should be written in an <style> tag or in a separate file.
The code is working fine. The button if full width too.
Check it out live here: https://codepen.io/manaskhandelwal1/pen/rNVWEEX
EDIT
To do so remove p-3 and mb-5 class from the div with class .forma.
And do not give the form a fixed height.
See here: https://codepen.io/manaskhandelwal1/pen/zYGogBG

Bootstrap row hiding behind another one on small screens

I'm very new to ASP.NET, and I'm currently using ASP.NET Core 2.0, so my issue could come from this, just letting you know.
So, what I'm trying to do is quite simple, display a row including 2 col-md-6, and another row under this one including a col-md-12.
This works perfectly on "normal" laptop screen, but when I reduce screen size to test responsiveness, the second row displays behind the first one, and in its center.
Laptop screen:
Small screen:
CSS here :
body {
padding-top: 50px;
padding-bottom: 20px;
}
/* Wrapping element */
/* Set some basic padding to keep content from hitting the edges */
.body-content {
padding-left: 15px;
padding-right: 15px;
}
/* Custom changes */
body {background-color:grey;}
.form {
background-color: green;
height: 66vh;
}
.form form {
height: 100%;
}
#inputs {
height: 90%;
width: 100%;
margin: 0;
padding: 0;
}
.col-md-6 {
padding-top: 2%;
padding-bottom: 3%;
text-align: center;
background-color:orange;
height: 100%;
}
.textbox {
width: 66%;
height: 90%;
background-color: red;
resize: none;
}
#submit {
text-align: center;
background-color: pink;
height: 48px;
padding: 0;
margin: 0;
}
.errors {
background-color: aqua;
}
And HTML:
#page
#model IndexModel
#{
ViewData["Title"] = "Home page";
}
#{
string message = "";
string phones = "";
int error_nb = 0;
int error_line = 0;
if (Request.Method == "POST")
{
message = Request.Form["message"];
phones = Request.Form["phones"];
}
}
<div class="form">
<form method="post">
<div class="row" id="inputs">
<div class="col-md-6">
Message:<br />
<textarea type="text" name="message" class="textbox">#message</textarea>
</div>
<div class="col-md-6">
Phones:<br />
<textarea type="text" name="phones" class="textbox">#phones</textarea>
</div>
</div>
<div class="row" id="submit">
<div class="col-md-12">
<input type="submit" name="submit" class="btn btn-lg btn-success" />
</div>
</div>
</form>
</div>
<div class="errors">
<textarea>#error_nb error(s) detected at line #error_line !</textarea>
</div>
Any idea to solve this ?
Thanks !
EDIT: Here is the _Layout.cshtml file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>#ViewData["Title"] - WebApplication6</title>
<environment include="Development">
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="~/css/site.css" />
</environment>
<environment exclude="Development">
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css"
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
</environment>
</head>
<body>
<div class="container body-content">
#RenderBody()
</div>
<environment include="Development">
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
</environment>
<environment exclude="Development">
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js"
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
asp-fallback-test="window.jQuery"
crossorigin="anonymous"
integrity="sha384-K+ctZQ+LL8q6tP7I94W+qzQsfRV2a+AfHIi9k8z8l9ggpc8X+Ytst4yBo/hH+8Fk">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js"
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
crossorigin="anonymous"
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa">
</script>
<script src="~/js/site.min.js" asp-append-version="true"></script>
</environment>
#RenderSection("Scripts", required: false)
</body>
</html>
The problem is that at lower screen resolution, you have no set column... You should always define at least a col-xs-* here, I added col-xs-12 and it works.
CSS here: body {
padding-top: 50px;
padding-bottom: 20px;
}
/* Wrapping element */
/* Set some basic padding to keep content from hitting the edges */
.body-content {
padding-left: 15px;
padding-right: 15px;
}
/* Custom changes */
body {
background-color: grey;
}
.form {
background-color: green;
height: 66vh;
}
.form form {
height: 100%;
}
#inputs {
height: 90%;
width: 100%;
margin: 0;
padding: 0;
}
.col-md-6 {
padding-top: 2%;
padding-bottom: 3%;
text-align: center;
background-color: orange;
height: 100%;
}
.textbox {
width: 66%;
height: 90%;
background-color: red;
resize: none;
}
#submit {
text-align: center;
background-color: pink;
height: 48px;
padding: 0;
margin: 0;
}
.errors {
background-color: aqua;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="form container">
<form method="post">
<div class="row" id="inputs">
<div class="col-md-6 col-xs-12">
Message:<br />
<textarea type="text" name="message" class="textbox">#message</textarea>
</div>
<div class="col-md-6 col-xs-12">
Phones:<br />
<textarea type="text" name="phones" class="textbox">#phones</textarea>
</div>
</div>
<div class="row" id="submit">
<div class="col-xs-12">
<input type="submit" name="submit" class="btn btn-lg btn-success" />
</div>
</div>
</form>
</div>
<div class="errors">
<textarea>#error_nb error(s) detected at line #error_line !</textarea>
</div>
Unfortunately, this is not documented correctly in the docs, but having columns without a XS value will have unpredictable results. Note that in your case, the CSS rule float:left was missing, since only col-xs-* apply it.
It's working perfectly when am using row-fluid in you grid, its suggested to use row-fluid for better responsive cases.
Ref link.
and for the responsive issues, I have added this code for you -
#media only screen and (max-width: 767px) {
#inputs {
height: auto;
width: auto;
margin: 0;
padding: 0;
}
}
body {
padding-top: 50px;
padding-bottom: 20px;
}
/* Wrapping element */
/* Set some basic padding to keep content from hitting the edges */
.body-content {
padding-left: 15px;
padding-right: 15px;
}
/* Custom changes */
body {
background-color: grey;
}
.form {
background-color: green;
height: 66vh;
}
.form form {
height: 100%;
}
#inputs {
height: 90%;
width: 100%;
margin: 0;
padding: 0;
}
.col-md-6 {
padding-top: 2%;
padding-bottom: 3%;
text-align: center;
background-color: orange;
height: 100%;
}
.textbox {
width: 66%;
height: 90%;
background-color: red;
resize: none;
}
#submit {
text-align: center;
background-color: pink;
height: 48px;
padding: 0;
margin: 0;
}
.errors {
background-color: aqua;
}
#media only screen and (max-width: 767px) {
#inputs {
height: auto;
width: auto;
margin: 0;
padding: 0;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="form">
<form method="post">
<div class="row-fluid" id="inputs">
<div class="col-md-6">
Message:<br />
<textarea type="text" name="message" class="textbox">#message</textarea>
</div>
<div class="col-md-6">
Phones:<br />
<textarea type="text" name="phones" class="textbox">#phones</textarea>
</div>
</div>
<div class="row-fluid" id="submit">
<div class="col-md-12">
<input type="submit" name="submit" class="btn btn-lg btn-success" />
</div>
</div>
</form>
</div>