Can't seem to get form to appear inside a div? - html

I'm trying to create a form that sticks at the bottom of the div that says "General" and "programming."
Here's a picture:
I've tried many things, and can't seem to get the form to appear... When I do get something to appear, I can't make it stick to the bottom either. Can anyone help?
I'm using bootstrap
Heres my HTML:
<div class="chatroom">
<div id="contain">
<div id="channels">
<div class="list-group">
General
Programming
</div>
<div id="bar"></div>
<form id="create-channel">
<div class="form-group">
<input type="text" id="c" class="form-control" autocomplete="off"></div>
</form>
</div>
<div id="chat">
<ul id="messages">
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
<div class="input">
<form>
<div class="form-group">
<input type="text" id="m" class="form-control" autocomplete="off"></div>
</form>
</div>
</div>
</div>
</div>
and CSS:
body {
background-color: azure;
background: url(../images/background.jpg) no-repeat center center fixed;
-webkit-background-size:cover;
background-size:cover;
}
.chatroom {
width: 90vw;
height: 80vh;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
position: fixed;
border: 2px solid white;
border-radius: 30px;
background-color: white;
opacity:.8;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
display: flex;
flex-direction: column;
}
.input {
height: 40px;
width: 98%;
margin-left:1%;
margin-top: auto;
}
#chat .form-control{
border-bottom-right-radius: 30px;
border-top-right-radius: 30px;
}
#chat{
border-top-right-radius: 30px;
border-bottom-right-radius: 30px;
float: right;
height:100%;
width: 75%;
display: flex;
flex-direction: column;
}
#channels{
border-top-left-radius: 30px;
border-bottom-left-radius: 30px;
background-color: white;
width:25%;
float: left;
height:100%;
overflow-y: hidden;
}
#bar{
background-color:black;
height:100%;
float: right;
width: 3px;
}
#contain{
height:100%;
}
.list-group{
font-family: "Avant Garde",Avantgarde,"Century Gothic",CenturyGothic,AppleGothic,sans-serif;
font-size:20px;
width:calc(100% - 3px);
background-color:#bcbcbc;
float:left;
display:inline-block;
}

It works fine when I rearrange the bar div below your form. Check here: https://jsfiddle.net/vj2fyuLm/
<form id="create-channel">
<div class="form-group">
<input type="text" id="c" class="form-control" placeholder="one" autocomplete="off"></div>
</form>
<div id="bar"></div>
Update
You can have your entire form inside the list group like this: https://jsfiddle.net/vj2fyuLm/3/
<div class="list-group">
General
Programming
<form id="create-channel">
<div class="form-group">
<input type="text" id="c" class="form-control" placeholder="one" autocomplete="off"></div>
</form>
</div>

Can you remove the div with id #bar? It seems that by floating that to the right, you get some layout funk.
By removing that, the form field shows up then you can style it as you desire:
http://jsfiddle.net/20nhLz3x/4/

Related

How to position the results div beneath the search input with the same width of the input?

I have a search box that shows some results while typing.
Here is a static example:
<form method="GET" class="my-form">
<div class="search-wrapper">
<span>
<input type="search" class="search-query" placeholder="Search"> </span>
<span>
<input type="submit" value="search" class="search" >
</span>
<div class="results">
<ul>
<li>first</li>
<li>second</li>
<li>third</li>
</ul>
</div>
</div>
</form>
CSS:
.my-form{width:100%}
.search-wrapper{
width: 50%;
margin: 0 auto;
background: #000;
display: table;
position:relative;
padding:2%
}
span{display:table-cell;margin-top:10%}
span:first-of-type{width:75%}
.search-query{
border-top-left-radius: 25px;
border-bottom-left-radius: 25px;
padding-left: 3%;
width:100%
}
.search{
background: #ea7d20;
border-radius: 25px;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
width:100%
}
.results{
width:75%;
background:#888;
color:#fff;
position:absolute;
left:0;
top:100%
}
I want to position the results div beneath the search input and have the same width of that input , It should be responsive too.
Here is a live preview: https://jsfiddle.net/nner02rk/4/
Your results is inside the search-wrapper. But this div is affected by a padding of 2%. That is why your values are not responding as you expecte them to.
.results{
width: 70%;
background: #888;
color: #fff;
position: absolute;
left: 3.5%;
top: 100%;
}
To validate the alignment, you can set the top value to 71%
Hope this helps :)
.my-form{width:100%}
.search-wrapper{
width: 50%;
margin: 0 auto;
background: #000;
display: table;
position:relative;
padding:2%
}
span{display:table-cell;margin-top:10%}
span:first-of-type{width:75%}
.search-query{
border-top-left-radius: 25px;
border-bottom-left-radius: 25px;
padding-left: 3%;
width:100%
}
.search{
background: #ea7d20;
border-radius: 25px;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
width:100%
}
.results{
width: 70%;
background: #888;
color: #fff;
position: absolute;
left: 3.5%;
top: 100%;
}
<form method="GET" class="my-form">
<div class="search-wrapper">
<span>
<input type="search" class="search-query" placeholder="Search"> </span>
<span>
<input type="submit" value="search" class="search" >
</span>
<div class="results">
<ul>
<li>first</li>
<li>second</li>
<li>third</li>
</ul>
</div>
</div>
</form>
Updated your fiddle just keep the result class width to 100%..
.results{
margin-left: 4%;
width:70%;
}
https://jsfiddle.net/nner02rk/8/

how do vertically align login form between banner and footer

Given I have the html and css in the snippet below the question, how can I vertically centre the login view no matter what screen height is?
I have tried this for the .login-layout__positioner class:
.login-layout__positioner {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 42%;
transform: translateY(-42%);
}
But this does not centre well in large screen heights?
Is there a better way?
body {
height: 100%;
background-color: #f7f7f4;
}
.app-layout__body {
height: 100vh;
display: flex;
flex-direction: column;
}
.app-layout__container {
flex: 1 0 auto;
}
.banner__container {
background-color: #fff
}
.banner__top {
padding-top: 15px;
}
.login-layout__container {
background-color: #f7f7f4;
width: 100%;
}
.login-layout__positioner {
text-align: center;
margin: auto;
}
footer {
background-color: #0065bd;
}
a {
color: #fff;
}
ul {
list-style: none;
margin-left: 0;
}
li {
display: inline;
}
.form__group {
background-color: #fff;
}
<body>
<div id="root">
<div class="main-content">
<div class="app-layout__body">
<div class="app-layout__container">
<div class="banner__container">
<div class="banner__top">
<div>
<div>
<h2>Banner</h2></div>
</div>
</div>
</div>
<div class="login-layout__container">
<div class="login-layout__positioner">
<div class="form__group">
<div>
<form>
<div class="login__container">
<div class="login__wrapper">
<div>
<div>
<div class="login__form__elements">
<div>
<div>
<h2 class="">Sign In</h2></div>
</div>
<div>
<div>
<div>
<label for="email" id="email-label" class="label__default label__strong label__double-margin">Email</label>
<div>
<input type="text" autocomplete="off" class="input__default form-control" id="email" name="email" aria-invalid="false" aria-describedby="email-error" value="">
</div>
<div id="email-error" aria-hidden="true" role="alert"></div>
</div>
</div>
</div>
<div>
<div>
<div>
<label for="password" id="password-label">Password</label>
<div>
<input type="password" autocomplete="off" id="password" name="password" aria-invalid="false" aria-describedby="password-error" value="">
</div>
<div id="password-error" aria-hidden="true" role="alert"></div>
</div>
</div>
</div>
<div>
<div><a to="/">Forgotten your password?</a></div>
<div>
<button type="submit">LOGIN</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<footer>
<div>
<div>
<div>
<ul>
<li><a target="_blank" href="/static/about">About</a></li>
<li><a target="_blank" href="/static/accessibility">Accessibility</a></li>
<li><a target="_blank" href="/static/cookies">Cookies</a></li>
<li><a target="_blank" href="/static/privacy">Privacy</a></li>
</ul>
</div>
</div>
</div>
</footer>
</div>
</div>
</div>
</body>
When it comes to centering something both vertically and horizontally I like to use css flex. Adding it to the parent container surrounding the element you wish to center will cause it to flex in all screen dimensions and heights. Justify-content centers it horizontally and align-items centers it vertically. Here is a helpful guide to learn more about flex:https://css-tricks.com/snippets/css/a-guide-to-flexbox/
.parent-container{
width:100vw;
height:100vh;
background-color:black;
display:flex;
justify-content:center;
align-items:center;
}
.child{
width:50%;
background-color:white;
text-align:center;
}
<div class="parent-container">
<div class="child">
<h1>Centered</h1>
</div><!-- child -->
</div><!-- parent-container -->
Flexbox and grid work great for this, the difference being that grid is said to be 2 dimensional whereas flexbox is 1 dimensional. See MDN's Relationship of flexbox to other layout methods. BTW: If you want a sticky footer add min-height: 100vh; to your container.
Both Ron and Jeh's answer are correct. Though I'm wondering why do you have so many container wrappers then if you can just use certain wrappers to display your entire login form, banner and footer.
Here's my template for my custom login forms.
You will noticed that I use calc on height to differentiate the height of banner and footer and then less it to the height of your .section-login container, in which it will automatically adjusted the height no matter what the browser height does. And I declared min-height just to avoid overlaying above to each container wrapper.
Hope this helps.
.login {
background: pink;
margin: 0;
padding: 0;
}
.body-wrapper {
background: white;
width: 100%;
height: 100vh;
}
.hero-wrapper,
.globalfooter {
background: #CCC;
text-align: center;
}
.hero-wrapper {
line-height: 200px; /* just for the text v-alignment only */
height: 200px;
}
.globalfooter {
line-height: 100px; /* just for the text v-alignment only */
height: 100px;
}
.section-login {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: #EEE;
min-height: calc(100% - (200px + 100px));
padding: 30px;
box-sizing: border-box;
}
.help-text-wrapper {
font: 300 12px sans-serif;
color: red;
text-align: center;
margin: 15px 0 0;
}
.help-text-wrapper.hidden {
/* Remove comment to enable
display: none; */
}
h1 {
font: 600 24px sans-serif;
text-align: center;
text-transform: uppercase;
margin: 0 0 15px;
}
form {
background: #FFF;
font: 300 12px sans-serif;
text-transform: uppercase;
width: 260px;
padding: 30px;
box-shadow: 0 0 5px 0 rgba(0,0,0,0.50);
box-sizing: border-box;
border-radius: 3px;
}
form > fieldset {
margin: 0 0 15px;
padding: 0;
border: 0;
}
form > fieldset label:first-child {
display: block;
margin-bottom: 15px;
}
form input {
display: block;
width: 100%;
height: 30px;
margin: 5px 0;
padding: 6px;
box-sizing: border-box;
}
form button {
display: block;
background: #888;
color: #FFF;
text-transform: uppercase;
height: 30px;
margin: auto;
padding: 7px 15px;
border: 0;
cursor: pointer;
}
<body class="login page">
<div class="body-wrapper">
<header class="hero-wrapper">
Banner
</header>
<section class="section-login">
<h1>Sign In</h1>
<form action="" method="post">
<fieldset>
<label for="username">
Username
<input type="text" id="username" value="" placeholder="Username" autofocus>
</label>
<label for="password">
Password
<input type="password" id="password" value="" placeholder="Password">
</label>
</fieldset>
<button type="submit">Login / Sign In</button>
</form>
<div class="help-text-wrapper hidden">
Something around here after fallback.
</div>
</section>
<footer class="globalfooter">
Footer
</footer>
</div>
</body>
Just change some class properties which I wrote down:
.login-layout__positioner {
display: flex;
align-items: center;
justify-content: center;
}
.form__group {
background-color: transparent;
}
a {
color: #333;
}
footer a {
color: #fff;
}

Bootstrapped webpage has input disabled due to position:relative

hello I one simple but annoying problem. I managed to use css and bootsatrap to create the responsive webpage that i wanted. However, when i used position:relative my input (text field) got disabled. Any idea why?
<div class="col-md-offset-2 col-md-8 text-center">
<div class="container-fluid">
<div id="logo">
<img class="img-responsive" src="uv.png">
</div>
<div class="login-form">
<h1>United Volunteers</h1>
<div class="form-group">
<label class="input-title">Username</label>
<input type="text" class="form-input" placeholder="Username">
</div>
<div class="form-group">
<label class="input-title">Password</label>
<input type="password" class="form-input" placeholder="Password">
</div>
</div>
</div>
</div>
.login-form {
top:90px;
position:relative;
box-sizing: border-box;
margin: 25px auto;
margin-bottom:0px;
width: 100%;
max-width:400px;
background-color: white;
padding: 100px 50px 50px 50px;
box-shadow: 1px 5px 2px #330000;
z-index: -1;
}
.form-input {
width: 100%;
display: block;
height: 35px;
padding: 6px 12px;
font-size: 12px;
font-family: sans-serif;
vertical-align: middle;
border: 1px solid #ccc;
border-radius: 4px;
background-color: #f2f2f2;
line-height: 1.5;
}
This is because of z-index: -1;. Its set to negative value.
Just make it positive like:
.login-form {
z-index: 1;
}
Or look at the snippet below:
.login-form {
top:90px;
position:relative;
box-sizing: border-box;
margin: 25px auto;
margin-bottom:0px;
width: 100%;
max-width:400px;
background-color: white;
padding: 100px 50px 50px 50px;
box-shadow: 1px 5px 2px #330000;
z-index: 1;
}
.form-input {
width: 100%;
display: block;
height: 35px;
padding: 6px 12px;
font-size: 12px;
font-family: sans-serif;
vertical-align: middle;
border: 1px solid #ccc;
border-radius: 4px;
background-color: #f2f2f2;
line-height: 1.5;
}
<div class="col-md-offset-2 col-md-8 text-center">
<div class="container-fluid">
<div id="logo">
<img class="img-responsive" src="uv.png">
</div>
<div class="login-form">
<h1>United Volunteers</h1>
<div class="form-group">
<label class="input-title">Username</label>
<input type="text" class="form-input" placeholder="Username">
</div>
<div class="form-group">
<label class="input-title">Password</label>
<input type="password" class="form-input" placeholder="Password">
</div>
</div>
</div>
</div>
Hope this helps!

Center login form bootstrap

please help, i want this form dead center both vertical and horizontal so it looks like this http://www.creattor.com/files/14743/5515/futuristic-login-form-screenshots-1.jpg and so it is dynamical center hope you can help me.
<html>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<style>
body{
background-color:#33383E;
}
.login input{
width:150px;;
background-color:#1D1E22;
border: 0px solid;
padding:5px;
color:#33383E;
}
.login{
width:320px;
padding:20px;
background-color:#1D1E22;
border-radius:10px;
margin-top:33.3%
}
#user{
margin-bottom:-10px;
}
#pass{
margin-top:-10px;
margin-bottom:0px;
}
#login{
display: inline;
margin: 0;
}
hr{
border:2px solid;
background-color: #33383E;
}
#circle {
width: 100px;
height: 100px;
background: #33383E;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;
border-radius: 50px;
float:right;
}
#mini-circle{
width: 70px;
height: 70px;
background: #1D1E22;
-moz-border-radius: 40px;
-webkit-border-radius: 40px;
border-radius: 40px;
margin-right:auto;
margin-left:auto;
margin-top:15px;
}
.ring{
margin-top:-125px;
margin-left: 200px;
}
</style>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-3">
<div class="form-group">
<div class="login">
<form id="login" method="post">
<input type="text" id="user" name="user" placeholder="Username" /><br />
<hr />
<input type="password" id="pass" name="pass" placeholder="Password" />
</form>
</div>
<div class="ring"><div id="circle"><div id="mini-circle"></div></div></div>
</div>
</div>
<div class="col-md-4"></div>
</div>
</div>
</body>
</html>
Codepen: http://codepen.io/anon/pen/rVjpJb
CSS for .form
display: inline-block
CSS for containing element (eg. div, body)
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
Also, Make sure that the document has 100% height
PS- Sorry I didn't use all the markup
You can achieve it with CSS tables too.
Here's the fiddle: http://jsfiddle.net/jf4nvk1n/ for the futuristic-login-form
And here's the fiddle for the fast explanation http://jsfiddle.net/1dcevxhm/
HTML:
<div class="table">
<div class="table-cell">
<p>Test</p>
</div>
</div>
CSS:
html, body, .table, .table-cell{
height: 100%;
width: 100%;
}
.table{
display: table;
}
.table-cell{
display: table-cell;
vertical-align: middle
}
p{
margin-right: auto;
margin-left: auto;
width: 20%;
text-align: center;
}

Positioning div with arrow in bootstrap form field

I am trying to position a div with arrow in bootstrap form field but the pointing arrow is pointing to the next row. Here is my code:
<h3>Rregistration </h3>
<div class="control-group">
<label class="control-label" for="inputName">Name</label>
<div class="controls">
<input type="text" id="inputName" placeholder="Name">
</div>
</div>
<div class="container">
<div id="pointer"></div>
</div>
and the CSS
.container {
margin-top: 10px;
}
body {background:#ff004e;padding:40px}
.container {
background:white;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
width:250px;
height:100px;
display: block;
position: relative;
}
#pointer{
border-right:solid 20px #FFF;
/* border-left: solid 5px transparent; */
border-top: solid 10px transparent;
border-bottom: solid 10px transparent;
position:absolute;
width: 0;
height: 0;
top: 10px;
left:-20px
}
The JsFiddle link is here: http://jsfiddle.net/barnamah/Epj6z/13/
try this
http://jsfiddle.net/Epj6z/15/
<h3>Rregistration </h3>
<div class="control-group">
<label class="control-label" for="inputName">Name</label>
<div class="controls">
<input type="text" id="inputName" placeholder="Name" style="float:left">
<div class="span3">
<div id="pointer"></div>
</div>
</div>
</div>
body {background:#ff004e;padding:40px}
.span3 {
background:white;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
width:250px;
height:100px;
display: block;
position: relative;
}