5
I have the following form:
.table {
max-width: 500px;
border-collapse: collapse;
font-size: 12;
width: 320px;
text-align: center;
box-shadow: 2px 2px 2px 2px #aaa;
}
.table tr td{
padding: 8px 8px 8px 8px;
}
.campo {
border: 1px double black;
}
#teste {
overflow: auto;
max-height: 500px;
max-width: 18ç0px;
position:absolute;
z-index:999;
left:0%;
top:0%;
background-color:#fff;
border:1px solid #000;
padding:6px;
}
#teste2 {
overflow: auto;
max-height: 500px;
max-width: 300px;
position:absolute;
z-index:999;
right:0%;
top:0%;
background-color:#fff;
border:1px solid #000;
padding:6px;
}
<div id="teste">
<form id="form1" name="form1" method="post" action="#">
<input type="button" onclick="ver()" value="x">
<div id="div1" style="display: none;"></div>
</form>
</div>
<center>
<h1>x</h1>
</center>
<form id="form2" name="form2" method="post" action="#">
<center>
<table class="table">
<tr>
<td class="campo">
<span id="inf1">*x</span><br/>
<input type="text" id="txt" name="txt" size="2"/><br/>
<span id="inf2">x?</span><br/>
<input type="text" id="txt2" name="txt2" size="2"/><br/>
x?
<input type="checkbox" id="ckb" name="ckb" /><br/><br/>
<input type="button" value="x" onclick="setaInf();">
</td>
</tr>
</table>
<br/>
<span id="inf3"><small>*x</small></span>
</center>
</form>
<div id="teste2">
<form id="form3" name="form3" method="post" action="#">
<input type="button" onclick="ver()" value="x">
<div id="lol1" style="display: none;"></div>
</form>
</div>
<br/><br/><br/>
<center>
<div>
<form id="form4" name="form4" method="post" action="#">
<div id="lol" style="display: none;"></div>
</form>
</div>
</center>
I know the tag <center>
was discontinued and according to references, the correct now would be to use the attribute css
text-align:center;
but even so I cannot reproduce the same effect, see the example below:
.table {
max-width: 500px;
border-collapse: collapse;
font-size: 12;
width: 320px;
text-align: center;
box-shadow: 2px 2px 2px 2px #aaa;
}
.table tr td{
padding: 8px 8px 8px 8px;
}
.campo {
border: 1px double black;
}
#teste {
overflow: auto;
max-height: 500px;
max-width: 18ç0px;
position:absolute;
z-index:999;
left:0%;
top:0%;
background-color:#fff;
border:1px solid #000;
padding:6px;
}
#teste2 {
overflow: auto;
max-height: 500px;
max-width: 300px;
position:absolute;
z-index:999;
right:0%;
top:0%;
background-color:#fff;
border:1px solid #000;
padding:6px;
}
<div id="teste">
<form id="form1" name="form1" method="post" action="#">
<input type="button" onclick="ver()" value="x">
<div id="div1" style="display: none;"></div>
</form>
</div>
<div style='text-align:center;'>
<h1>x</h1>
<form id="form2" name="form2" method="post" action="#">
<table class="table">
<tr>
<td class="campo">
<span id="inf1">*x</span><br/>
<input type="text" id="txt" name="txt" size="2"/><br/>
<span id="inf2">x?</span><br/>
<input type="text" id="txt2" name="txt2" size="2"/><br/>
x?
<input type="checkbox" id="ckb" name="ckb" /><br/><br/>
<input type="button" value="x" onclick="setaInf();">
</td>
</tr>
</table>
<br/>
<span id="inf3"><small>*x</small></span>
</form>
</div>
<div id="teste2">
<form id="form3" name="form3" method="post" action="#">
<input type="button" onclick="ver()" value="x">
<div id="lol1" style="display: none;"></div>
</form>
</div>
<br/><br/><br/><br/><br/><br/>
<div style='text-align:center;'>
<form id="form4" name="form4" method="post" action="#">
<div id="lol" style="display: none;"></div>
</form>
</div>
How do I center the two div´s
of the first example without having to use the tag <center>
?
Associated: http://answall.com/questions/32276/discontinues%C3%A7%C3%A3o-da-tag-center/32278#32278
– MarceloBoni
remove the <center> tags and add the css in body, body{ text-align:center; }.. There are other ways to solve as well. It doesn’t mean that this is the only solution or the best solution.
– Daniel Omine