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
Demohttp://jsfiddle.net/zwvgfkjo/
HTML:
<divid="log"><divclass="wrapper"></div></div><buttonid="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:
functionlog(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:
<divid="log-wrapper"><divid="log"></div></div>
#log {
position: absolute;
bottom: 0;
}
functionlog(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;
}
<scriptsrc="//code.jquery.com/jquery-2.1.1.min.js"></script><divid="log-wrapper"><divid="log"></div></div><buttonid="add"type="button">Add Entry</button>
Post a Comment for "Element With Multiple Lines Of Text, How Can I Overflow Them Upwards?"