So, my parent DIV contains 3 main DIV which contain a couple DIVs each. I have the parents li elements displayed inline as I want all 3 nested DIVs to be side by side along the width of the parent. I have been successful with getting the first two lined up correctly. The third div has the correct x-axis positioning however on the y-axis it has dropped down and outside of the parent div and I'm not sure where I am going wrong. I have tried many many different solutions on StackOverflow, however, none have had any success.
I have the right-hand div (the one below parent) set to absolute as if it's not then it does not get the correct x-axis, with absolute it gets half the position correct.
Relevant code:
.supContainer {
position: absolute;
top: 900px;
left: 38%;
width: 400px;
}
.supContainer ul {
list-style-type: none;
padding-left: 0px;
margin: 0;
}
.supContainer li {
display: inline-block;
white-space: nowrap;
margin-top: 10px;
margin-right: 10px;
}
#supp {
margin-left: 295px;
}
.leftUpper {
width: 233px;
padding-left: 47px;
}
.leftLower {
width: 233px;
padding-bottom: 10px;
}
.supMid {
float: none;
margin-right: 5px;
width: 201px;
padding-left: 238px;
}
.rightUpper {
width: 266px;
}
.rightLower {
width: 266px;
}
.wrapper .leftSide {
margin-top: 24px;
position: absolute;
width: 233px;
left: 0;
}
.wrapper .rightSide {
float: right;
position: absolute;
width: 273px;
left: 445px;
/*top:88px;*/
}
.wrapper {
width: 730px;
height: 155px;
overflow: hidden;
}
#sysit {
margin-left: 35px;
}
#comms {
margin-left: 15px;
}
#collapseExample {
width: 730px;
}
/* GLOBAL CLASSES FOR COMMON ADJUSTMENTS */
.inLine li {
/* Remember to define a width within parent */
display: inline-block;
white-space: nowrap;
}
.borderMe {
border: 2px solid black;
}
.borderMeGreen {
border: 2px solid green;
}
.borderMeRed {
border: 2px solid red;
}
.paddSingleLine {
padding-top: 15px;
padding-bottom: 15px;
}
<div class="supContainer">
<button class="btn btn-warning" id="supp" type="button" data-toggle="collapse" data-target="#collapseExample">Support</button>
<div class="collapse borderMe" id="collapseExample">
<li>
<ul>
<br/>
<div class="wrapper inLine borderMe">
<div class="leftSide">
<div class="leftUpper inLine">
<li>
<button class="btn btn-warning" type="button">Capital
<br/>Equipment</button>
</li>
<li>
<button class="btn btn-warning" type="button">Finance
<br/>Process</button>
</li>
</div>
<div class="leftLower inLine">
<li>
<button class="btn btn-warning paddSingleLine" type="button">NDA</button>
</li>
<li>
<button class="btn btn-warning" type="button">QMS
<br/>Update</button>
</li>
<li>
<button class="btn btn-warning paddSingleLine" type="button">Projects</button>
</li>
</div>
</div>
<div class="supMid">
<li>
<button class="btn btn-warning" id="sysit" type="button">Systems and IT</button>
</li>
<br/>
<li>
<button class="btn btn-warning" id="comms" type="button">Communication
<br/>Relationship/Structure</button>
</li>
<br/>
<li>
<button class="btn btn-warning" type="button">Disaster Recovery Planning</button>
</li>
</div>
<div class="rightSide borderMe">
<div class="rightUpper inLine">
<li>
<button class="btn btn-warning paddSingleLine" type="button">Admin</button>
</li>
<li>
<button class="btn btn-warning" type="button">Recruitment
<br/>/Contractors</button>
</li>
</div>
<div class="rightLower inLine">
<li>
<button class="btn btn-warning" type="button">Export
<br/>Control</button>
</li>
<li>
<button class="btn btn-warning paddSingleLine" type="button">HR Staff</button>
</li>
<li>
<button class="btn btn-warning paddSingleLine" type="button">HS and E</button>
</li>
</div>
</div>
</div>
</ul>
</li>
</div>
</div>
And a screen-grab of the output of the code:
Sorry for the sloppy code I'm new to this. If you could tell me where I've gone wrong but also why it's gone wrong and why the solution will fix it I'd be grateful as it will aid my learning.
Cheers and thanks in advance.
You are messing it up with position:absolute. Check the solution below.
Just update:
.supMid {
float: left;
margin-right: 5px;
width: 201px;
}
.wrapper .leftSide {
position: relative;
width: 233px;
float: left;
}
.wrapper .rightSide {
float: left;
position: relative;
width: 273px;
}
.wrapper {
width: 730px;
height: 155px;
overflow: hidden;
padding-top: 10px;
}
.supContainer {
position: absolute;
top: 900px;
left: 38%;
width: 400px;
}
.supContainer ul {
list-style-type: none;
padding-left: 0px;
margin: 0;
}
.supContainer li {
display: inline-block;
white-space: nowrap;
margin-top: 10px;
margin-right: 10px;
}
#supp {
margin-left: 295px;
}
.leftUpper {
width: 233px;
padding-left: 47px;
}
.leftLower {
width: 233px;
padding-bottom: 10px;
}
.supMid {
float: left;
margin-right: 5px;
width: 201px;
}
.rightUpper {
width: 266px;
}
.rightLower {
width: 266px;
}
.wrapper .leftSide {
position: relative;
width: 233px;
float: left;
}
.wrapper .rightSide {
float: left;
position: relative;
width: 273px;
}
.wrapper {
width: 730px;
height: 155px;
overflow: hidden;
padding-top: 10px;
}
#sysit {
margin-left: 35px;
}
#comms {
margin-left: 15px;
}
#collapseExample {
width: 730px;
}
/* GLOBAL CLASSES FOR COMMON ADJUSTMENTS */
.inLine li {
/* Remember to define a width within parent */
display: inline-block;
white-space: nowrap;
}
.borderMe {
border: 2px solid black;
}
.borderMeGreen {
border: 2px solid green;
}
.borderMeRed {
border: 2px solid red;
}
.paddSingleLine {
padding-top: 15px;
padding-bottom: 15px;
}
<div class="supContainer">
<button class="btn btn-warning" id="supp" type="button" data-toggle="collapse" data-target="#collapseExample">Support</button>
<div class="collapse borderMe" id="collapseExample">
<li>
<ul>
<br/>
<div class="wrapper inLine borderMe">
<div class="leftSide">
<div class="leftUpper inLine">
<li>
<button class="btn btn-warning" type="button">Capital
<br/>Equipment</button>
</li>
<li>
<button class="btn btn-warning" type="button">Finance
<br/>Process</button>
</li>
</div>
<div class="leftLower inLine">
<li>
<button class="btn btn-warning paddSingleLine" type="button">NDA</button>
</li>
<li>
<button class="btn btn-warning" type="button">QMS
<br/>Update</button>
</li>
<li>
<button class="btn btn-warning paddSingleLine" type="button">Projects</button>
</li>
</div>
</div>
<div class="supMid">
<li>
<button class="btn btn-warning" id="sysit" type="button">Systems and IT</button>
</li>
<br/>
<li>
<button class="btn btn-warning" id="comms" type="button">Communication
<br/>Relationship/Structure</button>
</li>
<br/>
<li>
<button class="btn btn-warning" type="button">Disaster Recovery Planning</button>
</li>
</div>
<div class="rightSide borderMe">
<div class="rightUpper inLine">
<li>
<button class="btn btn-warning paddSingleLine" type="button">Admin</button>
</li>
<li>
<button class="btn btn-warning" type="button">Recruitment
<br/>/Contractors</button>
</li>
</div>
<div class="rightLower inLine">
<li>
<button class="btn btn-warning" type="button">Export
<br/>Control</button>
</li>
<li>
<button class="btn btn-warning paddSingleLine" type="button">HR Staff</button>
</li>
<li>
<button class="btn btn-warning paddSingleLine" type="button">HS and E</button>
</li>
</div>
</div>
</div>
</ul>
</li>
</div>
</div>
Try this
Jsfiddle
Give .supMid property display: inline-block
.supMid{
float:none;
display: inline-block;
margin-right:5px;
width:201px;
padding-left:238px;
}
Just give vertical-align:top to .rightSide. No need of position to set element
.wrapper .rightSide {
float: right;
width: 250px;
vertical-align: top;
}
Try to change some of their properties. I used float instead of position
.wrapper .leftSide {
margin-top: 24px;
float: left;
width: 233px;
}
.supMid {
float: left;
margin-right: 5px;
width: 201px;
}
.wrapper .rightSide {
float: left;
width: 273px;
}
Related
I have a container where i store 2 div's. ".logo" and ".navbar-list" how can I move my ".navbar-list" to the right edge of container.
Previously everything worked but when I switched bootstrap to version 4.3.1 my div's overlapped .I've tried float:right but is not working.
container {
font-family: sans-serif;
height: 100%;
margin-left: auto;
margin-right: auto;
float: none;
padding: 0;
}
.logo {
width: 380px;
margin-right: 0;
position: absolute;
height: 100%;
margin-left: 10px;
}
.navbar-list {
color: white;
width: 300px;
height: 100%;
}
<div class="container">
<div class="logo">
<a class="navbar-brand" href="#"><img src="img/640px-HSV-Logo.png" /></a>
<h1>WITAJ W <span>DOMU!</span></h1>
</div>
<div class="navbar-list ">
<ul>
<li>
<span class=" glyphicon glyphicon-shopping-cart" aria-hidden="true"></span> Sklep
</li>
</ul>
<ul>
<li> <button type="button" class="btn btn-danger btn-md ">
<span class="glyphicon glyphicon-user" aria-hidden="true"></span> Zaloguj się
</button></li>
</ul>
</div>
</div>
There are lots of methods of achieving your desired result! In my opinion, Flexbox would be your best option. You should add display: flex to your .container. You can add the flex to the .logo container as well, if you want the logo and h1 to sit side by side.
You should also avoid using float, as this often makes HTML behave unexpectedly. You can replace this with justify-content: space-between.
I've amended your example above to incorporate my amends:
.container {
font-family: sans-serif;
padding: 0;
height: 80px;
display: flex;
justify-content: space-between;
align-items: center;
}
.logo {
width: 380px;
/*margin-right: 0; */
/*position: absolute; */
height: 100%;
margin-left: 10px;
display: flex;
align-items: center;
}
.navbar-list {
color: white;
width: 300px;
height: 100%;
}
<div class="container">
<div class="logo">
<a class="navbar-brand" href="#"><img src="img/640px-HSV-Logo.png" /></a>
<h1>WITAJ W <span>DOMU!</span></h1>
</div>
<div class="navbar-list ">
<ul>
<li>
<span class=" glyphicon glyphicon-shopping-cart" aria-hidden="true"></span> Sklep
</li>
</ul>
<ul>
<li> <button type="button" class="btn btn-danger btn-md ">
<span class="glyphicon glyphicon-user" aria-hidden="true"></span> Zaloguj się
</button></li>
</ul>
</div>
</div>
From a high level, the go-to method for this situation is using flexbox instead of floats. Not sure about Bootstrap in your case or why you had that change happen.
.container {
display: flex;
justify-content: flex-end; /* and many more positioning options */
}
just add float: right; to your .navbar-list css then you can move your div to right side
.navbar-list {
color: white;
width: 300px;
height: 100%;
float: right;
}
So I'm trying out a new chat room and I wanted to display a list of users into two columns. When I have two people in the room the <li>'s get nicely spread across the two columns. However, when there is an uneven amount of li's I get the below problem. Can someone take a look at my code and see what I did wrong?
edit: I deleted the column-fill: balance, but still nothing.
SCSS code
.first-main-column {
.first-column-window {
height: 700px;
background-color: #ffffff;
.user-container {
height: 350px;
width: 100%;
overflow: auto;
columns: 2;
column-gap: 1em;
column-rule: thin solid black;
h2 {
font-family: "Bebas Neue";
column-span: all
}
.list {
column-fill: balance;
ul {
li {
width: 80%;
border-radius: 5px;
margin: 0 auto;
}
}
}
}
.btn-container{
width: 100%;
height: 350px;
button {
margin: 5% 0;
padding: 5%;
}
}
}
}
HTML code
<div class="col-md-4 first-main-column">
<div class="first-column-window w-80">
<div class="user-container">
<h2 class="p-2">User List</h2>
<div class="list">
<ul class="list-group">
<li class="list-group-item my-2" *ngFor="let user of userList">
{{user}}
</li>
</ul>
</div>
</div>
<div class="btn-container ">
<button class="btn btn-block btn-lg btn-primary" (click)="joinRoom('general', chatWindow)">General Chat</button>
<!-- House chat should be different with each house-->
<button class="btn btn-block btn-lg btn-warning" (click)="joinRoom('house', chatWindow)">House Chat</button>
<button class="btn btn-block btn-lg btn-danger" (click)="joinRoom('country', chatWindow)">Country Chat</button>
</div>
</div>
</div>
Add
display: inline-block;
to your li style.
.list {
column-fill: balance;
ul {
li {
width: 80%;
border-radius: 5px;
margin: 0 auto;
display: inline-block;
}
}
}
I am trying to make my table and buttons to be responsive but without success.
The buttons aren't fixed to the width when I decrease the size of the screen and the table below is set behind of this buttons and not below as it should be.
The search bar and buttons are supposed to be fixed below the navbar.
The system is like an admin system, where I display the logs from my other system (getting the data from MongoDB).
I am attaching screenshots and source code.
HTML-
<header>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="#">
<img src="./image/logoC.png">
</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li><i class="fa fa-sign-in fa-fw"></i>Logins
</li>
<li><i class="fa fa-user-plus fa-fw"></i>Signup
</li>
<li><i class="fa fa-exclamation-circle fa-fw"></i>Add Items Errors
</li>
<li><i class="fa fa-retweet fa-fw"></i>Refresh Log
</li>
<li>Refresh Errors
</li>
<li>Bad Product
</li>
<li><i class="fa fa-refresh fa-fw"></i>Refresh All
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><i class="fa fa-sign-out fa-fw"></i>Logout</li>
</ul>
</div>
</div>
</div>
</header>
<div class="table_content">
<div class="row">
<div class="options">
<div class="col-sm-4">
<form class="searchBox">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-search"></i>
</div>
<input type="text" class="form-control" ng-model="searchLogins">
</div>
</div>
</form>
</div>
<div class="col-sm-8">
<ul class="pager" ng-show="currentPage==login">
<li>
<button id="markAsHandled" name="markAsHandled" class="btn btn-success" ng-click="handle()" value="Handle">Mark as Handled</button>
</li>
<li>
<button id="deleteError" name="deleteError" class="btn btn-danger" ng-click="remove()" value="Remove">Delete Errors</button>
</li>
<li>
<button id="select_all" name="deleteError" class="btn btn-info" ng-model="selectedAll" ng-click="checkAll()">Select All</button>
</li>
<li>
<button ng-click="removeLogs()" id="deleteAllErrors" name="deleteError" class="btn btn-danger">Remove All</button>
</li>
</ul>
<h5 id="statusMessage">{{statusMsg}}</h5>
</div>
</div>
</div>
</div>
<div class="tableAdmin">
<table ng-table="tableParams" class="table table-striped" show-filter="true">
<tr ng-repeat="log in $data| orderBy:sortType:sortReverse | filter : searchLogins">
<td data-title="'ID'">
{{log._id}}
</td>
<td data-title="'Data'">
{{log.logData}}
</td>
<td data-title="'Date'">
{{log.logDate}}
</td>
<td data-title="'Handled'">
<input type="checkbox" ng-model="log.selected" />
</td>
</tr>
</table>
</div>
<footer class="footer">
<div class="container">
<div class="row">
<div class="span9">
<p class="text-muted">Copyright © 2017 - Designed & Developed by me.</p>
</div>
</div>
</div>
</footer>
</div>
CSS-
html {
width: 100%;
height: 100%;
}
body {
font-family: 'Lato', Calibri, Arial, sans-serif;
background: #f9f9f9;
font-weight: 300;
font-size: 15px;
overflow: scroll;
overflow-x: hidden;
width: 100%;
height: 100%;
}
.btn {
font-weight: 400;
width: 100px;
height: 36px;
-moz-user-select: none;
-webkit-user-select: none;
user-select: none;
cursor: pointer;
}
#markAsHandled {
width: 130px;
margin-right: 5px;
float: left;
}
#deleteError {
width: 110px;
margin-right: 5px;
float: left;
}
#select_all {
width: 110px;
margin-right: 15px;
float: left;
}
#deleteAllErrors {
width: 110px;
float: left;
}
#statusMessage {
float: left;
margin-left: 10px;
padding-top: 10px;
}
.table {
width: 80%;
height: 100%;
margin-top: 55px;
margin-left: 6px;
}
#ID_column {
width: 230px;
}
#user_column {
width: 230px;
}
#date_column {
width: 230px;
}
#handled_column {
width: 100px;
}
input[type="radio"],
input[type="checkbox"] {
line-height: normal;
margin-left: 50px;
}
.btn-success {
margin-left: 26px;
width: 100px;
}
#import url(http://fonts.googleapis.com/css?family=Lato:300,400,700);
*,
*:after,
*:before {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 0;
margin: 0;
}
.ckbox {
position: relative;
}
.ckbox input[type="checkbox"] {
opacity: 0;
}
.table_content {
width: 100%;
margin-top: 66px;
}
td {
word-wrap: break-word;
overflow-wrap: break-word;
}
.searchBox {
float: left;
width: 400px;
margin: 10px 0 0 0;
}
/*Menu Options*/
.options {
float: left;
width: 100%;
height: 50px;
position: fixed;
display: block;
padding-left: 10px;
background-color: #f9f9f9;
z-index: 1000;
}
.pager {
float: left;
margin: 10px 0 0 10px;
}
.tableAdmin {
width: 100%;
padding-top: 20px;
padding-left: 50px;
}
.badgebox {
opacity: 0;
}
.badgebox + .badge {
text-indent: -999999px;
width: 27px;
}
.badgebox:focus + .badge {
box-shadow: inset 0px 0px 5px;
}
.badgebox:checked + .badge {
text-indent: 0;
}
#div1 {
height: 50px;
width: 100%;
margin-left: 35%;
}
footer {
padding: 50px 0;
height: auto;
text-align: center;
}
Thank you guys.
I've fixed this issue by decreasing the size of the search area and the size of the buttons.
This is my div structure. I'm having difficulties achieving the following.
How can I make all 3 buttons (Sub 1, Sub 2, Sub 3) visible and make the height of DIV 1 to the height of its children buttons?
Fiddle
html:
.sub {
position: relative;
background-color: lime;
}
.itmHolder {
position: relative;
}
.Buttons {
display: inline-block;
padding: 12px 8px;
}
.itmHolder:nth-child(2),
.itmHolder:nth-child(3) {
position: absolute;
top: 0;
}
.og {
margin-top: 15px;
position: relative;
text-align: center;
}
<div class="og">
<div class="itmHolder">
<div class="sub">DIV 1</div>
<div class="sub">DIV 2</div>
<div class="sub">
<button type="button" class="Buttons">Sub 1</button>
<button type="button" class="Buttons">Sub 2</button>
<button type="button" class="Buttons">Sub 3</button>
</div>
</div>
<div class="itmHolder">
<button type="button" class="normalBtn">Button</button>
</div>
</div>
Expected output:
well I removed obsolete elements and css definitions and now it looks exactly like the image:
.sub {
position: relative;
background-color: lime;
overflow: hidden;
}
.itmHolder {
position: relative;
}
.Buttons {
display: inline-block;
padding: 12px 8px;
}
.og {
margin-top: 15px;
position: relative;
text-align: center;
}
<div class="row">
<div class="og">
<div class="itmHolder">
<div class="sub">
<button type="button" class="Buttons">Sub 1</button>
<button type="button" class="Buttons">Sub 2</button>
<button type="button" class="Buttons">Sub 3</button>
</div>
</div>
<div class="itmHolder">
<button type="button" class="normalBtn">Button</button>
</div>
</div>
</div>
fiddle
You just have to change your css a little:
.Buttons{
display: inline-block;
padding: 1px 8px;
height: 100%;
line-height: 100%;
}
.itmHolder > :nth-child(2) , .itmHolder > :nth-child(3){
position: absolute;
top:0;
width: 100%;
}
https://jsfiddle.net/t5au23ra/7/
I would have made somethin like that
.wrapper {
width: 500px;
text-align: center;
margin: 0 auto;
}
.subs {
background-color: green;
}
.subs button {
height: 30px;
}
<div class="wrapper">
<div class="subs">
<button>Sub1</button>
<button>Sub2</button>
<button>Sub3</button>
</div>
<button>Button</button>
</div>
Your problem and your markup is not understandable. Don't know why you have used pos:abs property. If you want as in your figure then, you don't need that much codes. Look at this fiddle .
HTML
<div class="make-center">
<div class="sub">
<button type="button" class="Buttons">Sub 1</button>
<button type="button" class="Buttons">Sub 2</button>
<button type="button" class="Buttons">Sub 3</button>
</div>
<button type="button" class="normalBtn">Button</button>
</div>
CSS
.make-center {
text-align: center;
padding: 20px 0;
}
.sub {
background: lime;
}
.normalBtn,
.Buttons {
padding: 10px;
border: 1px solid gray;
}
The spacing between buttons are because of default button border ( browser's default rendering ).
i hope you want like this type of menu
<ul class="itmHolder">
<li>DIV 1</li>
<li>DIV 2
<ul class="sub">
<li> <button type="button" class="Buttons">Sub 1</button></li>
<li> <button type="button" class="Buttons">Sub 2</button></li><li>
<button type="button" class="Buttons">Sub 3</button></li>
<button type="button" class="normalBtn">Button</button>
</ul>
</li>
</ul>
css
.itmHolder{ margin:0; padding:0;}
.itmHolder li{ display:inline-block; position:relative;}
.itmHolder li .sub{display:none; height:50px; background:lime; width:100%; position:absolute; width:500px;}
.itmHolder li:hover .sub {display:block;}
.itmHolder li:hover .sub button{height:50px; margin:0 2px;}
.normalBtn{top:50px;margin-left:250px;position:absolute}
use this.
Remove this from your css: Demo
.itmHolder :nth-child(2) , .itmHolder :nth-child(3){
position: absolute;
top:0;
}
As per your expected output. This could help you.
HTML
<div>
<div class="parent">
<button>SUB1</button>
<button>SUB2</button>
<button>SUB3</button>
</div>
<div>
<button>Button</button>
</div>
</div>
CSS
.parent {
background-color: lime;
}
div{
text-align: center;
}
.parent button{
margin: 0;
padding:0;
height: 55px;
width: 50px;
}
Basically I'm trying to make the chat messages scrollable. However as of right now the content doesn't seem to be scrollable. When the "chat-messages-wrapper" class was relative it'd scroll just fine however I want the chat messages to appear at the bottom initially which is why I switched it to absolute.
Html:
<div class="chat-widget">
<div class="header">Social Chat</div>
<div class="chat-messages-wrapper">
<div class="chat-message">
<img class="profile-image" src="../Content/images/facebook-profile.png" /> <span class="header-1">
<img class="logo" src="../Content/images/facebook-logo.png" />
<span class="username">Jens Olsen says:</span>
</span> <span class="header-2">
<button class="reply btn btn-primary btn-xs">Reply</button>
<button class="like btn btn-success btn-xs">Like</button>
<button class="spam btn btn-danger btn-xs">Spam</button>
<span class="date">5:03PM</span>
</span>
<div class="text">This is the chat message. This is the chat message.</div>
</div>
<div class="chat-message">
<img class="profile-image" src="../Content/images/facebook-profile.png" /> <span class="header-1">
<img class="logo" src="../Content/images/twitter-logo.png" />
<span class="username">Jens Olsen says:</span>
</span> <span class="header-2">
<button class="reply btn btn-primary btn-xs">Reply</button>
<button class="like btn btn-success btn-xs">Like</button>
<button class="spam btn btn-danger btn-xs">Spam</button>
<span class="date">5:03PM</span>
</span>
<div class="text">This is the chat message. This is the chat message.</div>
</div>
<div class="chat-message">
<img class="profile-image" src="../Content/images/default-avatar.png" /> <span class="header-1">
<span class="username">Jens Olsen says:</span>
</span> <span class="header-2">
<button class="reply btn btn-primary btn-xs">Reply</button>
<button class="like btn btn-success btn-xs">Like</button>
<button class="spam btn btn-danger btn-xs">Spam</button>
<span class="date">5:03PM</span>
</span>
<div class="text">This is the chat message. This is the chat message.</div>
</div>
</div>
<div class="reply-box">
<input class="reply-text" placeholder="Type your message here..." />
<button class="btn btn-primary reply-button">Send</button>
</div>
</div>
Css:
.chat-widget {
position: fixed;
right: 5px;
bottom: 5px;
height: 95%;
width: 300px;
background-color: #FFF;
border: solid 3px #3B5998;
overflow: hidden;
}
.chat-widget .header {
text-align: center;
font-size: 18px;
color: #FFF;
background-color: #3B5998;
font-weight: bold;
padding-top: 5px;
padding-bottom: 5px;
}
.header {
position: relative;
z-index: 2;
width: 100%;
}
.chat-messages-wrapper {
position: absolute;
bottom: 40px;
padding-left: 7px;
padding-right: 7px;
height: auto;
overflow-y: auto;
}
.chat-message {
padding-top: 5px;
position: relative;
border-bottom: solid 1px #000;
overflow-y: auto;
}
.chat-message .profile-image {
height: 48px;
width: 48px;
border: solid 1px #000;
margin-right: 5px;
}
.chat-message > .header-1 {
position: absolute;
height: 20px;
}
.chat-message > .header-1 .logo {
width: 75px;
height: 20px;
}
.chat-message > .header-1 .username {
font-weight: bold;
}
.chat-message > .header-2 {
position: absolute;
top: 30px;
height: 20px;
}
.chat-message > .header-2 > .reply {
width: 50px;
}
.chat-message > .header-2 > .like {
width: 50px;
}
.chat-message > .header-2 > .spam {
width: 50px;
}
.chat-message > .header-2 .date {
font-style: italic;
position: relative;
right: 0px;
}
.chat-message .text {
position: relative;
margin: 5px;
}
.chat-message:last-child {
border-bottom: 0px;
}
.reply-box {
overflow-y: auto;
position: absolute;
bottom: 5px;
}
.reply-box .reply-text {
width: 70%;
height: 32px;
}
.reply-box .reply-button {
width: 25%;
}
Here's a JSFiddle with the entire code:
http://jsfiddle.net/5GCE5/1/
In order to get overflow-y to work, you need to specify an explicit (min/max) height for the .chat-messages-wrapper element.
However, since the box is positioned absolutely, you could play with top and bottom properties to achieve the same effect:
Example Here
.chat-messages-wrapper {
position: absolute;
padding-left: 7px;
padding-right: 7px;
/* height: auto; */
bottom: 40px; /* = height of bottom element */
top: 32px; /* = height of top element */
overflow-y: auto;
}
You need to give .chat-messages-wrapper a max-height
http://jsfiddle.net/5GCE5/6/