mardi 19 janvier 2016

Adjust height of a div absolutely positioned according to content

I have a div with position: absolute, and many more divs inside of it. I'm trying to adjust this div's height to the content it has inside, but its height is not increasing. What can I do to adjust its height automatically according to its content?

My HTML:

body
div(id="contentAcerca")
  div(id="imagenEquipo")
    div(id="descripcionPlataforma")
        p(id="tituloPlataforma") PERSPECTIVA A4
        p(id="textoPlataforma") Lorem Ipsum is simply dummy text of the printing and typesetting industry.

CSS:

#contentAcerca {                
z-index: -1;
position: absolute;
left: 7.5%;
top: 25%;
min-height: 65%;
width: 85%;
background: white;
border-radius: 3px;
border: 0;
outline: 0;
-webkit-box-shadow: 0 0 10px #aeaeae;
-moz-box-shadow: 0 0 10px #aeaeae;
box-shadow: 0 0 10px #aeaeae;
}

#imagenEquipo {
position: absolute;
top: 5%;
width: 95%;
height: 100%;
background-image: url("../images/acerca/equipo.jpg");
background-size: cover;
background-repeat: no-repeat;
left: 2.5%;
}

#descripcionPlataforma {
    position: absolute;
    width: 100%;
    background-color: #808080;
    border-radius: 5px;
    top: 100%;
}

#tituloPlataforma {
    position: relative;
    left: 2.5%;
    color: rgba(235, 81, 77, 1);
    font-size: 2vw;
}

#textoPlataforma {
    position: relative;
    left: 2.5%;
    color: white;
}

And finally this is what I'm getting:

Layout with current CSS

But this is what I need:

Layout I'm looking for

As you can see, the containing div (the one with the white background) is bigger, because of the image and the div with gray background.

Many Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire