Hi i have a problem i need to fix i have a form that i need to put inside a box so i put the form inside a div and assigned a background-color to the div the only problem is the div is sretching the whole browser width when i want it to only stretch as far as the content.
Heres a screenshot:
Screenshot
CSS CODE:
.content-wrapper {
background-color: #FFFFFF;
width: auto;
height: auto;
}
.input-text {
background-image: url("images/input-text.png");
background-repeat: no-repeat;
width: 214px;
height: 39px;
font-size: 14px;
font-family: "custom font", Tahoma, sans-serif;
color: #9aa1aa;
border: none;
padding-left: 11px;
padding-right: 11px;
}
.input-text:focus {
background-image: url("images/input-textf.png");
color: #34495e;
outline: none;
}
HTML CODE:
<div class="content-wrapper">
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
<?php
echo $dbnameErr;
echo $dbuserErr;
echo $dbpassErr;
echo $dbhostErr;
?>
Database Name<input class="input-text" type="text" name="db-name" value="<?php echo $dbname;?>" ><br />
Username<input class="input-text" type="text" name="db-username" value="<?php echo $dbuser;?>" ><br />
Password<input class="input-text" type="text" name="db-password" value="<?php echo $dbpass;?>" ><br />
Database Host<input class="input-text" type="text" name="db-host" value="localhost" ><br />
<input type="submit">
</form>
</div>
You need an outer DIV styled text-align:center
<div style="text-align:center" >
Then you need to change the CSS for your content wrapper to:
.content-wrapper {
display:inline-block;
text-align:left;
background-color: #FFFFFF;
margin-left: auto;
margin-right: auto;
}
Note the first two lines and the last two lines.
I have to look this up every time I need to do it :)
.content-wrapper {
background-color: #FFFFFF;
width: 400px; //Set width of the content wrapper.
height: auto;
}
This will set your width of the content-wrapper width.
Related
I've got two forms on a webpage I'm making. On all the pages I have no forms on, the footer sits neatly at the bottom of the page however as soon as I introduce forms, the footer has some whitespace below it about the same size as the footer and sticks to the form. It should stay at the bottom of the page no matter viewport. I've looked extensively for an answer to this but can't find one.
I tried using this http://matthewjamestaylor.com/blog/keeping-footers-at-the-bottom-of-the-page person's blog to fix it but it didn't.
Any help would be greatly appreciated.
body {
background-color: #40E39C;
display: relative;
margin: 0;
padding: 0;
height: 100%;
}
.style1{
border: 2px;
border-radius: 20px;
border-color: #D6B656;
background-color: #FFF2CC;
}
.style2{
border: 2px;
border-radius: 20px;
border-color: #82B366;
background-color: #D5E8D4;
}
.container {
min-height: 100%;
height: auto !important;
height: 100%;
margin-bottom: -142px;
margin-top: 30px;
}
.footer {
background-color: #EAEDD0;
text-align: center;
width: 100%;
}
.footer, .push {
height: 142px;
}
.footer li {
display: inline-block;
}
.footer ul {
text-align: center;
margin: 0;
}
<div class="container">
<div id="restaurant-book">
<form class="style1" style="text-align: center;">
<div style="display:inline;clear:both;">
First name: <br/><input type="text" name="firstName" required/><br/><br/>
Last name: <br/><input type="text" name="lastName" required/><br/><br/>
</div>
<div style="display:inline;clear:both;">
<?php if (isset($_POST["date"])){?>
Booking date: <br/><input type="date" value="<?php echo $_POST['date'] ?>" required/><br/><br/>
<?php } else {?>
Booking date: <br/><input type="date" required/><br/><br/>
<?php } ?>
</div>
<div style="display:inline;clear:both;">
<?php if (isset($_POST["time"])){?>
Time: <br/><input type="time" min="09:00:00" max="22:00:00" step="1800" value="<?php echo $_POST['time'] ?>" required/><br/><br/>
<?php } else {?>
Time: <br/><input type="time" min="09:00:00" max="22:00:00" step="1800" required/><br/><br/>
<?php } ?>
</div>
<div style="display:inline;clear:both;">
Number of adults: <br/><input type="number" max="10" required/><br/><br/>
</div>
<div style="display:inline;clear:both;">
Number of children (0-11 years): <br/><input type="number" max="10" required/><br/><br/>
</div>
<div style="display:inline;clear:both;">
Number of tables: <br/><input type="number" max="5" required/><br/>
</div>
</form>
</div>
<div class="push"></div>
</div>
<footer class="footer">
<ul>
<li>A | </li>
<li>B | </li>
<li>C | </li>
<li>D | </li>
<li>E | </li>
<li>F </li>
</ul>
</footer>
I think I got you, try adding this to your css BUT first remove the "push" div
.footer {
background-color: #EAEDD0;
text-align: center;
width: 100%;
position: fixed;
bottom: 0;
}
I'm a newbie when talking about HTML, and I need to make a web page to a data collector with Windows CE. These stuff have a very low resolution screen (300px-) and everything I try to do goes bad on that resolution.
The best screen I could make:
//Remove a mensagem de sucesso ou falha
function none(){
document.getElementById('message').style.display = 'none';
}
//Insere a mensagem de sucesso ou falha
function block(){
document.getElementById('message').style.display = 'block';
}
function setCodDeposito1(){
document.getElementById('codDeposito').value = "1";
}
function alertSuccess(){
alert("");
}
body{
margin-left: 3px;
font-family: sans-serif;
}
.btnLimpar{
margin-top:5px;
padding: 0px 65px 0px;
margin-left: 180px;
text-align: center;
}
.btnConsulta{
width: 100%;
text-align: center;
margin: 5px 0px 4px 0px;
}
label{
margin: 3px 0px 3px;
display:inline-block;
float: left;
clear: both;
text-align:right;
}
h3{
align-self: center;
}
input{
margin-bottom: -10px;
text-align: right;
float: right;
}
#main{
overflow: all;
width: 100%;
height: 100%;
}
<h3>Consulta de Produtos</h3>
<div id="main">
<label for="codDeposito">Código do Depósito:</label><input type="text" id="codDeposito" size="20"/>
<label for="codBarras">Código de Barras:</label><input type="text" id="codBarras" size="20" />
<input type="button" class="btnConsulta" value="Consultar" onclick="block(); setCodDeposito1();"/>
<form>
<label for="codProduto">Código do Produto:</label><input type="text" id="codProduto" size="20"/>
<label for="descProduto">Descrição do Produto:</label><input type="text" id="descProduto" size="20"/>
<label for="complemento">Complemento:</label><input type="text" id="complemento" size="20"/>
<label for="enderecamento">Endereçamento:</label><input type="text" id="enderecamento" size="20"/>
<label for="qtdEstoque">Qtd em Estoque:</label><input type="text" id="qtdEstoque" size="20"/>
<input type="button" class="btnLimpar" value="Limpar" onClick="this.form.reset();none();"/>
</form>
</div>
<div class="alert" id="message" style="display: none;">
×
Consultado com sucesso!
</div>
Sorry for the giant code with a lot of trash that does nothing..
Anyways, I need to make a web page like this that goes well in a very small resolution. And my code is showing a success message when I click on Consult, but that's showing in the middle of the screen and I can't take it out there.
Do you have any suggestions with a better way to do this?
You need to add media queries to your css. Be specific also on adding it.
Example:
#media only screen and (max-width: 300px) {
body {
background-color: #000;
}
}
I'm trying to get certain elements of this form to be displayed on the same line: I want the output of the form to be displayed on the same line as "Total: $ " - (I still want the price per lb ($1.00 in this example) to be displayed on the line above and the number spinner to be displayed to the right). I tried to wrap the whole thing in a <span> that I set the CSS of to be display:inline but it didn't work (& I've tried a few other things as well which also didn't work).
Here's a selection of my code:
HTML:
<div class="caption">
<form onsubmit="return false" oninput="amount.value = (quantity.valueAsNumber * (1))">
<legend>$1.00</legend>
<span class="quant"><p><label for="quant">QTY</label>
<input type="number" min="1" max="5" id="quantity" name="quantity"></p></span>
<span class="inline"><p>Total:$<output name="amount" for="quantity"></output></p></span>
</form>
</div>
CSS:
legend { float: left;
margin-top: 35px;
padding-top: 20px;
margin-bottom: 5px;
}
.inline { display: inline; }
.quant { text-align: right;
max-width: 30em;
float: right;
margin-top: 25px;
padding-bottom: 5px;
margin-bottom: 10px;
}
legend { float: left;
}
.inline { display: inline; }
.quant { text-align: right;
max-width: 30em;
float: right;
}
form > * { border:1px solid red; line-height:2em }
<div class="caption">
<form onsubmit="return false" oninput="amount.value = (quantity.valueAsNumber * (1))">
<legend>$1.00</legend>
<span class="quant">
<label for="quant">QTY</label>
<input type="number" min="1" max="5" id="quantity" name="quantity">
</span>
<span>Total:$<output name="amount" for="quantity"></output></span>
</form>
</div>
Get rid of your p tags. Try not to use dispensable containers and classes. Your code would be more readable. You can change the line-height value of form > *
I have a search bar and I am trying to embed a font awesome icon, however it does not seem to be getting wrapped within the container div
Here is an image which shows where the icon currently is and I want the search icon to go
Any help will be greatly appreciated, thank you
CSS:
#import url("//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css");
.searchbar{
position:relative;
}
.searchbar input { text-indent: 32px;}
.searchbar .fa-search {
position: absolute;
top: 10px;
left: 10px;
color: #4f5b66;
}
.search_field {
min-width: 270px;
width: 65%;
height:40px;
font-size: 2em;
behavior: url(js/PIE.htc);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
margin-right: -4px;
margin-top: 10px;
float:right;
}
HTML:
<div class="searchbar">
<form method="GET" action="search.php" style= "padding: 1px; font-family: Tahoma, Geneva, sans-serif;">
<span class="fa fa-search fa-lg"></span>
<input type="text" name="search" class="search_field" value="<?php echo $_GET['search']; ?>" id="search" maxlength="20" />
<input type="hidden" name="start" value="0" />
<input type="hidden" name="limit" value="10" />
</form>
</div>
You should wrap your input on a div, position that DIV exactly where you want the text input to be, and then set the DIV to position relative. Also place your icon inside this DIV.
On another note, if you ICON is supposed to be clickable for submit purposes, dont use a span, either use a 'button' tag or an actual input-type:submit
I'm trying to insert a search field in my header (black zone) but doesn't work. I want the search field inline with "SimpleCMS"...
See this screenshot to understand:
I want it on the same line as the header text...
There's my HTML code:
<div id="header"><h1><?php echo($header_text); ?></h1>
<div style="float: right;">
<form action="search.php" method="get">
<input type="text" name="q" id="q" value="Search..." />
<input type="submit" value="Search" />
</form>
</div>
</div>
And my CSS:
#header
{
padding: 5px 10px;
background: #000;
color: #FFF;
text-align: left;
}
The problem is that you use a <h1> element. This will span over the whole width (see here) of the top so that every other element will be placed below it. Use a <span> instead and style it according to your needs. Using position-absolute as alpaca lips nao suggests might work as well.
Update: Use position: absolute;
#header
{
padding: 5px 10px;
background: #000;
color: #FFF;
text-align: left;
position: relative;
}
#header div form {
position: absolute;
top: 75px;
right: 25px;
}