css in a chatbox - html

I have a chat program where my target is, when someone type and send a text, i want the text to be display from the bottom. Like any other chating frame.
To do this, i have wrote the following html/css structure.
here the "li" tags are creating dynamically when someone send a text.
The problem:
The problem is if i remove the "height:100% " from the ".chatbox ul", the text in the chatbox starts from the bottom. But in that case i dont see any scroll bar. But I need to see a scroll bar.
And, if I keep the "height:100% " in the ".chatbox ul", I see a scroll bar but the text in the chatbox starts from the top.
My target is to have a scroll bar and the text should also start from the bottom.
How would I acheive this..?? any help guys??
<div class="chatBox">
<ul id="messages" class="chatText">
<li>
<div class="chatterName">maverick </div>
<div class="chatterMessage"> hi</div>
<div class="clear"></div>
</li>
<li>
<div class="chatterName">johny</div>
<div class="chatterMessage"> hello</div>
<div class="clear"></div>
</li>
</ul>
CSS:
.chatBox
{
background-image: url('../images/DefaultitemBg.gif');
font-family: Verdana;
font-size: 14px;
color: #333333;
border: 1px double #FFFFFF;
padding: 5px;
margin: 10px;
width:76%;
height:600px;
position:relative;
border: 1px solid #E9E9E9;
overflow:auto;
float:left;
}
.chatBox ul
{
list-style-type: none;
padding: 0px;
margin: 0px;
position:absolute;
overflow:auto;
bottom:0;
height:100%;
}
.chatBox ul li
{
border-bottom-style: solid;
border-bottom-width: 1px;
border-bottom-color: #F2F2F2;
margin-bottom: 0px;
}
.chatterName
{
width: 120px;
background-color: #EEEEEE;
color: #333333;
float: left;
border-right-style: solid;
border-right-width: 1px;
border-right-color: #CCCCCC;
height: 30px;
border-bottom-style: solid;
border-bottom-width: 1px;
border-bottom-color: #E6E6E6;
}
.chatterMessage
{
width: 91%;
padding-left:4px;
color: #333333;
float:left;
min-height:30px;
border-bottom-style: solid;
border-bottom-width: 1px;
border-bottom-color: #EFEFEF;
}
.chatText
{
bottom: 0;
left: 0;
border-top-style: 0;
border-right-style: 0;
border-bottom-style: 1;
border-left-style: 0;
border-bottom-width: 1px;
border-bottom-color: #E6E6E6;
width:100%;
}
EDIT:
See it live here
If you see carefully, you will notice when i am entering text in the chatbox, from the top, previous texts are disappearing.
What I want is a scroll bar, so that users can see previous messages.

You can use javascript to scroll to bottom:
document.getElementById('messages').innerHTML += '<li>'+your message here+'</li>'
window.scrollTo(0, document.body.scrollHeight)

This should solve it:
use max-height instead of height
.chatBox ul
{
list-style-type: none;
padding: 0px;
margin: 0px;
position:absolute;
overflow:auto;
bottom:0;
max-height: 100%;
/*height:100%;*/
}
working example: http://jsfiddle.net/pt43J/1/

Related

CSS 3 special rounded border [duplicate]

This question already has answers here:
Invert rounded corner in CSS?
(10 answers)
Closed last month.
I have tried to create that rounded border corners on the bottom but I can't figure it out how to make them ....
.test {
border-bottom: 2px solid #EEF7FF;
display: inline-flex;
}
.test li {
float: left;
list-style-type: none;
}
.test li a {
text-decoration: none;
padding-left: 30px;
padding-right: 30px;
padding-top: 5px;
color: #A6B5C7;
}
<div class="" style="margin-top: 20px;">
<ul class="test" style>
<li>
<a style="border-top: 2px solid #EEF7FF;border-left: 2px solid #EEF7FF;border-right: 2px solid #EEF7FF;border-bottom: 5px solid white;color: #000000 !important;padding-bottom: 5px;vertical-align: super;border-radius: 5px 5px 0px 0px; " href="">All</a>
</li>
<li>
Solved
</li>
</ul>
</div>
Connecting border-radius from adjacent elements
Those borders might be achieved connecting the borders of the adjacent list item elements.
After finishing the demo I realized it's not the best approach to get there actually. But since it shows how to deliver an idea I think it's still worth remaining here.
Styling the active item - border-left and border-top:
I added the class active to distinguish between active and inactive navigation links.
The item with the active has only the border left and top styled:
li.active a {
position: relative;
color: black;
vertical-align: super;
border-top: solid var(--border-size) var(--border-color);
border-left: solid var(--border-size) var(--border-color);
border-radius: var(--border-radius-active) var(--border-radius-active) 0px 0px;
}
Styling the active item - border-right:
While the right border gets styled using the pseudoelement ::after positioned absolute. The reason why we couldn't style directly the right border it's because its lenght can't be the whole height since we are trying to connect with this segment the border radius coming from two different elements and if we used the whole lenght it wouldn't look right:
li.active a::after {
content:"";
background: var(--border-color);
position: absolute;
bottom: var(--border-offset-bottom);
right: 0;
height: calc(100% - var(--border-offset-top) - var(--border-offset-bottom));
width: var(--border-size);
}
Styling the next item - border-bottom:
And eventually the last portion of the line is styled by the next element:
li.active + li a {
border-bottom: solid var(--border-color) var(--border-size);
border-radius: 0 0 0 var(--border-radius-inactive);
}
Custom properties:
I encoded the core parameters as custom properties in the :root element:
--border-color: #EEF7FF;
--border-size: 1px;
--border-offset-top: 4px;
--border-offset-bottom: 2px;
--border-radius-active: 10px;
--border-radius-inactive: 3px;
The demo:
In the demo you can toggle the border color to red to better see in contrast the result:
:root{
--border-color: #EEF7FF;
--border-size: 1px;
--border-offset-top: 4px;
--border-offset-bottom: 2px;
--border-radius-active: 10px;
--border-radius-inactive: 3px;
}
.red{
--border-color: red;
}
*{
box-sizing: border-box;
}
body{
font-size: 30px;
font-family: sans-serif;
}
.test {
display: inline-flex;
}
.test li {
float: left;
list-style-type: none;
}
.test li a{
text-decoration: none;
padding-left: 30px;
padding-right: 30px;
padding-top: 5px;
padding-bottom: 5px;
color: #A6B5C7;
}
li.active a {
position: relative;
color: black;
vertical-align: super;
border-top: solid var(--border-size) var(--border-color);
border-left: solid var(--border-size) var(--border-color);
border-radius: var(--border-radius-active) var(--border-radius-active) 0px 0px;
}
li.active a::after {
content:"";
background: var(--border-color);
position: absolute;
bottom: var(--border-offset-bottom);
right: 0;
height: calc(100% - var(--border-offset-top) - var(--border-offset-bottom));
width: var(--border-size);
}
li.active + li a {
border-bottom: solid var(--border-color) var(--border-size);
border-radius: 0 0 0 var(--border-radius-inactive);
}
button{
cursor: pointer;
padding: 1em;
}
<div style="margin-top: 20px;">
<ul id="nav" class="test" style>
<li class="active">
All
</li>
<li>
Solved
</li>
</ul>
</div>
<button onclick="document.getElementById('nav').classList.toggle('red')">change color to red!</button>

Show separate line not border

I am not sure how to make a separate line as shown in this image.
This is what I am doing:
.separate-line {
background-color: #D8D9DE;
border-width: 0;
color: #D8D9DE;
height: 1px;
}
I added this html to show the border line:
<div>
<hr class="separate-line">
<input...>
</div>
The result shows a normal border. But I want to display a separate horizontal line.
If your looking to create a two coloured/seperate lined <hr>, this is a way that you can do it
If you zoom in close, you can see the difference in colours between the top half of the line and the bottom half
I've added a darker background so you can notice the difference in colour
.separate-line {
background-color: #fff;
color:#fff;
height: 2px;
border:0;
border-top:2px solid #aaa;
}
input {
width: 96%;
margin-left:2%;
}
body {
background-color: #ddd;
}
<div>
<hr class="separate-line">
<input type="text">
</div>
For Firefox (some reason have to double hr height):
.separate-line {
background-color: #fff;
color:#fff;
height: 4px;
border:0;
border-top:2px solid #aaa;
}
input {
width: 96%;
margin-left:2%;
}
body {
background-color: #ddd;
}
<div>
<hr class="separate-line">
<input type="text">
</div>
Hello Try This This Might Help you as you want a separate border.
hr {
display: block;
border-style: inset;
border-width: 2px;
background-color: #D8D9DE;
}
you can increase the border using border-width:

show the div inside that div next to it

I want to make a vertical menu with submenu's and the submenu have to go next to the parent div.
Hope you guys know how to do that, I did a look on google but only found results like 2 divs next to eachother. But I need that the child div have to get next of it.
My code for now:
HTML
<div id="menuCont">
<div class="menuItem">
Applicatie Ontwikkeling
<div class="subMenuCont">
<div class="subMenuItem">HTML</div>
<div class="subMenuItem">CSS</div>
<div class="subMenuItem">jQuery</div>
</div>
</div>
<div class="menuItem">
Netwerk Beheer
</div>
<div class="menuItem">
Server Beheer
</div>
</div>
CSS
#menuCont {
width: 17.5%;
text-align: center;
}
.menuItem {
width: 100%;
padding: 1em;
background-color: #ffffff;
color: #000000;
font-family: Lato;
font-size: 125%;
border: 1px solid #7266ff;
border-bottom: 0;
cursor: pointer;
}
.menuItem:first-child {
border-top-left-radius: 1.5em;
}
.menuItem:last-child {
border-bottom: 1px solid #7266ff;
border-bottom-right-radius: 1.5em;
}
.menuItem:hover {
background-color: #7266ff;
color: white;
}
.subMenuCont {
/*display: none;*/
position: relative;
/*left: 100%;*/
/*width: 90%;*/
}
.subMenuItem {
border: 1px solid #7266ff;
border-bottom: 0;
}
.subMenuItem:last-child {
border-bottom: 1px solid #7266ff;
}
Do you need any more info, please say it. for now I don't know what to give as more info.
In your CSS Code I changed the position element to absolute, that allows you to place the element exactly where you want:
.subMenuCont {
position: absolute;
top:0;
left: 17.5%;
width: 17.5%;
}

Align Divs in HTML + CSS

I am trying to align three divs inside of a fourth div to create something similar to what you see on this page: http://www.thedistillerydistrict.com/
I can't seem to get the inside divs (#Entertainment, #Community, #welcome) align side by side inside the #HomeMain div
This is from the html
<div id = "HomeMain">
<div id="welcome">
<p>Finest Booze around, come taste for yourself Home to many of Toronto's hottest designer boutiques, unique cafes, artisan shops, breathtaking art galleries, performance venues and award-winning restaurants, The Distillery District is the place to see and be seen. An internationally acclaimed pedestrian-only village, The Distillery features more than 70 ground-floor cultural and retail establishments in the restored red brick, Victorian-era buildings of the renowned Gooderham & Worts whiskey distillery. One of Canada's hottest tourist attractions, centrally-located and just a short walk from downtown Toronto there is always something happening at The Distillery.</p>
<div class = "Oldman"></div>
</div>
<div id = "Entertainment">
<img src="images/Entertainment1.jpg" id="EntSlide" width=125 height=70 />
</div>
<div id = "Community">
<img src="images/Victoria1.jpg" id="ComSlide" width=125 height=70 />
</div>
</div>
Here is the CSS
#HomeMain{
width: 100%;
float: left;
overflow:hidden;
margin:0 auto;
padding:5px;
border-style: groove;
border-width: 3px;
border-colour: white;
border-radius: 5px 5px 5px 5px;
}
#Entertainment #Community{
float: left;
width: 25%;
border-style: groove;
border-width: 3px;
border-colour: white;
border-radius: 5px 5px 5px 5px;
}
#welcome{
float: left;
width:50%;
position: relative;
border-style: groove;
border-width: 3px;
border-color: white;
border-radius: 5px 5px 5px 5px;
font-weight: bold;
padding:15px;
}
Check this fiddle link http://jsfiddle.net/hek7fLy2/
All i have done is use the box-sizing css property to achieve the desired result. Also I assume you would want the images in the 2 smaller divs to be centered, so this takes care of that.
I have not changed your HTML code but i tweaked just a little bit of css code including the typo..
#HomeMain{
width: 100%;
float: left;
overflow:hidden;
margin:0 auto;
padding:5px;
border-style: groove;
border-width: 3px;
border-colour: white;
border-radius: 5px 5px 5px 5px;
box-sizing:border-box;
}
#Entertainment, #Community{
float: left;
width: 25%;
border-style: groove;
border-width: 3px;
border-colour: white;
border-radius: 5px 5px 5px 5px;
box-sizing:border-box;
}
#welcome{
float: left;
width:50%;
position: relative;
border-style: groove;
border-width: 3px;
border-color: white;
border-radius: 5px 5px 5px 5px;
font-weight: bold;
padding:15px;
box-sizing:border-box;
}
img{
display:block;
margin: 0 auto;
}
You forgot the the comma in the second rule and in order to make it right you have to use the box-sizing: border-box;.
#HomeMain {
width: 100%;
float: left;
overflow: hidden;
margin: 0 auto;
padding: 5px;
border-style: groove;
border-width: 3px;
border-colour: white;
border-radius: 5px;
box-sizing: border-box;
}
#Entertainment,
#Community {
float: left;
width: 25%;
border-style: groove;
border-width: 3px;
border-colour: white;
border-radius: 5px;
box-sizing: border-box
}
#welcome {
float: left;
width: 50%;
position: relative;
border-style: groove;
border-width: 3px;
border-color: white;
border-radius: 5px;
font-weight: bold;
padding: 15px;
box-sizing: border-box
}
<div id="HomeMain">
<div id="welcome">
<p>
Finest Booze around...
</p>
<div class="Oldman"></div>
</div>
<div id="Entertainment">
<img src="http://dummyimage.com/125x70" id="EntSlide">
</div>
<div id="Community">
<img src="http://dummyimage.com/125x70" id="ComSlide">
</div>
</div>
Check this fiddle
First of all it should be
#Entertainment,#Community{
and not
#Entertainment #Community{
next, why your divs arent aligning is because you are specifying a border of 3px each for the 3 divs which makes the divs to jump to the next line.So, here i've used box-sizing: border-box property for each of the divs.
Try it..
<div id = "HomeMain">
<div id="welcome">
Finest Booze around
</div>
<div id = "Entertainment">
Finest Booze around,
</div>
<div id = "Community">
Finest Booze around,
</div>
</div>
css use display property
#HomeMain{
width: 100%;
float: left;
overflow:hidden;
margin:0 auto;
padding:5px;
border-style: groove;
border-width: 3px;
border-colour: white;
border-radius: 5px 5px 5px 5px;
display:block;
}
#Entertainment, #Community,#welcome{
width: auto;
border-style: groove;
border-width: 3px;
border-colour: white;
border-radius: 5px 5px 5px 5px;
background:#ccc;
display:inline-block;
}
fiddle
http://jsfiddle.net/tnmzo1gc/
You have a typo in the CSS
#Entertainment #Community{
should be
#Entertainment, #Community{
I hope it solves your problem:) If not, please elaborate on a question.

Aligning Font-Width across 3 Major Browsers

I currently have 4 Divs, each of which contains a hyperlink. Each hyperlink is a member of the navigation bar at the top of a website. The rightmost link must line up with elements below it. I should be able take a vertical line ruler and see the rightmost elements align at the right-most edge of the page.
My rendered HTML looks great in Chrome, but not in FireFox, or IE: the links are not as wide and the page looks weird because the fourth link doesn't hit the right edge of the page.
I believe this has to do with font width definitions, however I do not know what to manually set.
FireFox CSS Computed Text:
font-family Lucida Sans Unicode
font-size 16px
font-weight 600
font-style normal
font-size-adjust none
color #EEFFFF
text-transform none
text-decoration none
letter-spacing normal
word-spacing 0
line-height 23px
text-align start
vertical-align baseline
direction ltr
-moz-tab-size 8
-moz-font-feature-settings normal
-moz-font-language-override normal
-moz-text-blink none
-moz-text-decoration-color #EEFFFF
-moz-text-decoration-line none
-moz-text-decoration-style solid
text-overflow clip
Chrome Computed Style:
background-attachment: scroll;
background-clip: border-box;
background-color: #D00;
background-image: none;
background-origin: padding-box;
border-bottom-color: #B00;
border-bottom-style: solid;
border-bottom-width: 1px;
border-left-color: #B00;
border-left-style: solid;
border-left-width: 1px;
border-right-color: #B00;
border-right-style: solid;
border-right-width: 1px;
border-top-color: #B00;
border-top-style: solid;
border-top-width: 1px;
color: white;
cursor: auto;
display: inline;
float: none;
font-family: 'Lucida Sans Unicode';
font-size: 16px;
font-weight: 600;
height: auto;
line-height: 23px;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;
padding-bottom: 17px;
padding-left: 10px;
padding-right: 10px;
padding-top: 17px;
text-decoration: none;
width: auto;
---Append---
<div id="LinkContainer">
<div class="Link">
Variable Length Text A
</div>
<div class="Link">
Variable B
</div>
<div class="Link">
Variable Length Text C Really Long
</div>
<div class="Link">
Var D
</div>
</div>
#LinkContainer
{
position:absolute;
float: left;
margin-top:165px;
margin-bottom:5px;
margin-left:225px;
width:680px;
}
.Link
{
float:left;
margin: 0px 1px 0px 1px;
padding: 00px 0px 20px 0px;
color: #EFF;
font-weight:600;
font-family:Lucida Sans Unicode;
font-size: 16px;
}
.mnu-hover
{
background: #C00;
text-decoration: none; /* color: #FFF; */;
border: solid 1px #B00;
padding: 15px 10px 15px 10px;
margin: 0 0 0 0;
color: #EEE;
}
.mnu-hover:hover
{
background: #D00;
border: solid 1px #B00;
padding: 17px 10px 17px 10px;
color: #FFF;
}
This isn't something you can fix. If the text has to look perfect in every browser on every OS, use an image.
<ul id="LinkContainer">
<li class="=Link">
Variable Length Text A
</li>
<li class="=Link">
Variable B
</li>
<li class="=Link">
Variable Length Text C Really Long
</li>
<li class="=Link">
Var D
</li>
</ul>
.Link a {
background-image:url(title_sprite.png);
background-repeat:no-repeat;
height:40px;
text-indent:-999em;
}
.Link a.var_a {
background-repeat:no-repeat;
background-position:0 0;
width:200px;
}
.Link a.var_b {
background-repeat:no-repeat;
background-position:0 -45px;
width:150px;
}
.Link a.var_c {
background-repeat:no-repeat;
background-position:0 -90px;
width:75px;
}
.Link a.var_d {
background-repeat:no-repeat;
background-position:0 -135px;
width:90px;
}