[My question differs from the suggested duplicate because of the presence of padding in my animated div]
Trying to get a div to expand, without having fixed heights and with some padding. My css is below and I toggle .closed in and out using jquery.
.slide {
  padding: 10%;
  background-color: gold;
  overflow-y: hidden;
  transition: height 2s;
  transition: max-height 2s;
  height: auto;
  max-height: 1000px;
}
.closed {
  height: 0;
  max-height: 0;
}
The issue is that with the padding you can't hide the text to start with, and without a fixed height you don't get a transitioned css change. Can anyone help - hope I don't need to do more with javascript?
Update I've now got to:
.slide {
  padding: 10%;
  background-color: gold;
  overflow-y: hidden;
  transition: max-height 2s ease;
  max-height: 500px;
}
.closed {
  max-height: 0;
  padding: 0;
  transition: all 2s ease;
}
See plnkr. The problem now is the padding on closing. In the case above it transitions out, and if i limit the transition in .closed to max-height then there is a jarring effect as it collapses just as the animation starts.
 
     
    