Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Space in form element

Tags:

html

I'm trying to get rid of the space between the period dates and the guets field, tried everything with border, padding, also tried floating the fields but didn't work.

here is the code

<html>
<head>
    <link rel="stylesheet" href="css/style.css" />
</head>
<body>  
<form id="frmContact" action="/confirmacao.html" method="post">
<fieldset>
<legend>Consulta:</legend>
  <p>
    <label class="field" for="usr">Nome:&nbsp;</label>
    <input id="usr" type="text" name="nome" title="Digite seu nome" class="textbox"/>
  </p>


<p>
  <label class="field" for="usr">Period:&nbsp;</label>
  <input type="text" id="dataEntrada" name="dataEntrada" class="textbox-date"/>
    a: 
    <input type="text" id="dataSaida" name="dataSaida" class="textbox-date"/>
</p>


<p>
    <label class="field" for="hospedes">Guests:&nbsp;</label>
    <select class="textbox-option" id="hospedes" name="hospedes"> 
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
        <option value="6">6</option>
        <option value="7">7</option>
        <option value="8">8</option>
        <option value="9">9</option>
        <option value="10">10</option>  
    </select>
</p> 

<p>
    <label class="field" for="usr">E-mail:&nbsp;</label>
    <input id="email" class="textbox" name="email" title="Seu e-mail para que possamos entrar em contato"/>
</p>
<p>
    <label class="field" for="usr">Detalhes:&nbsp;</label>
    <textarea id="mensagem" name="msg" rows="6" cols="30" title="Detalhes adicionais"></textarea>
</p>
<p>
    <input type="submit" value="  Enviar  "/>
</p>
</fieldset>
</form>
</body>

and this is the css

label.field {
    text-align: right;
    width: 100px;
    float: left;
}

.textbox, .textbox-option{
    float: left;
}

.textbox {
width: 250px;
}

.textbox-date{
width: 75px;
}

fieldset p {
clear: both;
padding: 5px;
}
like image 919
Davi Trindade Avatar asked Jun 11 '26 03:06

Davi Trindade


1 Answers

In Firefox Web Developer Tools, I see 16px of margin-bottom:

enter image description here

This is being added by the browser's default stylesheet:

enter image description here

Scenarios like this is why CSS Resets are used. Alternatively, to fix this specific problem, set the margin of your your p elements in your stylesheet.

like image 94
Greg Avatar answered Jun 13 '26 18:06

Greg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!