edge an object that doesn’t exist

Asked

Viewed 38 times

1

Hello!

I’d like to put an edge on my counter. The problem is that my counter is based on the case numbers of json, so the numbers in html do not exist.

Is there any way to edge the div that has no content?

document.getElementById("contadorprincipal").innerHTML = arrayResultados.length;
.contadorprincipalcapa {
    color: white;
    font-size: 15px;
    margin: 10px;
}
<div class="contadorprincipalcapa">
    <div id="contadorprincipal"></div>
</div>

  • You need to add content, padding or set a fixed/minimum size to the div

1 answer

2


You need to add a content, a padding or set a fixed/minimum size to the div. In this case I added a height minimum:

document.getElementById("contadorprincipal").innerHTML = "50" //arrayResultados.length;
.contadorprincipalcapa {
    color: white;
    font-size: 15px;
    margin: 10px;
    min-height: 1em; /* 2em = 2 vezes o tamanho da fonte */
    border: 1px solid #000;
    background: #000
}
<div class="contadorprincipalcapa">
    <div id="contadorprincipal"></div>
</div>

  • worked as soon as it works out I mark as right

Browser other questions tagged

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