Css in inputs using Affordance principles

6

To facilitate the development of responsive forms it is very common to place 100% of width in the inputs, and to control its size through the width of a container div, this technique helps when manipulating the media queries of these inputs. This can be a problem when we have labels larger than the input data for example. The most common way to do this is as html below.

<!-- html-->
<div class="form-control classe-controladora">
    <label>Endereço</label>
    <input type="text">
</div>

<!-- css-->
label, input{
  display: block;
  width: 100%;
}    
.classe-controladora{
  width: 30%;
}

But following the affordance principles, an input must have the optimal width for the data that can be entered. If the maximum is 10 characters, it should be 10 characters long. So what are the best way to handle the width of inputs, using the size attribute? using css?

I think that at first, the controlling class should perhaps manipulate only the input, the problem would be in a very large system where the variation of widths would be difficult to maintain (especially if we treat the responsive)

 .classe-controladora input{
     width: 30%
 }

- Edit -

Doubt here is how it would be possible to balance these concepts, because if we choose only the easiest, affordance is impaired. If we make all the custom inputs for your content, maintenance would be very complicated.

    
asked by anonymous 30.03.2017 / 21:50

1 answer

1

I think you need to balance the concepts of affordance , responsiveness, economy (avoid unnecessary code), and scalability (in code maintenance and expansion).

You should prioritize things and if necessary, stretch the rules to achieve this balance.

I'm always looking for standards and methodologies that improve development, debugging, maintenance, but by adopting, I'm careful not to limit myself to the standard when it hurts the user experience.

Taking the example you gave, even if a field has a maximum number of characters, if it is among others with different lengths and the programmer insists on limiting the size of the fields accordingly, it will end up with an uneven interface. Is it worth it?

Finally, if it were to do, it would give preference to the CSS, since it would facilitate maintenance and reuse of code.

    
15.04.2017 / 18:58