Bug, padding go overflow in inline-flex+block+flex+block container? - html

I found strange case. when I use html like that :
<div class="card" style="display:inline-flex; overflow:hidden;">
<div style="display: block; width:10em; height: 5em;">
<div style="display:flex;">
<!-- here -->
<div style="padding-bottom: 10em;"></div>
</div>
</div>
</div>
The div padding-bottom:10em push out others div.card blow the div.card like the padding is some invisible part of the div.card
When I change the internal flex div to block div the bug disapear
It look like the internal flex as it own layout that breach out from the blok and the outer inline-flex
How I prevent that, and make the div with the padding cut out like normal content into overflow hidden element.
It can be I found new bug in chrome flex model ?
Live example :
https://uvzoo.csb.app/
Codesendbox: https://codesandbox.io/s/zen-engelbart-uvzoo
div {
outline: 1px solid pink;
padding: 0.5em;
margin: 0.3em;
}
<div style="display: block; width:30em; height: 40em; padding: 1em;">
<!-- block card -->
<div style="display:inline-flex; overflow:hidden;">
<div style="display: block; width:10em; height: 5em;">
<div style="display:flex;">
<div style="padding-bottom: 10em;"></div>
</div>
</div>
</div>
<!-- end block card -->
<!-- block card -->
<div style="display:inline-flex; overflow:hidden;">
<div style="display: block; width:10em; height: 5em;">
<div style="display:flex;">
<div style="padding-bottom: 10em;"></div>
</div>
</div>
</div>
<!-- end block card -->
<!-- block card -->
<div style="display:inline-flex; overflow:hidden;">
<div style="display: block; width:10em; height: 5em;">
<div style="display:flex;">
<div style="padding-bottom: 10em;"></div>
</div>
</div>
</div>
<!-- end block card -->
<!-- block card -->
<div style="display:inline-flex; overflow:hidden;">
<div style="display: block; width:10em; height: 5em;">
<div style="display:flex;">
<div style="padding-bottom: 10em;"></div>
</div>
</div>
</div>
<!-- end block card -->
<!-- block card -->
<div style="display:inline-flex; overflow:hidden;">
<div style="display: block; width:10em; height: 5em;">
<div style="display:flex;">
<div style="padding-bottom: 10em;"></div>
</div>
</div>
</div>
<!-- end block card -->
</div>

Adding vertical-align:top fixes the issue. I don't know exactly why but it seems there is a complex calculation that is affecting the baseline calculation of each box making it outside and far from the bottom. Since baseline is the default alignment, you are getting this strange result
div {
outline: 1px solid pink;
padding: 0.5em;
}
.box {
display: inline-flex;
vertical-align:top;
overflow: hidden;
}
.box>div {
display: block;
width: 10em;
height: 5em;
}
.box>div>div {
display: flex;
}
.box>div>div>div {
padding-bottom: 10em;
}
<div style="display: block; width:30em; height: 40em; padding: 1em;">
<!-- block card -->
<div class="box">
<div>
<div>
<div></div>
</div>
</div>
</div>
<div class="box">
<div>
<div>
<div></div>
</div>
</div>
</div>
<div class="box">
<div>
<div>
<div></div>
</div>
</div>
</div>
<div class="box">
<div>
<div>
<div></div>
</div>
</div>
</div>
</div>
If we add some text we can notice this:
div {
outline: 1px solid pink;
padding: 0.5em;
}
.box {
display: inline-flex;
overflow: hidden;
}
.box>div {
display: block;
width: 10em;
height: 5em;
}
.box>div>div {
display: flex;
}
.box>div>div>div {
padding-bottom: 10em;
}
<div style="display: block; padding: 1em;">
<!-- block card -->
<div class="box">
<div>
<div>
<div></div>
</div>
</div>
</div> some text here
<div class="box">
<div>
<div>
<div></div>
</div>
</div>
</div>
<div class="box">
<div>
<div>
<div></div>
</div>
</div>
</div>
</div> some text here
<div class="box">
<div>
<div>
<div></div>
</div>
</div>
</div>
</div>

Related

how to position elements one to left and other right one below the other- CSS

I am trying to position the following elements one below the other , but one to the left and other to the right:
my code:
here is the fiddle: https://jsfiddle.net/ak9hxfpt/2/
I want to position the test2 to the right of the test1 div, but it should appear below the test1 div
What I want to achieve is something like: https://jsfiddle.net/ak9hxfpt/3/
however this works only for one div, if I try float: right for all the divs I have this is what I get which is not working out for me:
https://jsfiddle.net/ak9hxfpt/4/
the every "remove link" content should appear below every "some content".
any ideas on how this can be achieved
.test2 {
margin-bottom: 30px;
}
.test1 {
border: 1px solid #000;
margin-bottom: 10px;
width: 93%;
}
<div class="test2">
remove link
</div>
</div>
<div class="test">
<div class="test1">
some content
</div>
<div class="test2">
remove link
</div>
</div>
<div class="test">
<div class="test1">
some content
</div>
<div class="test2">
remove link
</div>
</div>
just add some margin-left
.test2 {
margin-bottom: 30px;
margin-left:80%;
}
.test1 {
border: 1px solid #000;
margin-bottom: 10px;
width: 93%;
}
<div class="test2">
remove link
</div>
<div class="test">
<div class="test1">
some content
</div>
<div class="test2">
remove link
</div>
</div>
<div class="test">
<div class="test1">
some content
</div>
<div class="test2">
remove link
</div>
</div>
or
.test2 {
margin-bottom: 30px;
width:93%;
text-align:right;
}
.test1 {
border: 1px solid #000;
margin-bottom: 10px;
width: 93%;
}
<div class="test">
<div class="test1">
some content
</div>
<div class="test2">
remove link
</div>
</div>
<div class="test">
<div class="test1">
some content
</div>
<div class="test2">
remove link
</div>
</div>
I would try nesting your code in a container and use display: flex; with flex-direction: column;
.test2 {
float: right;
}
.test1 {
border: 1px solid #000;
margin-bottom: 10px;
width: 93%;
}
.container {
display: flex;
flex-direction: column;
}
<div class="container">
<div class="test">
<div class="test1">
some content
</div>
<div class="test2">
remove link
</div>
</div>
<div class="test">
<div class="test1">
some content
</div>
<div class="test2">
remove link
</div>
</div>
<div class="test">
<div class="test1">
some content
</div>
<div class="test2">
remove link
</div>
</div>
<div class="test">
<div class="test1">
some content
</div>
<div class="test2">
remove link
</div>
</div>
<div class="test">
<div class="test1">
some content
</div>
<div class="test2">
remove link
</div>
</div>
</div>
Another option would be to set display: flex; on test right a flex-direction: row; then you can can set test2 to width: 7%; while test still takes up 93%. Finally, you can space them by adding gap Check the snippet below.
.test2 {
width: 7%;
}
.test1 {
border: 1px solid #000;
margin-bottom: 10px;
width: 93%;
}
.test {
display: flex;
flex-direction: row;
width: 100%;
gap: 10px;
}
<div class="test">
<div class="test1">
some content
</div>
<div class="test2">
remove link
</div>
</div>
<div class="test">
<div class="test1">
some content
</div>
<div class="test2">
remove link
</div>
</div>
<div class="test">
<div class="test1">
some content
</div>
<div class="test2">
remove link
</div>
</div>
<div class="test">
<div class="test1">
some content
</div>
<div class="test2">
remove link
</div>
</div>
<div class="test">
<div class="test1">
some content
</div>
<div class="test2">
remove link
</div>
</div>
Just add display: flex; justify-content: flex-end to your test2 class and it will work.enter image description here

display: flex not working in CSS

In my template
<div class="summary-card">
<div ng-repeat="cardData in summaryCardsCtrl.summaryDetails">
<div ng-switch ="cardData.uniqueCardsDataFlag">
<div ng-switch-when=true>
<div style="background-color: red; width:170px; height: 50px;">
1111111
</div>
</div>
<div ng-switch-default>
<div class="cool-grid">
<div style="background-color: blue; width:170px; height: 50px;">
222222
</div>
</div>
</div>
</div>
</div>
</div>
ng-switch will be true only once; hence the red div will be only one and the rest will be blue.
CSS looks like:
div.summary-card {
display: inline-block;
margin: 5px 10px 15px 0px;
display: flex;
}
.cool-grid {
display: flex;
flex-wrap: wrap;
border: 1px solid black;
}
Now, they all stack up on top of each other.
But I want them to show like:
I am not sure how to give classes inside such a ng-repeat to make them look like this.
so that only the blue divs inside ng-switch-default wraps around each other and not around the red div.
Please help.
UPDATE
Rendered HTML looks like:
<div class="summary-card">
<!----><div ng-repeat="cardData in summaryCardsCtrl.summaryDetails">
<div ng-switch="cardData.uniqueCardsDataFlag">
<!----><div ng-switch-when="true">
<!-- <div ng-include="'......'"></div> -->
<div style="background-color: red; width:170px; height: 50px;">
1111111
</div>
</div><!---->
<!---->
</div>
</div><!----><div ng-repeat="cardData in summaryCardsCtrl.summaryDetails">
<div ng-switch="cardData.uniqueCardsDataFlag">
<!---->
<!----><div class="cool-grid" ng-switch-default="">
<!-- <div ng-include="'.....'"></div> -->
<div style="background-color: blue; width:170px; height: 50px;">
222222
</div>
</div><!---->
</div>
</div><!----><div ng-repeat="cardData in summaryCardsCtrl.summaryDetails">
<div ng-switch="cardData.uniqueCardsDataFlag">
<!---->
<!----><div class="cool-grid" ng-switch-default="">
<!-- <div ng-include="'.....'"></div> -->
<div style="background-color: blue; width:170px; height: 50px;">
222222
</div>
</div><!---->
</div>
</div><!----><div ng-repeat="cardData in summaryCardsCtrl.summaryDetails">
<div ng-switch="cardData.uniqueCardsDataFlag">
<!---->
<!----><div class="cool-grid" ng-switch-default="">
<!-- <div ng-include="'......'"></div> -->
<div style="background-color: blue; width:170px; height: 50px;">
222222
</div>
</div><!---->
</div>
</div><!---->
</div>
I've knocked up a simplified version that I think does what you're after.
The outer div needs flex-wrap:wrap, the red one needs to have its flex-basis set at 100%. The blue ones will then wrap to the next column and be laid out out according to whatever rules you give them...
#outer{
height:200px;
border:1px solid grey;
display:flex;
flex-direction:column;
flex-wrap:wrap;
justify-content:space-between;
width:500px;
}
#red{
background-color:red;
width:100px;
flex-basis:100%;
}
.blue{
flex-basis:25%;
width:100px;
background-color:blue;
}
codepen here
Simply use the bootstrap grid to get the layout you want. You do not have to use display flex for that.
Below is an example fot the layout using bootstrap grid
.row {
background: #f8f9fa;
}
.col {
border: solid 1px #6c757d;
}
.red{
background-color:red;
padding: 10px;
margin: 10px;
height: 120px;
}
.blue{
background-color: blue;
padding: 10px;
margin: 10px;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col-md-6" class="">
<div class="red">
sd
</div>
</div>
<div class="col-md-6">
<div class="row">
<div class="col-md-6">
<div class="blue">
sd
</div>
</div>
<div class="col-md-6">
<div class="blue">
sd
</div>
</div>
<div class="col-md-6">
<div class="blue">
sd
</div>
</div>
</div>
</div>
</div>
</div>
Check this layout. I have used flex for generating it
U can change the height of red block accordingly
Also the blue blocks will wrap automatically to next row, when it doesn't get enough width on the same line
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.summary-card {
display: flex;
flex-direction: row;
}
.left-sec,
.right-sec {
flex: 1;
display: flex;
}
.right-sec {
flex: 1;
display: flex;
flex-wrap: wrap;
}
<div class="summary-card">
<div class="left-sec">
<!---->
<div ng-repeat="cardData in summaryCardsCtrl.summaryDetails">
<div ng-switch="cardData.uniqueCardsDataFlag">
<!---->
<div ng-switch-when="true">
<!-- <div ng-include="'......'"></div> -->
<div style="background-color: red; width:170px; height: 50px;">
1111111
</div>
</div>
<!---->
<!---->
</div>
</div>
<!---->
</div>
<div class="right-sec">
<div ng-repeat="cardData in summaryCardsCtrl.summaryDetails">
<div ng-switch="cardData.uniqueCardsDataFlag">
<!---->
<!---->
<div class="cool-grid" ng-switch-default="">
<!-- <div ng-include="'.....'"></div> -->
<div style="background-color: blue; width:170px; height: 50px;">
222222
</div>
</div>
<!---->
</div>
</div>
<!---->
<div ng-repeat="cardData in summaryCardsCtrl.summaryDetails">
<div ng-switch="cardData.uniqueCardsDataFlag">
<!---->
<!---->
<div class="cool-grid" ng-switch-default="">
<!-- <div ng-include="'.....'"></div> -->
<div style="background-color: blue; width:170px; height: 50px;">
222222
</div>
</div>
<!---->
</div>
</div>
<!---->
<div ng-repeat="cardData in summaryCardsCtrl.summaryDetails">
<div ng-switch="cardData.uniqueCardsDataFlag">
<!---->
<!---->
<div class="cool-grid" ng-switch-default="">
<!-- <div ng-include="'......'"></div> -->
<div style="background-color: blue; width:170px; height: 50px;">
222222
</div>
</div>
<!---->
</div>
</div>
</div>
<!---->
</div>

why am I not able to see the margin property in my html page?

I am trying to design something but even on adding the margin property I am not able to see the changes.
Below is my html code.
.side {
background-color: teal;
display: inline;
padding: 7px;
margin-top: 20px;
}
<div>
<span>Task Managment To-do list</span>
</div>
<div class="row">
<div class="col s3 offset-s1">
<header class="side" id="day">Date Section</header>
</div>
<div class="col s2 offset-s3">
<header class="side">
Navigations
</header>
</div>
</div>
Use display: inline-block; instead of just display: inline;, because margin-top and margin-bottom does not work with inline elements
.side {
background-color: teal;
display: inline-block;
padding: 7px;
margin-top: 20px;
}
<div>
<span>Task Managment To-do list</span>
</div>
<div class="row">
<div class="col s3 offset-s1">
<header class="side" id="day">Date Section</header>
</div>
<div class="col s2 offset-s3">
<header class="side">
Navigations
</header>
</div>
</div>
You could either try this or change inline to block or inline-block
.side {
background-color: teal;
display: inline;
padding: 7px;
line-height: 400%;
}
<div>
<span>Task Managment To-do list</span>
</div>
<div class="row">
<div class="col s3 offset-s1">
<header class="side" id="day">Date Section</header>
</div>
<div class="col s2 offset-s3">
<header class="side">
Navigations
</header>
</div>
</div>

Vertical align text in a Div with respect to Rows

I am trying to align the text "address" in left div vertically. But i am unable to.
Here is the code,
div.row {
border: 1px solid black;
padding: 10px;
}
.centre {
display: block;
text-align: center;
vertical-align: middle;
background: yellow;
height: 100%;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row">
<div class="col-md-3 centre">
<label>Address</label>
</div>
<div class="col-md-6">
<div class="row">
<!--nested row one-->
<div class="col-md-6">
<label>Street</label>
</div>
<div class="col-md-6">
<input name="stname">
</div>
</div>
<div class="row">
<!--nested row two-->
<div class="col-md-6">
<label>Landmark</label>
</div>
<div class="col-md-6">
<input name="lmark">
</div>
</div>
<div class="row">
<!--nested row three-->
<div class="col-md-6">
<label>Zip code</label>
</div>
<div class="col-md-6">
<input name="zipcode">
</div>
</div>
</div>
</div>
<!--row end-->
</div>
What am i doing wrong. I am using bootsrap 3.
Plunker: https://plnkr.co/edit/cu4ZJVSp3jYTyBwz4NKB?p=preview (View Plunker in full screen)
I am trying to have result similar to this. The coloured borders are only for representation .
You are setting the styles to the center div, instead it should be the label inside the center div
<!DOCTYPE html>
<html>
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="script.js"></script>
<style>
div.row div{
border: 1px solid black;
padding: 10px;
}
.centre label{
display: block;
text-align: center;
vertical-align: middle;
background: yellow;
height: 100%;
padding:5px;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-md-3 centre">
<label>Address</label>
</div>
<div class="col-md-6">
<div class="row"><!--nested row one-->
<div class="col-md-6">
<label>Street</label>
</div>
<div class="col-md-6">
<input name="stname">
</div>
</div>
<div class="row"><!--nested row two-->
<div class="col-md-6">
<label>Landmark</label>
</div>
<div class="col-md-6">
<input name="lmark">
</div>
</div>
<div class="row"><!--nested row three-->
<div class="col-md-6">
<label>Zip code</label>
</div>
<div class="col-md-6">
<input name="zipcode">
</div>
</div>
</div>
</div><!--row end-->
</div>
</body>
</html>
you can add this code in your CSS file to get vertical-align.
but first, you have to add a new class with row class
<!DOCTYPE html>
<html>
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="script.js"></script>
<style>
.vertical > div {
display: table-cell;
vertical-align: middle;
float: none;
}
.vertical > div {
display: table-cell;
vertical-align: middle;
float: none;
}
div.row div{
border: 1px solid black;
padding: 10px;
}
.centre label{
display: block;
text-align: center;
vertical-align: middle;
background: yellow;
height: 100%;
padding:5px;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="row vertical">
<div class="col-md-3 centre">
<label>Address</label>
</div>
<div class="col-md-6">
<div class="row"><!--nested row one-->
<div class="col-md-6">
<label>Street</label>
</div>
<div class="col-md-6">
<input name="stname">
</div>
</div>
<div class="row"><!--nested row two-->
<div class="col-md-6">
<label>Landmark</label>
</div>
<div class="col-md-6">
<input name="lmark">
</div>
</div>
<div class="row"><!--nested row three-->
<div class="col-md-6">
<label>Zip code</label>
</div>
<div class="col-md-6">
<input name="zipcode">
</div>
</div>
</div>
</div><!--row end-->
</div>
</body>
</html>
Here's a solution setting top margin/padding on columns not nested then cancelling top margin/padding in nested ones:
Plunkr
Relevant CSS:
[class*="col-"] {
border: 1px solid black;
padding: 10px;
}
.row:first-child [class*="col-"] {
margin-top: 10px;
background-color: lightgreen;
}
.row .row:first-child [class*="col-"] {
margin-top: -10px;
background-color: pink;
}
.row .row:not(:first-child) [class*="col-"] {
margin-top: 0;
background-color: lightblue;
}
Solution by #codegeek which avoids these problems is better imho :)
Code Pen
You can remove the offset and match it up to 12-grid system.
div.row {
border: 1px solid black;
padding: 10px;
}
.centre {
background: yellow;
top: 60px;
border: 1px solid blue;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-xs-3 centre">
<label>Address</label>
</div>
<div class="col-xs-8 col-sm-offset-1" style="border:1px solid green">
<!--You can remove style and remove offset and change it to sm-9 -->
<div class="row">
<!--nested row one-->
<div class="col-xs-6">
<label>Street</label>
</div>
<div class="col-xs-6">
<input name="stname">
</div>
</div>
<div class="row">
<!--nested row two-->
<div class="col-xs-6">
<label>Landmark</label>
</div>
<div class="col-xs-6">
<input name="lmark">
</div>
</div>
<div class="row">
<!--nested row three-->
<div class="col-xs-6">
<label>Zip code</label>
</div>
<div class="col-xs-6">
<input name="zipcode">
</div>
</div>
</div>
</div>
<!--row end-->
</div>
As for now, margin-top is a worth option trying.
I positioned the left div by using top: 50%(takes the height of the parent) and then using translateY, which takes the height of the current element.
Since relative positioning didnt take % values, I have used absolute.
But giving absolute makes the div come out of the document flow, hence used "left" for the right sibling with the width of the left sibling.
.parent{
position: relative;
}
.centre{
background: yellow;
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.right{
left: 25%;
/* width of left sibling, since col-md-3 is 25%*/
background: lightgreen;
}
Plnkr Link(with bootstrap) or JsFiddle (without Bootstrap)
Result:
Your vertical-align:middle doesn't work, because elements with display: block cannot be centered that way. An easy alternative would be to use display: flex.
Here is a snippet to demonstrate the way display:flex can be used to center pretty much everything:
div.row div{
border: 1px solid black;
padding: 10px;
}
.centre{
display: block;
text-align: center;
vertical-align: middle;
background: yellow;
height: 100%;
}
.flex {
display: flex;
align-items: center;
}
<div class="container-fluid">
<div class="row">
<div class="flex">
<div class="col-md-3 centre">
<label>Address</label>
</div>
<div class="col-md-6">
<div class="row"><!--nested row one-->
<div class="col-md-6">
<label>Street</label>
</div>
<div class="col-md-6">
<input name="stname">
</div>
</div>
<div class="row"><!--nested row two-->
<div class="col-md-6">
<label>Landmark</label>
</div>
<div class="col-md-6">
<input name="lmark">
</div>
</div>
<div class="row"><!--nested row three-->
<div class="col-md-6">
<label>Zip code</label>
</div>
<div class="col-md-6">
<input name="zipcode">
</div>
</div>
</div>
</div>
</div><!--row end-->
</div>
EDIT: maybe this guide might be of interest for you:
Centering in CSS: A Complete Guide

Can't align latest messages to the bottom

I have to create an IRC-like web chat (latest messages have to appear at the bottom of the parent container).
Here's my (unsuccessful) attempt:
.inner-conversation-container {
height: 100px;
position: relative;
overflow: hidden;
width: 500px;
}
.conversation-stream-container {
max-height: 100px;
position: absolute;
bottom: 0;
overflow: auto;
width: 100%;
}
<div class='inner-conversation-container'>
<div class='conversation-stream-container'>
<div class='conversation-item'>
<div class='conversation-message-part' msg-id='137'>
<div class='center-part'>Content</div>
</div>
<div class='conversation-message-part' msg-id='138'>
<div class='center-part'>Content</div>
</div>
<div class='conversation-message-part' msg-id='139'>
<div class='center-part'>Content</div>
</div>
<div class='conversation-message-part' msg-id='140'>
<div class='center-part'>Content</div>
</div>
<div class='conversation-message-part' msg-id='141'>
<div class='center-part'>Content</div>
</div>
<div class='conversation-message-part' msg-id='142'>
<div class='center-part'>Content</div>
</div>
<div class='conversation-message-part' msg-id='143'>
<div class='center-part'>Content</div>
</div>
<div class='conversation-message-part' msg-id='144'>
<div class='center-part'>The latest message that needs to be in the bottom</div>
</div>
</div>
</div>
</div>
The div with msg-id="144" needs to be visible and aligned to the bottom.
jQuery aided solution
Using your HTML mark-up:
<div class='inner-conversation-container'>
<div class='conversation-stream-container'>
<!-- A single item -->
<div class='conversation-item'>
<!-- Message parts -->
<div class='conversation-message-part' msg-id='125'>
<div class='center-part'>test 9</div>
</div>
...
<div class='conversation-message-part' msg-id='143'>
<div class='center-part'>no, it's not</div>
</div>
<div class='conversation-message-part' msg-id='144'>
<div class='center-part'>latest needs to be in the bottom</div>
</div>
</div>
</div>
</div>
you can simplify your CSS as follows:
.inner-conversation-container {
height: 200px;
width: 500px;
border: 2px solid lightgray; /* for demo only */
overflow: auto;
}
.conversation-stream-container {
background-color: yellow; /* for demo only */
}
and set the scroll bar position using jQuery:
$('.inner-conversation-container').scrollTop(
$('.inner-conversation-container')[0].scrollHeight
);
Demo fiddle: http://jsfiddle.net/audetwebdesign/FW6Y5/