how to display div one by one using css - html

we are developing chat application in that chat how much content will have that much width we want displaying separately one by one. and also chat length is big displaying of chat content in multi line.
We are displaying the content and how much content have that much size of width div displaying but side by side div is coming. we want to display step by step how to do.and if content length is long then displaying to multi line.
.right {
position: relative;
background: white;
text-align: right;
padding: 10px 15px;
border-radius: 6px;
border: 1px solid #ccc;
float: right;
right: 20px;
}
.right::before {
content: '';
position: absolute;
visibility: visible;
top: -1px;
right: -10px;
border: 10px solid transparent;
border-top: 10px solid #ccc;
}
.right::after {
content: '';
position: absolute;
visibility: visible;
top: 0px;
right: -8px;
border: 10px solid transparent;
border-top: 10px solid white;
clear: both;
}
<div>
<div class="right">
<span>thanks</span>
</div>
<div class="right">
<span>thanks</span>
</div>
</div>
<div>
<div class="right">
<span>thanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanks</span>
</div>
</div>

You have to clear the right float with overflow: hidden; for instance.
<div class="clear">
<div class="right">
<span>thanks</span>
</div>
</div>
<div class="clear">
<div class="right">
<span>thanks</span>
</div>
</div>
<div class="clear">
<div class="right">
<span>thregre gerg ergr geg reger ger gergregeg erger gerg erg erg ergergerger ge anks</span>
</div>
</div>
CSS
.clear { overflow: hidden; margin-bottom: 10px;}
Fiddle

You can use word-break:break-all(or normal|break-all|keep-all) Break words between any two letters.
and use clear property control the behavior of floating elements.
.right {
position: relative;
background: white;
text-align: right;
padding: 10px 15px;
border-radius: 6px;
border: 1px solid #ccc;
float: right;
right: 20px;
}
.right span{
word-break: break-all;
}
.fix{
clear:both;
}
.right::before {
content: '';
position: absolute;
visibility: visible;
top: -1px;
right: -10px;
border: 10px solid transparent;
border-top: 10px solid #ccc;
}
.right::after {
content: '';
position: absolute;
visibility: visible;
top: 0px;
right: -8px;
border: 10px solid transparent;
border-top: 10px solid white;
clear: both;
}
<div class="fix">
<div class="right">
<span>thanks</span>
</div>
</div>
<div class="fix">
<div class="right">
<span>thanks</span>
</div>
</div>
<div class="fix">
<div class="right">
<span>thanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanksthanks</span>
</div>
</div>

Related

Style Bottom Center Point of Div as Triangle

Here's what I have so far:
.buck-knives-inner-nav {
display: flex;
border: 1px solid #707070;
}
.buck-knives-inner-nav-tab {
text-align: center;
padding: 10px;
width: 100px;
}
.buck-knives-inner-nav-tab:not(:last-child) {
border-right: 1px solid #707070;
}
.active {
background-color: #0B0E55;
color: #ffffff;
}
/*
.active::after {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid #0B0E55;
}*/
<div class="buck-knives-inner-nav">
<div class="buck-knives-inner-nav-tab active">
Hold Old is My Knife?
</div>
<div class="buck-knives-inner-nav-tab">
Knife Sharpening
</div>
<div class="buck-knives-inner-nav-tab">
Safety Tips
</div>
<div class="buck-knives-inner-nav-tab">
Knife Care
</div>
<div class="buck-knives-inner-nav-tab">
Choosing the Right Knife
</div>
<div class="buck-knives-inner-nav-tab">
Buck's Forever Warranty
</div>
</div>
I'm wondering - is it possible to style the active tab differently so that it points downward at the bottom center, like I have it in the following mockup?
I tried to implement the downward-facing triangle effect that's used in this article:
https://css-tricks.com/snippets/css/css-triangle/
adding it as an ::after to the active tab - so why didn't that have any effect?
.active::after {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid #0B0E55;
}
Also tried something similar - what I found here: Center Triangle at Bottom of Div
All other ideas / suggestions are welcome!
You were missing the position on the after element.
I've added a position: relative; on the buck-knives-inner-nav-tab and some more positioning on the after:
content: "";
position: absolute;
top: 100%;
left: 0;
right: 0;
margin: 0 auto;
.buck-knives-inner-nav {
display: flex;
border: 1px solid #707070;
}
.buck-knives-inner-nav-tab {
text-align: center;
padding: 10px;
width: 100px;
position: relative;
}
.buck-knives-inner-nav-tab:not(:last-child) {
border-right: 1px solid #707070;
}
.active {
background-color: #0B0E55;
color: #ffffff;
}
.buck-knives-inner-nav-tab.active:after {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid #0B0E55;
content: "";
position: absolute;
top: 100%;
left: 0;
right: 0;
margin: 0 auto;
}
<div class="buck-knives-inner-nav">
<div class="buck-knives-inner-nav-tab active">
Hold Old is My Knife?
</div>
<div class="buck-knives-inner-nav-tab">
Knife Sharpening
</div>
<div class="buck-knives-inner-nav-tab">
Safety Tips
</div>
<div class="buck-knives-inner-nav-tab">
Knife Care
</div>
<div class="buck-knives-inner-nav-tab active">
Choosing the Right Knife
</div>
<div class="buck-knives-inner-nav-tab">
Buck's Forever Warranty
</div>
</div>

how to dispaly name, current time in message chat box

We developed chat application looks like watts-app. we finished everything but i want to show name and current time in chat message box. how to do that
requirement screen shot
.left {
position: relative;
background: white;
text-align: right;
padding: 10px 15px;
border-radius: 6px;
border: 1px solid #ccc;
float: right;
right: 20px;
}
.left::before {
content: '';
position: absolute;
visibility: visible;
top: -1px;
right: -10px;
border: 10px solid transparent;
border-top: 10px solid #ccc;
}
.left::after {
content: '';
position: absolute;
visibility: visible;
top: 0px;
right: -8px;
border: 10px solid transparent;
border-top: 10px solid white;
clear: both;
}
div{
clear: right;
}
<div class="left">
<p style="margin-top: 0px;margin-bottom: 0px;color:green;font-size: 11px;">Kranti</p>
<span>thanks</span>
<p style="float: left;margin-bottom: 0px;color:red;font-size: 11px;">2:33 PM</p>
</div>
You could create multiple span elements with their own classes and style the username and time to their position.
Use absolute positioning to get the styling as your provided image.
Here you go: https://jsfiddle.net/keqh0cqw/1/
An example of your new html:
<div class="right">
<span class="username">kranthi</span>
<span class="message">thanks</span>
<span class="time">12:08</span>
</div>

I have a div and a image and I need them aligned in the middle of the screen

body {
margin: 0;
width: 100%;
background-color: #292929;
}
.holder {
width: 66%;
height: 330px;
background-color: #412A22;
position: relative;
-webkit-box-shadow: 2px 2px 2px 0px #000000;
-moz-box-shadow: 2px 2px 2px 0px #000000;
box-shadow: 2px 2px 2px 0px #000000;
display: inline-block;
}
.holder:before {
content: '';
position: absolute;
top: 0; left: 0;
border-top: 50px solid #292929;
border-right: 50px solid #412A22;
width: 0;
}
.sidething {
float: left;
width: 100px;
display: block;
}
<div class="main">
<div class="holder">
<div class="holder-imgs">
</div>
<div class="contact">
</div>
</div>
<img class="sidething" src="Layer%203.png">
</div>
This is my css and html and what i basicly need is to center both image and div in the middle of the page. Here is what it looks like with image: http://imgur.com/IROUUk2
Thanks in advance
Why not do something simple like this:
<center>
<div class="main">
<div class="holder">
<div class="holder-imgs">
</div>
<div class="contact">
</div>
</div>
<img class="sidething" src="Layer%203.png">
</div>
</center>
Simple HTML - should do the trick!
Or, if you're main 'holder' div will only contain text, you could add the following property to the 'holder' div css:
text-align: center;
You might find this site useful!
Hope this helps and best of luck!

CSS arrow. Only a portion of the arrow is being displayed

I am trying to display a few words inside of a CSS styled arrow. I have figured out how to create an arrow with CSS which works fine. however, when I place the arrow within <h2>, complete arrow is not being displayed.
The source code is as follows
HTML
<div style="background-color: yellow;">
<h2><span style="background: green;">This is what I want</span><span class="arrow-right"></span><span style="margin-left: 50px;">is this what you want?</span></h2>
</div>
STYLE
<style>
.arrow-right::after{
content: "";
width: 0;
height: 0;
border-top: 15px solid transparent;
border-bottom: 15px solid transparent;
border-left: 15px solid green;
}
</style>
The output is as follows
The arrow pointer is not being displayed completely. Am I using the elements wrongly? I will need the div / h2 height to be bigger later, but at least that is not my concern right now since the arrow itself is not being displayed as desired.
Edit:
Sorry for my bad drawing. This sample below is what I want but of course the arrow would be lots nicer I just used paints to give it a quick draw.
Is this what you're looking for?
http://jsfiddle.net/61tc5em9/2/
HTML
<div id="container">
<div id="arrow">text text text</div>
<div id="content">text text text text</div>
</div>
CSS
#container {
height: 75px;
background-color: black;
position: relative;
white-space: nowrap;
}
#arrow {
width: 30%;
background-color: red;
text-align: center;
font-size: 1.5em;
line-height: 75px;
}
#arrow::after {
content: "";
border-top: 37px solid transparent;
border-bottom: 38px solid transparent;
border-left: 50px solid red;
position: absolute;
left: 30%;
}
#content {
color: yellow;
font-size: 1.5em;
position: absolute;
left: 50%;
top: 25px;
}
Hope this helps. Let me know if you need any changes.
You need font-size:0; for the arrow.
.arrow-right::after {
content: "";
width: 0;
height: 0;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
border-left: 30px solid green;
font-size: 0;
position: relative;
top: -8px;
}
span{
display: inline-block;
}
<div style="background-color: yellow;">
<h2><span style="background: green;">This is what I want</span><span class="arrow-right"></span><span style="margin-left: 50px;">is this what you want?</span></h2>
</div>
Recommendations for improving your code and make it more dynamic:
Use :after in the statement element itself (this way you will avoid
the extra code in html and you can position the arrow relative to the element).
Align it to the right using left: 100% (so it is always position to
the right regardless of the width of the arrow).
Use top: 50% and margin-top: -(height/2)px to center it vertically.
Just like this:
.wrapper {
padding: 2px 0;
background: yellow;
}
.statement {
position: relative;
background: green;
}
.statement:after {
content:"";
border-top: 15px solid transparent; /*change the border width to set the desired hieght of the arrow*/
border-bottom: 15px solid transparent;
border-left: 15px solid green; /*change the border width to set the desired width of the arrow*/
position: absolute;
left: 100%;
top: 50%;
margin-top: -15px; /*the element has height= 30px (border-top + border-bottom) to center it -height /2 */
}
h2{
margin: 0;
}
<div class="wrapper">
<h2>
<span class="statement">This is what I want</span>
<span style="margin-left: 50px;">is this what you want?</span>
</h2>
</div>
Note that in this way you have a more semantic code because you don't have dummy element in your html and if you want more statement it will put the arrow behind automatically like this:
.wrapper {
padding: 2px 0;
background: yellow;
margin-bottom: 10px;
}
.statement {
position: relative;
background: green;
}
.statement:after {
content:"";
border-top: 15px solid transparent;
border-bottom: 15px solid transparent;
border-left: 15px solid green;
position: absolute;
left: 100%;
top: 50%;
margin-top: -15px; /*the element has height= 30px (border-top + border-bottom) to center it -height /2 */
}
h2{
margin: 0;
}
<div class="wrapper">
<h2>
<span class="statement">One statement</span>
<span style="margin-left: 50px;">Good</span>
<span class="statement">Two statement</span>
<span style="margin-left: 50px;">Great</span>
</h2>
</div>
<div class="wrapper">
<h2>
<span class="statement">Where is the arrow?</span>
<span style="margin-left: 50px;">Do not worry about it</span>
</h2>
</div>

Add vertical line between the vertical divs

I want to add a vertical line between the multiple divs so that it looks like the attached image:
I'm trying to achieve that by adding a div .border and setting its position absolute. However I want to add some margin between the border and make the border appear behind the boxes as in above image.
Here's the code I'm trying:
HTML:
<div class="wrap">
<div class="box">
<div class="border"></div>
<div class="figure"></div>
<div class="right"> right</div>
</div>
<div class="box">
<div class="border"></div>
<div class="figure"></div>
<div class="right"> right</div>
</div>
<div class="box">
<div class="border"></div>
<div class="figure"></div>
<div class="right"> right</div>
</div>
</div>
CSS:
.wrap{
position: relative;
overflow: hidden;
}
.box{
overflow: hidden;
margin-top: 50px;
}
.box:first-child{
margin-top: 0;
}
.figure{
width: 50px;
height: 50px;
background: yellow;
display: inline-block;
margin-right: 10px;
}
.right{
display: inline-block;
}
.border{
border-right: 3px solid red;
height: 100%;
left: 24px;
position: absolute;
top: 0;
width: 1px;
}
.box:last-child .border{
display: none;
}
JSFiddle:
http://jsfiddle.net/w5TY9/
Here you go.
WORKING DEMO
The HTML:
<div class="wrap">
<div class="box">
<div class="border"></div>
<div class="figure"></div>
<div class="right"> </div>
</div>
<div class="box">
<div class="border"></div>
<div class="figure"></div>
<div class="right"> </div>
</div>
<div class="box">
<div class="border"></div>
<div class="figure"></div>
<div class="right"> </div>
</div>
</div>
The CSS:
.wrap{
position: relative;
overflow: hidden;
}
.box{
overflow: hidden;
margin-top: 50px;
}
.box:first-child{
margin-top: 0;
}
.figure{
width: 50px;
height: 50px;
background: yellow;
display: inline-block;
margin-right: 10px;
}
.right{
display: inline-block;
}
.border {
border-right: 3px solid #FF0000;
height: 98%;
left: 24px;
position: absolute;
top: 0;
width: 1px;
z-index: -1;
}
.box:last-child .border{
display: none;
}
.figure {
background: none repeat scroll 0 0 #FFFF00;
border-bottom: 12px solid #FFFFFF;
border-top: 12px solid #FFFFFF;
display: inline-block;
height: 50px;
margin-right: 10px;
width: 50px;
}
The CSS Changes:
.border {
border-right: 3px solid #FF0000;
height: 98%;
left: 24px;
position: absolute;
top: 0;
width: 1px;
z-index: -1;
}
.figure {
background: none repeat scroll 0 0 #FFFF00;
border-bottom: 12px solid #FFFFFF;
border-top: 12px solid #FFFFFF;
display: inline-block;
height: 50px;
margin-right: 10px;
width: 50px;
}
Hope this helps.
.border{z-index: -1;} use this
And see link http://jsfiddle.net/bipin_kumar/w5TY9/2/
.figure{
width: 50px;
height: 50px;
background: yellow;
display: inline-block;
margin-right: 10px;
z-index:1;
border:3px solid white;
}
.border{
border-right: 3px solid red;
height: 100%;
left: 24px;
position: absolute;
top: 0;
width: 1px;
z-index:-1;
}
replace your classes with mine, you will get both effects
.border{
border-right: 3px solid red;
height: 100%;
left: 24px;
position: absolute;
top: 0;
width: 1px;
}
Class need to be added the following property and value
z-index: -1;
In your css you need to add the following two rules for the .border class:
z-index: -1;
margin-left: -1px
The first line puts the line behind the boxes. So in the vertical space without boxes the line shows up.
One small improvement for centering the border perfectly under the boxes:
Your border is 3px width so the border should be moved at least 1px to the left in order to stay centered. With margin-left: -1px you get the correct result. If you want the border to be completely perfect centered you should either use a border with of 4px and a margin-left of -1px or a border with of 2px and a margin-left of 1px;
see http://jsfiddle.net/w5TY9/1/
Add z-index=-1 to border class.
check this fiddle
What you want is very easy. The short version is like this:
<div style="background-color:yellow; height:30px;width:30px;"> </div>
<div style="background-color:red; height:30px; width:5px; margin-left:10px;"> </div>
In this way you have a square with background yellow and below that you have a red line
with 5px width or whatever you want.