How to use desired CSS file property

Asked

Viewed 49 times

0

the SELECT element is "taking" the height property of a file. css . But Inputs "use" this same property of another css file ( which is the ideal file). And with this the height of the SELECT is smaller than the text inserted in the component : In the image the item 1 , SELECT is below the height of the letter ( is cutting the text ) Item 2 is SELECT - class form-control Item 3 shows that the height property is not being used there in the css file Item 4 shows where the height property is being searched. When I uncheck the height of item 4, then the component gets the height OK. How do I use the height property of the correct css file? And why does this happen ? inserir a descrição da imagem aqui

2 answers

3


This happens due to hierarchical level of CSS you see in this link

You may be prioritizing heigth by using the tag: important so it will catch the most Important for the code

ex:

.form-contro{
   heigth: 100px !important;
}
  • Dbaalone , Thank you ! Can you tell me why only the SELECT element was "using" the property of another file ? The inputs used the correct file.

  • So they come with presets of HTML5 & CSS3 understand? ai it adopts some forms, as for example, when you start a file/ project, it is nomal you reset the padding and the margin understood?

  • If my answer has helped or solved, could confirm and paste as solved the problem...

  • Yes, Dbaalone, solved and I had marked that "V' to the left ...blz. Thank you

1

Your select does not have the attribute size (:not[size]), nor the attribute multiple (:not[Multiple]), so it picks up the unwanted height.

If you put in your select any one of those attributes size and multiple the unwanted CSS rule is no longer applied, and it returns to the default height of the form-control

But notice that your select has a ID already. And any CSS declared in ID has preference, so an easy way to solve this is by putting the height on the ID for example. See a practical example to understand.

#teste {
	border: 1px solid #00f;
}
select.oi:not([xxx]):not([sss]) {
	border: 1px solid #f00;
}
pega a cor do ID<br>
<select name="" id="teste" class="oi">
	<option value="123">123</option>
</select>
<br>
é zzz é xxx não pega o css<br>
<select name="" zzz xxx class="oi">
	<option value="123">123</option>
</select>
<br>
Não é zzz nem xxx então fica vermelho<br>
<select name="" class="oi">
	<option value="123">123</option>
</select>

OBS: ! Important is to push the dirt under the tape, remember that now everything that uses the class that has ! You can’t change anymore... it can give you a lot of headache if you don’t know what you’re doing

  • hugocsl, so if I put the property in question ( height ) : <select class="form-control" id="typousuario" height> it will fetch the correct css file property, ok ?

  • @Rogeriorios looks at the practical example I put in the reply, and read the Link that the colleague quoted in the other answer that you will understand better because he is getting the style of . CSS "wrong". I particularly do not recommend using ! Mportant, only last That same, because using it you create a rule so strong that you can not change after, besides it will be worth for all elements that I had class .form-control, including some other that you have already changed the time

  • I removed the ! Port , put the height property inside : <select class="form-control" id="type" height> . It didn’t work. I’m testing the options that partners are posting.

  • @Rogeriorios to use height right on the tab you have to put on the tag style="height: 2.5rem" for example and not simply write height in tag

  • Ok...hugocsl, but putting the property directly in the tag and not in the css file is indicated ? ( I am a back-end programmer and this front-end has to study maaaaaisssss rs )

  • @Rogeriorios no, it is not very indicated puts CSS style directly in the tag, I do not recommend. Unless when publishing the project you have some kind of webpack that takes your file. css and transfer the properties directly to html tags. This better the performance of the request, page loading etc. But this is only for production, in development do not recommend.

  • #tipousuario{ height: auto ! Important; } as the colleague above mentioned, it worked , but it is very restricted, right ?

  • @Tutorials like you are putting the CSS using the id vc not even need the ! Mportant, probably if you just let #tipousuario{ height: auto; } will be enough.

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.