I am trying to implement a menu item as below.
My idea was to have :after for all individual divs and add border radius to :after element in each div to get the curved shape for each menu and position the after using z-index.
But while implementing a text clipping for each menu item , the :after elements seem to position themselves away from parent div . They seem not to recognise the text is being clipped and take full width of original text.
Click here for the fiddle highlighting the problem.
Here is my implementation
.interaction-area {
height: 30px;
font-family: sans-serif;
font-size: small;
color: white;
}
.context-item__child {
height: 40px;
max-width: 200px;
line-height: 40px;
padding-left: 30px;
padding-right: 5px;
display: inline-block;
background-color: #4286f4;
border-right: 2px solid white;
border-top: 2px solid white;
border-bottom: 2px solid white;
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.context-item__child:after {
height: 40px;
width: 30px;
top: 8px;
position: absolute;
display: inline-block;
z-index: 1;
background-color: #4286f4;
border-right: 2px solid white;
border-top: 2px solid white;
border-bottom: 2px solid white;
border-top-right-radius: 30px;
border-bottom-right-radius: 30px;
content: '';
}
<div class="interaction-area">
<div class="context-item__child">T</div>
<div class="context-item__child">DE FINIBUS BONORUM ET MALO</div>
<div class="context-item__child">NIHIL IMPEDIT QUO MINUS ID QUOD MAXIME</div>
<div class="context-item__child">DE FINIBUS BONORUM ET MALORUM</div>
<div class="context-item__child">NIHIL IMPEDIT QUO MINUS ID QUOD MAXIME</div>
</div>
Could you guide me what i am missing to make it work? Or is there a better way to approach the problem?
You could use Flexbox for ul and pseudo-elements to add that rounded border. You can create half circle with border-radius but then you also need to hide part of it with another pseudo-element so that it looks nice when li breaks to new line
* {
box-sizing: border-box;
}
ul {
display: flex;
flex-wrap: wrap;
list-style: none;
height: 40px;
}
li {
background: #498FF1;
position: relative;
height: 40px;
line-height: 40px;
padding: 0 30px;
color: white;
}
li:not(:first-child) {
padding-right: 30px;
}
li:after, li:before {
position: absolute;
content: '';
left: 100%;
height: 39px;
width: 39px;
border-bottom: 1px solid white;
border-right: 1px solid white;
border-radius: 50%;
transform: translateX(-50%) rotate(-45deg);
z-index: 1;
background: #498FF1;
}
li:after {
z-index: 2;
background: #498FF1;
border-radius: 0;
transform: rotate(0) translatex(-20px);
border: 1px solid #498FF1;
height: 38px;
top: 0;
width: 20px;
}
<ul>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum </li>
<li>Lorem ipsum dolor.</li>
<li>Lorem.</li>
</ul>
use :after alongside position:relative and flexbox.
You would need to optimise this a bit more... but I am sure you can handle it
.interaction-area {
height: 30px;
font-family: sans-serif;
font-size: small;
color: white;
position: relative; /* position relative */
display:flex; /* display flex */
width: auto;
}
.context-item__child {
height: 40px;
max-width: 200px;
line-height: 40px;
padding-left: 30px;
padding-right: 20px; /* adjust padding */
background-color: #4286f4;
border-right: 0 solid white;
border-top: 2px solid white;
border-bottom: 2px solid white;
text-align: center;
white-space: nowrap;
overflow: hidden;
position: relative; /* position relative */
text-overflow: ellipsis;
}
.context-item__child:first-child:before {
display:none;
}
.context-item__child:before { /* changed to next element's before */
height: 40px;
width: 30px;
top: -2px; /* fix for border */
left:-10px;
position: absolute;
z-index: 1;
background-color: #4286f4;
border-right: 2px solid white;
border-top: 2px solid white;
border-bottom: 2px solid white;
border-top-right-radius: 30px;
border-bottom-right-radius: 30px;
content: '';
}
.context-item__child:last-child { /* changed to next element's before */
padding-right: 40px;
}
.interaction-area:after { /* changed to next element's before */
height: 40px;
width: 30px;
top: -2px;
right: 0;
z-index: 1;
background-color: #4286f4;
border-right: 2px solid white;
border-top: 2px solid white;
border-bottom: 2px solid white;
border-top-right-radius: 30px;
border-bottom-right-radius: 30px;
content: '';
}
<body>
<div class="interaction-area">
<div class="context-item__child">T</div>
<div class="context-item__child">DE FINIBUS BONORUM ET MALO</div>
<div class="context-item__child">NIHIL IMPEDIT QUO MINUS ID QUOD MAXIME</div>
<div class="context-item__child">DE FINIBUS BONORUM ET MALORUM</div>
<div class="context-item__child">NIHIL IMPEDIT QUO MINUS ID QUOD MAXIME</div>
</div>
</body>
Here is how I'd do this:
.interaction-area {
height: 30px;
font-family: sans-serif;
font-size: small;
color: white;
}
.context-item__child {
height: 40px;
max-width: 200px;
line-height: 40px;
padding-left: 40px;
padding-right: 30px;
display: inline-block;
background-color: #4286f4;
border-top: 2px solid white;
border-bottom: 2px solid white;
text-align: center;
position: relative;
float: left;
border-radius: 0 22px 22px 0;
margin-left: -30px;
}
.context-item__child:last-child {
}
.context-item__child span {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 100%;
display: inline-block;
}
.context-item__child:after {
height: 40px;
width: 30px;
right: 0;
top: -2px;
position: absolute;
display: inline-block;
z-index: 1;
background-color: #4286f4;
border-right: 2px solid white;
border-top: 2px solid white;
border-bottom: 2px solid white;
border-top-right-radius: 30px;
border-bottom-right-radius: 30px;
content: '';
}
<body>
<div class="interaction-area">
<div class="context-item__child"><span>T</span></div>
<div class="context-item__child"><span>DE FINIBUS BONORUM ET MALO</span></div>
<div class="context-item__child"><span>NIHIL IMPEDIT QUO MINUS ID QUOD MAXIME</span></div>
<div class="context-item__child"><span>DE FINIBUS BONORUM ET MALORUM</span></div>
<div class="context-item__child"><span>NIHIL IMPEDIT QUO MINUS ID QUOD MAXIME</span></div>
</div>
</body>
What I did was:
moved the ellipsis down a level
applied position:relative to the menu items so their pseudo-elements would be positioned relative to them
made each item have the proper border-radius so they could wrap without breaking UI.
adjusted paddings/margins to the new changes.
Related
I want to make a line between two circles, for that, I have used the below code by using pseudo-element CSS. I would like to make the line between these two circles responsive, now it's intersecting with circle in some other devices like mobile, etc. How to make it responsive or any other solution that does the same design? Please help.
.cart_header_tab {
display: flex;
margin-top: 35px;
}
.cart_header_tab > div {
text-align: center;
margin-right: 100px;
cursor: pointer;
}
.cart_header_tab h6 {
color:#02b5f9;
font-weight: 400;
}
.cart_header_tab div:last-child h6 {
color:#ccc
}
span.circle_one::after {
content: "";
width: 152px;
height: 1px;
background: #eee;
position: absolute;
top: 6px;
left: 14px;
}
.cart_header_tab span.circle_one {
border: 1px solid #2fe4ba;
}
.cart_header_tab span {
display: inline-block;
width: 16px;
height: 16px;
border: 1px solid #ccc;
border-radius: 100%;
position: relative;
}
<div class="cart_header_tab">
<div>
<span class="circle_one"></span>
<h6>Order Details</h6>
</div>
<div>
<span class="circle_two"></span>
<h6>Freight Options</h6>
</div>
</div>
You can start tweaking the code something like this:
Be aware that if you wanted to change the size or width of the circle you have to tweak the other property in the css, hope that is not an issue here.
#cart_header_tab {
position: relative;
display: inline-block;
}
#cart_header_tab::after {
content: "";
position: absolute;
width: 50%;
z-index: -1;
top: 20%;
left: 25%;
border: 1px solid gray;
/* line between circles */
}
#cart_header_tab div {
display: inline-block;
font-size: 12px;
text-align: center;
min-width: 150px;
}
#cart_header_tab span {
color: white;
background: white;
display: block;
height: 15px;
margin: 0 auto 10px;
padding-top: 20px;
width: 30px;
border-radius: 50%;
border: 1px solid #22A7F2;
}
<div id="cart_header_tab">
<div><span class="circle_one"></span>
<h6>Order Details</h6>
</div>
<div><span class="circle_two"></span>
<h6>Freight Options</h6>
</div>
</div>
Using flex i insert that line between circle as separator itself is a child of flex and hen using margin adjust that according to circles
.cart_header_tab {
display: flex;
margin-top: 35px;
}
.cart_header_tab>div {
text-align: center;
cursor: pointer;
}
.cart_header_tab h6 {
color: #02b5f9;
font-weight: 400;
}
.cart_header_tab div:last-child h6 {
color: #ccc
}
.cart_header_tab {
position: relative
}
.sep {
width: 100%;
height: 1px;
background: #eee;
margin: 9px -21px 0;
}
.cart_header_tab span.circle_one {
border: 1px solid #2fe4ba;
background: #fff;
z-index: 1;
}
.circle_two {
background: #fff;
z-index: 1;
}
.cart_header_tab span {
display: inline-block;
width: 16px;
height: 16px;
border: 1px solid #ccc;
border-radius: 100%;
position: relative;
}
<div class="cart_header_tab">
<div>
<span class="circle_one"></span>
<h6>Order Details</h6>
</div>
<div class="sep"></div>
<div>
<span class="circle_two"></span>
<h6>Freight Options</h6>
</div>
</div>
I have a text in the middle of the div block with a font size 80px. When I hover on the div block, it will change the border size from 1px to 5px with a blue color but the text will moves down.
.calendar-content {
width: 81%;
display: block;
padding: 0;
background: #fff;
float: left;
position: relative;
margin-bottom: 150px;
}
.calendarday-container {
width: 139px;
height: 139px;
float: left;
position: relative;
margin-top: -1px;
margin-left: -1px;
border: 1px solid #ccc;
}
.calendarday-add .calendarday-number {
display: inline-block;
width: 100%;
font-size: 80px;
color: #f1f1f1;
margin: 12px 0px;
text-align: center;
}
.calendarday-number:hover {
margin: 12px 2px;
}
.calendarday-container:hover {
border: 5px solid #2e7ad1;
}
.add-day-ico {
display: none;
width: 21px;
height: 21px;
margin: 22px 0px;
float: right;
}
.calendarday-container:hover .add-day-ico {
display: block;
margin: 22px 0px;
}
<div class="calendarday-container" data-day="0" data-dropable="true">
<a href="/autoresponder/create_day.php?day=0" data-action="click" class="calendarday-add">
<span class="calendarday-number">0</span>
<img src="http://www.clker.com/cliparts/u/F/K/J/M/A/add-button-md.png" sytle="height: 21px; width: 21px;" align="right" style="margin-top: 3px;" class="add-day-ico">
</a>
</div>
Jsfiddle: http://jsfiddle.net/f0k6r9nb/
I have tried to change the margin in the calendarday-container:hover .add-day-ico but it didn't help to resolve the issue.
Can you please show me an example how I can stop the text moving down on hover?
Thank you.
Changing the width of the border from 1px to 5px and recalculating the inner parts is not a practical solution. You could use an additional element, which has 5px of transparent border and change it to 5px of colored border on hover.
Another simple solution would be to use outline instead, as it doesn't add to the elements dimensions:
.calendar-content {
width: 81%;
display: block;
padding: 0;
background: #fff;
float: left;
position: relative;
margin-bottom: 150px;
}
.calendarday-container {
width: 139px;
height: 139px;
float: left;
position: relative;
margin-top: -1px;
margin-left: -1px;
border: 1px solid #ccc;
}
.calendarday-container:hover {
outline: 5px solid #2e7ad1;
}
.calendarday-add .calendarday-number {
display: inline-block;
width: 100%;
font-size: 80px;
color: #f1f1f1;
margin: 12px 0px;
text-align: center;
}
.add-day-ico {
opacity: 0;
width: 21px;
height: 21px;
position: absolute;
bottom: 0;
right: 0;
}
.calendarday-container:hover img {
opacity: 1;
}
<div class="calendarday-container" data-day="0" data-dropable="true">
<a href="/autoresponder/create_day.php?day=0" data-action="click" class="calendarday-add">
<span class="calendarday-number">0</span>
<img src="http://www.clker.com/cliparts/u/F/K/J/M/A/add-button-md.png" class="add-day-ico">
</a>
</div>
A typical approach to showing a border on hover is to have the non-hover state be transparent or a color that matches the background along with the width matching that of the border when hovered.
In this case, there's an existing 1px border. Here, I would change the gray border blue, then use an inset box-shadow to add the additional 4px of the border.
Note: I also removed some margin for .calendarday-number on hover so the number does not shift.
.calendar-content {
width: 81%;
display: block;
padding: 0;
background: #fff;
float: left;
position: relative;
margin-bottom: 150px;
}
.calendarday-container {
width: 139px;
height: 139px;
float: left;
position: relative;
margin-top: -1px;
margin-left: -1px;
border: 1px solid #ccc;
}
.calendarday-add .calendarday-number {
display: inline-block;
width: 100%;
font-size: 80px;
color: #f1f1f1;
margin: 12px 0px;
text-align: center;
}
/*
.calendarday-number:hover {
margin: 12px 2px;
}
*/
.calendarday-container:hover {
border-color: #2e7ad1;
box-shadow: inset 0 0 0 4px #2e7ad1;
}
.add-day-ico {
display: none;
width: 21px;
height: 21px;
margin: 22px 0px;
float: right;
}
.calendarday-container:hover .add-day-ico {
display: block;
margin: 22px 0px;
}
<div class="calendarday-container" data-day="0" data-dropable="true">
<a href="/autoresponder/create_day.php?day=0" data-action="click" class="calendarday-add">
<span class="calendarday-number">0</span>
<img src="http://www.clker.com/cliparts/u/F/K/J/M/A/add-button-md.png" sytle="height: 21px; width: 21px;" align="right" style="margin-top: 3px;" class="add-day-ico">
</a>
</div>
Add this:
.calendarday-container {
border: 5px solid transparent;
outline: 1px solid #ccc;
outline: none;
}
.calendarday-container:hover {
outline: none;
}
Remove this:
.calendarday-number:hover {
margin: 12px 2px;
}
You can use a pseudo element like this. I also removed lot of unnecessary css that was fighting each other
* { margin: 0; padding: 0; box-sizing: border-box; }
body { margin: 5%; }
/* Normal */
.calendarday-container {
width: 150px; height: 150px;
position: relative;
display: flex; align-items: center; justify-content: center;
}
.calendarday-container:after {
content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0;
border: 1px solid #ccc; z-index: -1;
}
.caldndarday-add { text-decoration: none; }
.calendarday-number { font-size: 80px; color: #ccc; }
.add-day-ico { width: 24px; height: 24px; position: absolute; bottom: -8px; right: -8px; }
/* Hover FX */
.calendarday-container:hover:after { border: 10px solid navy; }
.calendarday-container:hover .calendarday-number { color: navy; }
<div class="calendarday-container" data-day="0" data-dropable="true">
<a class="caldndarday-add" href="/autoresponder/create_day.php?day=0" data-action="click">
<span class="calendarday-number">0</span>
<img class="add-day-ico" src="http://www.clker.com/cliparts/u/F/K/J/M/A/add-button-md.png">
</a>
</div>
The text was moving down because, There was increase in border-width from 1px to 5px while hover.
You can either maintain a outline around the box using outline property, and keeping the border: 5px solid transparent to border: 5px solid #2e7ad1 while hovering.
I've created a working fiddle for you, for better understanding: Link to Jsfiddle
I'm having an issue with some text that doesn't want to create a line break: when narrowing the browser window, it makes the text go on top of itself. How is it possible to fix this?
See the h1 and p text here:
http://jsfiddle.net/wWJqm/ and try resizing down your browser window.
HTML:
<div class="meteor">
<img width="599" height="400" src="http://imageshack.com/a/img197/9543/2v8z.jpg" />
<h1>Nulla eu purus et orci</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
CSS:
.meteor h1 {
position: absolute;
margin: 0;
top: 20px;
left: 30px;
font-size:24px;
line-height:1px;
text-align: center;
text-shadow: 1px 1px 0 #000;
padding: 2.3%;
background: #000;
}
.meteor p {
background: #000;
top: 50px;
left: 30px;
color: #fff;
line-height:1px;
margin: 0;
padding: 2%;
position: absolute;
text-align: center;
text-shadow: 1px 1px 1px #000;
}
Try this
.meteor p {
background: #000;
min-height:inherit;
max-height:auto;
top: 50px;
left: 30px;
color: #fff;
margin: 0;
padding: 2%;
position: absolute;
text-align: center;
word-wrap: break-word;
text-shadow: 1px 1px 1px #000;
}
your line height was set to 1px, it was moving, but it was only moving down one pixel which is almost unnoticeable.
get rid of the line-height, or change it. Add in a word wrap, and a min/max-width and height is optional too.
I think it's the line-height and the fact that your wrapper doesn't seem to have position:relative
JSFiddle Demo
CSS
.meteor {
background-color: lightgrey;
position: relative;
font-size:16px;
}
.meteor img {
max-width: 100%;
height:auto;
position: absolute;
top:0;
}
.meteor h1 {
position: absolute;
margin: 0;
top: 20px;
left: 30px;
line-height: 1em;
font-size:24px;
text-align: center;
text-shadow: 1px 1px 0 #000;
padding: 2.3%;
background: #000;
}
.meteor p {
background: #000;
top:100px;
left: 30px;
color: #fff;
line-height:1em;
margin: 0;
padding: 2%;
position: absolute;
text-align: center;
text-shadow: 1px 1px 1px #000;
}
I trying to create a html page which looks like similar to Messages(thread view) just as in our android and iphone devices.
Here is what i have coded
Css styles:
<style type='text/css'>
.triangle-right
{
position:relative;
padding:15px;
color:#fff;
background:#075698;
background:-webkit-gradient(linear, 0 0, 0 100%, from(#2e88c4), to(#075698)); background:-moz-linear-gradient(#2e88c4, #075698);
background:-o-linear-gradient(#2e88c4, #075698);
background:linear-gradient(#2e88c4, #075698);
-webkit-border-radius:10px;
-moz-border-radius:10px;
border-radius:10px;
}
.triangle-right.top
{
background:-webkit-gradient(linear, 0 0, 0 100%, from(#075698), to(#2e88c4));
background:-moz-linear-gradient(#075698, #2e88c4);
background:-o-linear-gradient(#075698, #2e88c4);
background:linear-gradient(#075698, #2e88c4);
}
.triangle-right.left
{
margin-left:10px;background:#075698;
}
.triangle-right.right
{
margin-right:10px; background:#075698;
}
.triangle-right:after
{
content:'';
position:absolute;
bottom:-20px;left:50px;border-width:20px 0 0 20px;border-style:solid;border-color:#075698 transparent; display:block;width:0;
}
.triangle-right.top:after
{
top:-20px;right:50px;bottom:auto;left:auto;border-width:20px 20px 0 0;border-color:transparent #075698;
}
.triangle-right.left:after
{
top:16px;left:-15px; bottom:auto;border-width:0 15px 15px 0;border-color:transparent #E8E177;
}
.triangle-right.right:after
{
top:16px;right:-15px;bottom:auto;left:auto;border-width:0 0 15px 15px; border-color:transparent #8EC3E2 ;
}
.triangle
{
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 100px solid transparent;
border-bottom: 50px solid #fc2e5a;
}
I tried changing some values in
.triangle-right.left:after
{
top:16px;left:-15px; bottom:auto;border-width:0 15px 15px 0;border-color:transparent #E8E177;
}
.triangle-right.right:after
{
top:16px;right:-15px;bottom:auto;left:auto;border-width:0 0 15px 15px; border-color:transparent #8EC3E2 ;
}
but not getting the exact shapes as desired.
I need to construct the bubble in the following fashion
Can anyone help me
The HTML
<div class="chat">
<div class="yours messages">
<div class="message last">
Hello, how's it going?
</div>
</div>
<div class="mine messages">
<div class="message">
Great thanks!
</div>
<div class="message last">
How about you?
</div>
</div>
</div>
The CSS
body {
font-family: helvetica;
display: flex ;
flex-direction: column;
align-items: center;
}
.chat {
width: 300px;
border: solid 1px #EEE;
display: flex;
flex-direction: column;
padding: 10px;
}
.messages {
margin-top: 30px;
display: flex;
flex-direction: column;
}
.message {
border-radius: 20px;
padding: 8px 15px;
margin-top: 5px;
margin-bottom: 5px;
display: inline-block;
}
.yours {
align-items: flex-start;
}
.yours .message {
margin-right: 25%;
background-color: #EEE;
position: relative;
}
.yours .message.last:before {
content: "";
position: absolute;
z-index: 0;
bottom: 0;
left: -7px;
height: 20px;
width: 20px;
background: #EEE;
border-bottom-right-radius: 15px;
}
.yours .message.last:after {
content: "";
position: absolute;
z-index: 1;
bottom: 0;
left: -10px;
width: 10px;
height: 20px;
background: white;
border-bottom-right-radius: 10px;
}
.mine {
align-items: flex-end;
}
.mine .message {
color: white;
margin-left: 25%;
background: rgb(0, 120, 254);
position: relative;
}
.mine .message.last:before {
content: "";
position: absolute;
z-index: 0;
bottom: 0;
right: -8px;
height: 20px;
width: 20px;
background: rgb(0, 120, 254);
border-bottom-left-radius: 15px;
}
.mine .message.last:after {
content: "";
position: absolute;
z-index: 1;
bottom: 0;
right: -10px;
width: 10px;
height: 20px;
background: white;
border-bottom-left-radius: 10px;
}
https://codepen.io/swards/pen/gxQmbj
I know this answer is old, but for anyone looking for new iOS iMessage style check this.
body {
font-family: "Helvetica Neue";
font-size: 20px;
font-weight: normal;
}
section {
max-width: 450px;
margin: 50px auto;
}
section div {
max-width: 255px;
word-wrap: break-word;
margin-bottom: 20px;
line-height: 24px;
}
.clear {
clear: both;
}
.from-me {
position: relative;
padding: 10px 20px;
color: white;
background: #0B93F6;
border-radius: 25px;
float: right;
}
.from-me:before {
content: "";
position: absolute;
z-index: -1;
bottom: -2px;
right: -7px;
height: 20px;
border-right: 20px solid #0B93F6;
border-bottom-left-radius: 16px 14px;
-webkit-transform: translate(0, -2px);
}
.from-me:after {
content: "";
position: absolute;
z-index: 1;
bottom: -2px;
right: -56px;
width: 26px;
height: 20px;
background: white;
border-bottom-left-radius: 10px;
-webkit-transform: translate(-30px, -2px);
}
.from-them {
position: relative;
padding: 10px 20px;
background: #E5E5EA;
border-radius: 25px;
color: black;
float: left;
}
.from-them:before {
content: "";
position: absolute;
z-index: 2;
bottom: -2px;
left: -7px;
height: 20px;
border-left: 20px solid #E5E5EA;
border-bottom-right-radius: 16px 14px;
-webkit-transform: translate(0, -2px);
}
.from-them:after {
content: "";
position: absolute;
z-index: 3;
bottom: -2px;
left: 4px;
width: 26px;
height: 20px;
background: white;
border-bottom-right-radius: 10px;
-webkit-transform: translate(-30px, -2px);
}
<section>
<div class="from-me">
<p>Hey there! What's up?</p>
</div>
<div class="clear"></div>
<div class="from-them">
<p>Checking out iOS7 you know..</p>
</div>
<div class="clear"></div>
<div class="from-me">
<p>Check out this bubble!</p>
</div>
<div class="clear"></div>
<div class="from-them">
<p>It's pretty cool!</p>
</div>
<div class="clear"></div>
<div class="from-me">
<p>Yeah it's pure CSS & HTML</p>
</div>
<div class="clear"></div>
<div class="from-them">
<p>Wow that's impressive. But what's even more impressive is that this bubble is really high.</p>
</div>
</section>
Source
Try this code For Thread view Messages.
<div class="messages scroll">
<div class="item blue">
<div class="arrow"></div>
<div class="text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ut diam quis dolor mollis tristique. Suspendisse vestibulum convallis felis vitae facilisis. Praesent eu nisi vestibulum erat.
</div>
<div class="date">09.02.2013, 21:04</div>
</div>
<div>
Css Styles
/* messages */
.body .content .block .messages{position: relative;}
.body .content .block .messages .item{width: 90%; padding: 5px; position: relative; margin: 10px 0px 0px; float: left;}
.body .content .block .messages .item.out{float: right; margin: 10px 0px 10px;}
.body .content .block .messages .item .arrow{border-color: transparent transparent #009AD7 #009AD7; border-style: solid; border-width: 5px;width: 0px; height: 0px; position:absolute; left: 10px; top: -10px;}
.body .content .block .messages .item.out .arrow{left: auto; top: auto; right: 10px; bottom: -10px; border-color: #005683 #005683 transparent transparent;}
.body .content .block .messages .item .text{font-size: 12px; color: #FFF; line-height: 13px;}
.body .content .block .messages .item .date{font-size: 12px; color: #FFF; text-align: right; opacity: 0.6; filter: alpha(opacity=60); line-height: 13px;}
/* eof messages */
Thanks,
Kamalakannan.M
Here is a simple pure css3 solution for creating chat bubble quite similar to iOS. I would go with this cleaner look... This is not using any image and its responsive for different device sizes. Here is the Working code. Came across this website and improvised css little bit to create pointer without image....
HTML
<div class="commentArea">
<div class="bubbledRight">
Error dicunt theophrastus cu qui. Ad eos simul possit option, adipisci principes sed at. Detracto adolescens pro ea, duo no
</div>
<div class="bubbledLeft">
Lorem ipsum dolor sit amet, ea oblique constituam signiferumque eam. Pri adipisci maluisset te.
</div>
CSS
.commentArea {
font: 14px Arial;
padding: 0 10px;
margin-top: 20px;
}
.bubbledLeft,.bubbledRight {
margin-top: 20px;
padding: 5px 9px;
max-width: 50%;
clear: both;
position: relative;
}
.bubbledLeft{
float: left;
margin-right: auto;
-webkit-border-radius: 8px 8px 8px 0px;
-moz-border-radius: 8px 8px 8px 0px;
-o-border-radius: 8px 8px 8px 0px;
-ms-border-radius: 8px 8px 8px 0px;
border-radius: 8px 8px 8px 0px;
background-color: #65B045;
color: #ffffff;
}
.bubbledLeft:before {
border-bottom: 10px solid #65B045;
border-left: 9px solid rgba(0, 0, 0, 0);
position: absolute;
bottom: 0;
left: -8px;
content: "";
}
.bubbledRight{
float: right;
margin-left: auto;
text-align: right;
-webkit-border-radius: 8px 8px 0px 8px;
-moz-border-radius: 8px 8px 0px 8px;
-o-border-radius: 8px 8px 0px 8px;
-ms-border-radius: 8px 8px 0px 8px;
border-radius: 8px 8px 0px 8px;
background-color: #07D;
color: white;
}
.bubbledRight:before {
border-bottom: 9px solid #07D;
border-right: 9px solid rgba(0, 0, 0, 0);
position: absolute;
bottom: 0;
right: -8px;
content: "";
}
I'm building a fairly interestingly shaped navigation for a site at the moment. The shape each menu item needs to be is illustrated below:
The final nav will look like an extended version of this:
I thought it would be an interesting experiment to do these shapes in CSS. The CSS and HTML for one of the arrow shapes is here:
.arrowEndOn {
font-size: 10px; line-height: 0%; width: 0px;
border-top: 11px solid #FFFFFF;
border-bottom: 11px solid #FFFFFF;
border-left: 5px solid transparent;
border-right: 5px solid #FFFFFF;
float: left;
cursor: pointer;
}
.arrowBulkOn {
height: 20px;
background: #FFFFFF;
padding: 2px 5px 0px 0px;
float: left;
color: #000000;
line-height: 14pt;
cursor: pointer;
}
.arrowStartOn {
font-size: 0px; line-height: 0%; width: 0px;
border-top: 11px solid transparent;
border-bottom: 11px solid transparent;
border-left: 5px solid #FFFFFF;
border-right: 0px solid transparent;
float: left;
cursor: pointer;
}
<div id="nav" class="navArrow" style="position: relative;">
<div class="arrowEndOn" id="nav"> </div>
<div class="arrowBulkOn" id="nav">NAV</div>
<div class="arrowStartOn" id="nav"> </div>
</div>
Each nav item has a negative offset applied to it (which I've left out of the demo) as it's rendered to get them all flush with each other.
I'm handling the rollovers and on states with Javascript.
My problem is getting the nav to stretch all the way across the width of the page. At the moment I have to set the nav container to a much larger width to accommodate it all.
I've tried setting overflow to hidden but the last item is dropping down a level rather than carrying on and just having the end cut off.
I've set an example up here - http://jsfiddle.net/spacebeers/S7hzu/1/
The red border has overflow: hidden; and the blue doesn't.]
My question is: How can I get the boxes to all float in a line that fills the width of the containing div without them dropping down a level.
Thanks
Add a negative margin to each arrow:
.navArrow {
float: left;
margin-left: -8px;
}
Demo: http://jsfiddle.net/S7hzu/2/
Flexbox
You can use this example
https://codepen.io/WBear/pen/pPYrwo
it works on new browsers, to support old ones some changes needed.
HTML:
<div class="content">
<div class="as1">
NAV
</div>
<div class="as2">
NAV
</div>
<div class="as3">
NAV
</div>
</div>
CSS:
.content {
margin-top: 10px;
width: 100%;
display: inline-flex;
}
.as1, .as2, .as3 {
height: 70px;
min-width: 8%;
max-width: 100%;
background-color: black;
position: relative;
display: inline-flex;
text-align: center;
flex-wrap: wrap;
flex-grow: 1;
}
.as1 a, .as2 a, .as3 a {
text-decoration: none;
display: inline-flex;
color: white;
margin: auto;
font-size: 14pt;
}
.as1:after {
content: "";
position: absolute;
right: 4px;
border-top: 35px solid transparent;
border-left: 25px solid black;
border-bottom: 35px solid transparent;
z-index: 2;
}
.as2 {
background-color: grey;
margin-left: -29px;
}
.as2:after {
content: "";
position: absolute;
right: 4px;
border-top: 35px solid transparent;
border-left: 25px solid grey;
border-bottom: 35px solid transparent;
z-index: 3;
}
.as3 {
background-color: #A9A9A9;
margin-left: -29px;
}