Div not filling up the rest of the page - html

What seems to be an easy HTML page and CSS set up I have come up to an issue. I am trying to make a DIV fill up the rest of the page and meet with the DIV at the bottom.
I have researched all through the web and tried many options I have come across.
It seems the most popular way is to use position:absolute but when I do that my Google map disappears. It will also not let me change the position of the Google Map DIV from relative.
At the moment it is displaying as you can see from my image. I would like the #map DIV to center and fill up the remainder of the space available.
My site in Chrome element view
My HTML code:
<div id="wrapper">
<div id="header">
<h1>Find a Car Park</h1>
</div>
<div id="section">
<input type="text" id="town" placeholder="Search for Town.." onkeypress="handle(event)" />
<input type="button" value="Find Car Parks" onclick="codeAddress()" />
<input type="button" value="View All" onclick="getAllCarParks()" />
<input type="button" value="Your Location" onclick="loadUserScript()" />
</div>
<div id="map">
<div id="googleMap">
</div>
</div>
<div id="footer">
<p>hello</p>
</div>
</div>
</body>
My CSS code:
body{
margin:0;
font-family: 'Cabin', sans-serif;
}
#header {
background-color:#2d89ef;
color:white;
text-align:center;
padding: 20px;
}
#wrapper{
position:absolute;
height:100vh;
width:100vw;
}
#section {
text-align:center;
padding-bottom:15px;
padding-top:15px;
width:100vw;
}
#footer {
background-color:#2c3e50;
color:white;
clear:both;
text-align:center;
padding-top:10px;
padding-bottom:10px;
bottom:0;
position:absolute;
width:100vw;
}
#map {
height:auto;
}
#googleMap{
height:65%;
}
input[type=button], input[type=submit], input[type=reset] {
background-color: #2d89ef;
border: none;
color: white;
padding: 16px 32px;
text-decoration: none;
margin: 4px 2px;
cursor: pointer;
border-radius: 4px;
}
input[type=text] {
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
font-size: 16px;
color: darkgrey;
background-color: white;
background-image: url('../images/searchicon.png');
background-position: 10px 10px;
background-repeat: no-repeat;
padding: 12px 20px 12px 40px;
}

Try using flexbox instead.
https://css-tricks.com/centering-css-complete-guide/
<div style="display:flex;justify-content:center;align-items:center;">
<div></div>
</div>

Try this CSS code on the #map, it will makes your map full width and height of the page :
#map {
display: block;
width: 100%;
height: 100%;
}
Fiddle

Related

Keep Newsletter form fixed to the background image?

I need to make a website without breaking it's structure. But, I've stepped into a problem. I was suggested to put a Newsletter Form on it, so I did. But when I try to resize the window (to check if it breaks), it's not breaking, but it is decentering, is there a way to make it always centers in relation to it's background?
Normal Size Centered:
Resized Not Centered:
I've tried vertical-aling:baseline; | position:sticky; | top:16.5%; bottom:16,5%
CSS:
.boletim .caixa_email{
position:absolute;
z-index:999;
margin:0 auto;
left:0;
right:0;
bottom:33%;
text-align:center;
width:50%;
font-family:Bebas Neue Regular;
font-size:1vw;
}
input[type=email], input[type=submit]{
width:45%;
height:auto;
padding: 12px;
margin: 8px 0;
display: inline-block;
vertical-align:baseline;
border: 1px solid #ccc;
box-sizing: border-box;
}
HTML:
<form action="action_page.php">
<div class="boletim">
<img src="Resumo.png" id="newsletter" alt="">
<div class="caixa_email">
<h1 id="texto_email">Inscreva-se em nosso boletim para receber ofertas!</h1>
<input type="email" name="email" placeholder="exemplo#exemplo.com.br">
<input type="submit" value="Inscrever-se">
</div>
</div>
</form>
I want to make it always centered (in relation to its background) when resizing the window.
try with transform
.boletim .caixa_email{
position:absolute;
z-index:999;
margin:0 auto;
left:50%;
top:50%;
text-align:center;
width:50%;
font-family:Bebas Neue Regular;
font-size:1vw;
transform: translate(-50%, -50%);
}
This result can be achieved with the simple Flex, no need of absolute position.
Give background to the background class in css or you can put image in there and make img absolute with height: 100%; width: 100%; left:0; top:0;
input[type=email], input[type=submit]{
width:45%;
height:auto;
padding: 12px;
margin: 8px 0;
display: inline-block;
vertical-align:baseline;
border: 1px solid #ccc;
box-sizing: border-box;
}
.background {
background: #999;
height: 100vh;
}
form {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
<div class="background">
<form action="action_page.php">
<div class="caixa_email">
<h1 id="texto_email">Inscreva-se em nosso boletim para receber ofertas!</h1>
<input type="email" name="email" placeholder="exemplo#exemplo.com.br">
<input type="submit" value="Inscrever-se">
</div>
</form>
</div>
See the result in full page snippet

HTML/ CSS/ Bootstrap: Navigational buttons on edge of footer

I am trying to implement three navigational buttons on the edge of the footer (so overlapping the header and going into "center of page"). It is supposed to look like this:
How it is supposed to look like
The three buttons I am talking about are the "Dashboard", "Reports" and "Form editing" buttons.
I actually got to this design but when I implemented the other two buttons above this ("Contact us" and "Log out"), one of the 3 navigational buttons jumped out of its position and I am wondering why this happened? Also, when I then implemented bootstrap cdn afterwards, all three buttons changed their size and position and now I'm kind of lost. This is how it looks now:
Current design
My code is the following:
HTML:
<div class="wrapperforstickyfooter">
<header role="banner" class="header-reports">
<div class="content-wrap">
<img class="logo" src="../../_images/logo.JPG" alt="Logo">
<input class="logoutbtns" type="button" value="Log out"/>
<i class="material-icons" id="logout-icons">lock</i>
<input class="contactbtns" type="button" value="Contact us"/>
<i class="material-icons" id="contact-icons">contactmail</i>
<a class= "buttonDB" href="#"> Dashboard</a>
<a class= "buttonREP" href="#"> Reports</a>
<a class= "buttonEDIT" href="#"> Form editing</a>
</div>
</header>
CSS:
.buttonDB, .buttonREP, .buttonEDIT {
background: rgb(234,235,235);
color: rgb(109,111,113);
text-decoration: none;
height: 20px;
width: 180px;
display: inline-block;
text-align: center;
margin-bottom: -20px;
border-top: 10px solid rgb(227,111,30);
position:relative;
left:330px;
top:20px;
font:13px/1.5 Verdana,Helvetica,Arial,sans-serif;
}
.buttonREP {
border-top: 10px solid rgb(225,37,134);
}
.buttonEDIT {
border-top: 10px solid rgb(110,25,112);
}
.content-wrap {
max-width: 1170px;
margin: 0 auto;
padding: 5px;
}
The class .contentwrap is implemented to ensure the text-free margins at the edge of the pages without affecting the background color of the header and footer.
Not sure if you need this but this is the CSS for the logout and contact us buttons:
.logoutbtns {
float:right;
border: none;
background: rgb(0,143,197);
color: white;
font-size: 1em;
/*padding:30px 15px;*/
padding-top:30px;
padding-right: 15px;
margin-right:0;
margin-bottom:0;
}
.contactbtns {
float:right;
border: none;
background: rgb(0,143,197);
color: white;
font-size: 1em;
padding-top:30px;
padding-right: 10px;
margin-right:40px;
margin-bottom:0;
}
.material-icons{
color:white;
float:right;
}
#logout-icons, #contact-icons{
margin-top:25px;
margin-right:0px;
margin-bottom:0;
padding-bottom:0;
}
I am quite stuck here and just cannot figure out what I did wrong.
Does this solve your problem? Only the changes have been made to the .buttonDB, .buttonREP, .buttonEDIT {} and added a button-group class. You can make changes to the button-group class position according to your needs whether you want a relative margin or an absolute, you can tweak around it.
.button-group{
display: flex;
position: absolute;
right:15%;
top: 100px;
}
.buttonDB, .buttonREP, .buttonEDIT {
background: rgb(234,235,235);
color: rgb(109,111,113);
text-decoration: none;
height: 50px;
width: 180px;
display: inline-block;
text-align: center;
border-top: 10px solid rgb(227,111,30);
position:relative;
font:13px/1.5 Verdana,Helvetica,Arial,sans-serif;
margin-right: 10px;
}
.buttonREP {
border-top: 10px solid rgb(225,37,134);
}
.buttonEDIT {
border-top: 10px solid rgb(110,25,112);
}
.content-wrap {
max-width: 1170px;
margin: 0 auto;
padding: 5px;
}
.logoutbtns {
float:right;
border: none;
background: rgb(0,143,197);
color: white;
font-size: 1em;
/*padding:30px 15px;*/
padding-top:30px;
padding-right: 15px;
margin-right:0;
margin-bottom:0;
}
.contactbtns {
float:right;
border: none;
background: rgb(0,143,197);
color: white;
font-size: 1em;
padding-top:30px;
padding-right: 10px;
margin-right:40px;
margin-bottom:0;
}
.material-icons{
color:white;
float:right;
}
#logout-icons, #contact-icons{
margin-top:25px;
margin-right:0px;
margin-bottom:0;
padding-bottom:0;
}
#media only screen
and (max-width : 700px) {
.button-group{
right:3%;
}
.buttonDB, .buttonREP, .buttonEDIT {
height: 30px;
width: 100px;
}
}
<div class="wrapperforstickyfooter">
<header role="banner" class="header-reports">
<div class="content-wrap">
<img class="logo" src="../../_images/logo.JPG" alt="Logo">
<input class="logoutbtns" type="button" value="Log out"/>
<i class="material-icons" id="logout-icons">lock</i>
<input class="contactbtns" type="button" value="Contact us"/>
<i class="material-icons" id="contact-icons">contactmail</i>
<div class="button-group">
<a class= "buttonDB" href="#"> Dashboard</a>
<a class= "buttonREP" href="#"> Reports</a>
<a class= "buttonEDIT" href="#"> Form editing</a>
</div>
</div>
</header>
</div>
I made changes in the answer, hope it helps.
#Harshit:
Thanks for your answer! As said before it worked and looks really nice now. However, when resizing the window (i.e. making it smaller) the buttons stay exactly where they are, so the margin to the right doesn't change nor does their size adjust.
I adjusted the button-group class now to look like this:
.button-group{
display:flex;
position:absolute;
right:7%;
top:100px;
}
This is how the page looks in the beginning. The buttons are exactly how they are supposed to be:
And this is how it looks when making it smaller:
One can directly see that the buttons keep the same distance to the right edge whereas the other stuff immediately starts to shrink its distance to the right edge. Also when I make it really small, the buttons disappear once they are on the left edge of the window. Is there anything I am doing wrong here?

Center A form HTML CSS

Hello I am having issues centering a form for a login page. I am not to good with CSS and it has been a while since I have played with HTML. What I want to do is, center the input boxes and align the text left on top of the input fields, as well as have an image centered as well, like in the picture. I have tried adding different div id and tags to the form but I can not seem to figure out the css part. I appreciate any help and sorry if the CSS is sloppy.
body {
background-color:lightgray;
font-family:Verdana, Arial, Helvetica, sans-serif;
}
h1 {
color: black;
}
p {
color: black;
}
html {
text-alight: center;
}
#login {
text-align:center;
}
input[type=text], input[type=date], input[type=password] {
width: 30%;
height: 50px;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
}
input[type=submit] {
width: 30%;
height: 50px;
background-color: #4CAF50;
border: none;
color: white;
padding: 16px 32px;
text-decoration: none;
margin: 4px 2px;
cursor: pointer;
}
#service_type, #series, #speaker, #users {
width: 30%;
height: 50px;
}
#media only screen and (max-device-width: 1024px){
input[type=text], input[type=date], input[type=password] {
width: 100%;
height: 50px;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
}
input[type=submit] {
width: 100%;
height: 50px;
background-color: #4CAF50;
border: none;
color: white;
padding: 16px 32px;
text-decoration: none;
margin: 4px 2px;
cursor: pointer;
}
#service_type, #series, #speaker, #users{
width: 100%;
height: 50px;
}
#keypad_users{
width: 345px;
height: 50px;
vertical-align:middle;
text-align:center;
border:1px solid #000000;
font-size:30px;
font-weight:bold;
}
#keypad {margin:auto; margin-top:10px;}
#keypad tr td {
vertical-align:middle;
text-align:center;
border:1px solid #000000;
font-size:18px;
font-weight:bold;
width:100px;
height:80px;
cursor:pointer;
background-color:#666666;
color:#CCCCCC;
}
#keypad tr td:hover {
background-color:#999999;
color:#FFFF00;
}
#display {
text-align:center;
width:345px;
margin:10px auto auto auto;
background-color:#000000;
color:#00FF00;
font-size:48px;
border:1px solid #999999;
}
#message {
text-align:center;
color:#009900;
font-size:18px;
font-weight:bold;
display:none;
}
}
<div id="login">
<form action = "login.php" id="login" method ="POST">
Username <br />
<input type="text" name="username" id="username" required /><br /><br />
Password <br />
<input type ="password" name="password" id="password" required /><br /><br />
<input type="submit" name="submit" value="Log in">
</form>
</div>
I've made a JSfiddle for you here (click me please) that resembles the picture you've added.
As requested to not use a third party like I've added the code here:
HTML
<div id="login">
<form action = "login.php" id="login" method ="POST">
<div class="picture">
</div>
<p>Username</p>
<input type="text" name="username" id="username" required /><br /><br />
<p>Password</p>
<input type ="password" name="password" id="password" required /><br /><br />
<input type="submit" name="submit" value="Log in">
</form>
</div>
CSS
body
{
background-color:lightgray;
font-family:Verdana, Arial, Helvetica, sans-serif;
}
#login
{
text-align:center;
width: 50%;
margin: 0 auto;
}
.picture
{
width:100px;
height: 100px;
border-radius: 100px;
background-color:red;
margin: 0 auto;
}
#login p
{
float: left;
}
input[type=text], input[type=date], input[type=password] {
width: 100%;
height: 50px;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
}
input[type=submit] {
width: 100%;
height: 50px;
background-color: #4CAF50;
border: none;
color: white;
padding: 16px 32px;
text-decoration: none;
margin: 4px 2px;
cursor: pointer;
}
EDIT:
New fiddle here: https://jsfiddle.net/gay1ufa1/2/
I've improved your HTML. All form inputs should have an associated label element. Also don't use br for spacing use padding/margin instead.
Further more use have a duplicated id, id's must be unique to the page.
#login_container /*This is Our base container for the login "control" */
{
width:30%; /*Define the width of the control*/
margin:auto; /*This Provide the horizontal centering of the control*/
padding:120px 10px 10px 10px; /*Add some padding, the first number is the top and provides room for the image*/
background-image:url(" http://fillmurray.com/100/100"); /*Add our background image, thanks Bill Murray*/
background-position:center 10px; /*Position our image, first is Horizontal alignment, second is top*/
background-repeat:no-repeat; /*One Bil Murray is more than enough*/
background-color: #F0F0F0; /*Base Background image*/
}
#login_container label
{
display:block; /*Label will now take up a whole line*/
margin-bottom:.25em; /*Give it some room underneath*/
}
#login_container input[type="text"], #login_container input[type="password"], #login_container input[type="submit"]
{
width:100%; /*Form controls now take 100% width of the container*/
margin-bottom:0.5em;
}
<div id="login_container"> <!-- Can't have duplicate ID's -->
<form action = "login.php" id="login" method ="POST">
<label for="username">Username </label>
<input type="text" name="username" id="username" required />
<label for="password">Password</label>
<input type ="password" name="password" id="password" required />
<input type="submit" name="submit" value="Log in">
</form>
</div>
One problem in your code is that you use the ID "login " twice, which must not be done. I put together a codepen, which you can find here:
http://codepen.io/anon/pen/dNWQgp
What I basically did (except adding a div representing the image in your picture): I assigned the following CSS to a wrapper DIV around the whole form and image. It uses flexbox to center the contents. Plus I assigned a width setting (40%) to the form element.
.wrapper {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
To center a div set margin-left and margin-right to auto and assign a fixed width to it. In your case, this would be for #login.

How to center the submit button?

I want to center the submit button on the last div, but i can´t do it.
I try a lot of things, like margin:auto, align-left and right and others asks you make at this page, but it´s imposible for me.
<!DOCTYPE html>
<head>
<meta charset="UTF-8"/>
<title>Mi Revista</title>
<style>
body {
background: #7f7f7f;
}
#container {
width: 800px;
margin: auto;
position: relative;
}
#header {
background: #5783a0;
height: 75px;
}
#contenido {
padding: 1px;
background-color: white;
}
#left {
float:left;
width: 470px;
background-color: pink;
height: 300px;
}
#bordei {
border-style: solid none;
border-width: 2px;
border-color: black white;
background: #efefef;
margin: 0px 0px 2px 10px;
font-weight: bold;
}
#borded {
border-style: solid none;
border-width: 2px;
border-color: black white;
background: #efefef;
margin: 0px 10px 2px 0px;
font-weight: bold;
}
#derecha {
float:left;
width: 330px;
background-color: yellow;
height: 300px;
}
#footer {
height: 50px;
background-color: aquamarine;
clear:both;
}
div form {
display:block
}
#acept {
margin:auto;
}
</style>
</head>
<body>
<div id="container">
<div id="header"> Mi Revista</div>
<div id="contenido"> texto de arriba</div>
<div id="left">
<div id="bordei"> borde uno</div>
formulario izquierda
</div>
<div id="derecha">
<div id="borded">borde derecha </div>
Formulario derecha
</div>
<div id="footer">
<form id="acept">
<input type="submit" name="submit" value="Aceptar"/>
</form>
</div>
</div>
</body>
</html>
I wait for your awnswer, beacuse I can´t do it of any form.
Thaks
Just give alignment center to footer div
<div id="footer" align="center">
Change your CSS slightly as follows
#acept {
width:20px;
margin:0 auto;
}
The problem was that you wasnt specifying a width for the form and due to that it was taking 100% width.And thus the margin:0 auto doesnt work.
I've done a fiddle.Please check it..
Use the text-align:center in #acept is the simplest way.
You could as well use the &ltcenter&gt tag, but is is deprecated. So the best way would be to change
#acept{
margin:auto;
}
to
#acept{
margin:auto;
text-align:center;
}
you can use :
#acept {
margin-left:40%;
width:10%;
}
JSFIDDLE Link

Website linking title - HTML and CSS

Could someone point out how to get the white space left to the login box to be highlighted as part of the link in the title heading? Obviously I don want people to click on the login box and get linked back to the homepage. Tried floating the loginBox element and really not sure what to do. Here's the code:
<html>
<head>
<link rel="stylesheet" href="css.css"/>
</head>
<body>
<div id="container">
<a href="#" style="display:block">
<div id="title">
<h1>Record Store</h1>
<img src="images/vinyl.jpg" height="80px" width="auto" />
</div>
</a>
<div id="loginBox">
<form action="#">
<label>User Name: </label>
<input type="text" />
<label>Password: </label>
<input type="password" />
<input type="submit" value="Login"/>
</form>
</div>
<div id="navigation" >
<ul class="navbar">
<li>Home</li>
<li>Vinyl Stock</li>
<li>Online Offers</li>
<li>Collectors News</li>
<li>Join</li>
</ul>
</div>
<div id="content">
<p>You'd be a fool to believe anything on this site</p>
</div>
<div id="footer">
<span id="adminLogin">Admin Login</span>
<p id="copyright">©</p>
</div>
</div>
</body>
</html>
and
* {
padding: 0;
margin:0;
}
body{
font-family: Arial, Verdana, Helvetica;
}
h1{
font: bold 2.8em Arial, Verdana, Helvetica;
position:absolute;
left: 10px;
top:5px;
}
img {
position: absolute;
left:300px;
/*top:5px;*/
}
#container {
margin: auto;
width: 800px;
border: 1px solid black;
z-index: -9;
}
#title {
margin:auto;
/*border: 1px solid black;*/
height: 16%;
position: relative;
}
#loginBox{
float:right;
border: 1px solid black;
}
#navigation{
clear:both;
border-top: 1px solid black;
border-bottom: 1px solid black;
height: auto;
overflow: auto;
background-color: blue;
}
#content{
min-height:400px;
background-color: white;
}
#adminLogin{
float:right;
margin-right: 60px;
margin-top: 20px;
}
#footer{
height:100px;
background-color: red;
}
#copyright{
clear: both;
text-align: center;
}
.navbar {
}
.navbar ul {
}
.navbar li {
font: bold 12px/1.2em Arial, Verdana, Helvetica;
height: auto;
list-style: none;
text-align: center;
width: 20%;
float:left;
background-color: blue;
padding: 1% 0px;
}
.navbar a {
border-right: 1px solid #1F5065;
color: white;
display: block;
text-decoration: none;
}
.navbar li:hover a {
color: black;
}
.navbar li:hover{
background-color: white;
}
I think your best bet is to fill a parent div with your anchor, and then absolutely position the login on top. The absolutely positioned header and image are better placed using padding, to maintain the box's natural height.
h1 {
font: bold 2.8em Arial,Verdana,Helvetica;
display: inline-block;
vertical-align: top;
}
#header {
position: relative;
margin:auto;
}
#title {
padding: 5px 0 24px 10px;
}
#loginBox{
border: 1px solid black;
position:absolute;
right:0;
bottom:0;
}
And then add your relative div, like
<div id="header">
<a href="#" style="display:block">
<div id="title">
<h1>Record Store</h1>
<img src="images/vinyl.jpg" height="80px" width="auto" />
</div>
</a>
<div id="loginBox">
<form action="#">
<label>User Name: </label>
<input type="text" />
<label>Password: </label>
<input type="password" />
<input type="submit" value="Login"/>
</form>
</div>
</div>