Skip to content Skip to sidebar Skip to footer

Element With Multiple Lines Of Text, How Can I Overflow Them Upwards?

http://jsbin.com/dodiha/1/edit?html,css,js,output So basically I have a 'log' element that shows recent messages. By default, it is collapsed and only 1 line-height high. You can

Solution 1:

Here's a simple way with minimal code change

Demo http://jsfiddle.net/zwvgfkjo/

HTML:

  <div id="log">
    <div class="wrapper">
    </div>
  </div>
  <button id="add">Add Entry</button>

CSS:

.wrapper {
    position: absolute;
    left: 0;
    bottom: 0;
}

#log {
  position: absolute;
  bottom: 100px;
  left: 5px; right: 5px;
  background-color: lightgray;
  height: 30px;
  line-height: 30px;
  font-size: 20px;
  padding-left: 10px;
  overflow: hidden;
  float: bottom;
}

JS:

function log(m) {
  $('#log .wrapper').append('<div>' + m + '</div>');
}

$("#add").on('click',function() {
  log("New Entry Added...")
})

$('#log').hover(
  function() {
    $('#log').animate({"height":"200px"})
  },
  function() {
    $('#log').animate({"height":"30px"})
  }
)

$(document).ready(function() {
  log('Document Ready.')

})

Solution 2:

Try this:

<div id="log-wrapper">
  <div id="log"></div>
</div>
#log {
  position: absolute;
  bottom: 0;
}

function log(m) {
  $('#log').append('<div>' + m + '</div>')
}
  
$("#add").on('click',function() {
  log("New Entry Added...")
})

$('#log-wrapper').hover(
  function() {
        $('#log-wrapper').animate({"height":"200px"})
  },
  function() {
    $('#log-wrapper').animate({"height":"30px"})
  }
)

$(document).ready(function() {
  log('Document Ready.')
  
})
#log-wrapper {
  position: absolute;
  bottom: 100px;
  left: 5px; right: 5px;
  background-color: lightgray;
  height: 30px;
  line-height: 30px;
  font-size: 20px;
  padding-left: 10px;
  overflow: hidden;
  float: bottom;
}
#log {
  position: absolute;
  bottom: 0;
}
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<div id="log-wrapper">
  <div id="log"></div>
</div>
<button id="add" type="button">Add Entry</button>

Post a Comment for "Element With Multiple Lines Of Text, How Can I Overflow Them Upwards?"