How to adjust the width in the background-color in ccs

Asked

Viewed 270 times

0

I’m having trouble adjusting the background-color of a table using css so that the background is all black and still on a margin to the sides, up and down. Width can be adjusted with width:

#tabela{
width: 38%;
margin: auto;  
background-color: black;
}

However height I cannot with height.

  • 1

    Dude, it’s not clear what you need... do you have an image of Layout? You want to change the height of the table as a whole or just the background... it’s kind of meaningless what you want to do

1 answer

2


Try to use the vh, may be that you are setting a value in px or % of height but he’s applying on his elemento pai, for this reason does not apply the expected height for you.

The measure vh is equal to 1/100 of the height of viewport. So, for example, if the browser height is 900px, 1vh amounts to 9px.

Following example:

<style>
#tabela{
width: 38%;
margin: auto;
height: 100vh;
background-color: #ccc;
}
</style>

<div id="tabela">tabela</div>

References: https://desenvolvimentoparaweb.com/css/unidades-css-rem-vh-vw-vmin-vmax-ex-ch/

Browser other questions tagged

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