i am using Ionic2 and have an app that has messages. the message looks as follows in a browser:
However, running on an Android or iOS device, it looks as follows:
As you can see, the tail on each message is missing.
Question
If anyone can advise how I can get the style to be consistent and display the tail on all devices?
HTML
<ion-content padding class="messages-page-content">
<ion-list class="message-list">
<ion-item class="message-item" *ngFor="let item of firelist | async">
<div [ngClass]="{'message message-me':(item.memberId1 == me.uid)}">
<div [ngClass]="{'message message-you':(item.memberId1 == you.uid)}">
<div class="message-content">{{item.message_text}}</div>
<span class="time-tick">
<span class="message-timestamp-date">{{item.timestamp | amDateFormat: 'D MMM YY'}}</span>
<span class="message-timestamp">{{item.timestamp | amDateFormat: 'h:mm a'}}</span>
<div *ngIf="item.memberId1 === me.uid && item.readByReceiver === true">
<span class="checkmark">
<div class="checkmark_stem"></div>
<div class="checkmark_kick"></div>
</span>
</div>
</span>
</div>
</div>
</ion-item>
</ion-list>
</ion-content>
CSS
See: background-image: url(/assets/message-me.png); and background-image: url(/assets/message-you.png);
.title-timestamp {
font-size: 11px;
color: gray;
}
.message-item {
background-color: transparent;
}
.label {
overflow: visible;
white-space: normal;
}
.message-send {
font-size: 3.2em;
}
.input-wrapper {
overflow: visible;
}
.item-md.item-block .item-inner {
padding-left: 8px;
}
.messages-page-navbar {
.chat-picture {
width: 50px;
border-radius: 50%;
float: left;
}
.chat-title {
line-height: 27px;
display: inline-block;
}
.chat-subtitle {
font-size: 11px;
padding: 0px;
}
}
.messages-page-content {
> scroll-content {
padding: 0;
}
.message-list {
background-color: #E0DAD6;
background-repeat: no-repeat;
background-size: cover;
}
.message-wrapper {
margin-bottom: 9px;
&::after {
content: "";
display: table;
clear: both;
}
}
.message {
display: inline-block;
position: relative;
max-width: 236px;
border-radius: 7px;
box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
&.message-me {
float: right;
background-color: #effeff;
&::before {
right: -11px;
background-image: url(/assets/message-me.png);
}
}
&.message-you {
float: left;
background-color: #FFF;
&::before {
left: -11px;
background-image: url(/assets/message-you.png);
}
}
&.message-you::before, &.message-me::before {
content: "";
position: absolute;
bottom: 3px;
width: 12px;
height: 19px;
background-position: 50% 50%;
background-repeat: no-repeat;
background-size: contain;
}
.message-content {
padding: 5px 7px;
word-wrap: break-word;
&::after {
content: " \00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0\00a0";
display: inline;
}
}
.message-timestamp {
position: absolute;
bottom: 2px;
right: 17px;
font-size: 11px;
color: gray;
}
.message-timestamp-date {
position: relative;
bottom: 2px;
right: -6px;
font-size: 9px;
color: gray;
}
}
}
.message-datetime {
font-size: 11px;
color: grey;
}
.messages-page-footer {
padding-right: 0;
.message-editor {
margin-left: 2px;
padding-left: 5px;
background: white;
border-radius: 3px;
}
.message-editor-button {
background: color($colors, primary);
box-shadow: none;
width: 50px;
height: 50px;
font-size: 17px;
margin: auto;
}
}
.checkmark {
display:inline-block;
width: 22px;
height:22px;
-ms-transform: rotate(45deg); /* IE 9 */
-webkit-transform: rotate(45deg); /* Chrome, Safari, Opera */
transform: rotate(45deg);
position: absolute;
bottom: 2px;
right: 1px;
}
.checkmark_stem {
position: absolute;
width:2px;
height:9px;
background-color:#3BB9FF;
left:15px;
top:6px;
}
.checkmark_kick {
position: absolute;
width:2px;
height:3px;
background-color:#3BB9FF;
left:13px;
top:12px;
}
.time-tick {
display:inline-block;
}
UPDATE
Thanks to the advise below, I add the following:
CSS
.tail-me {
background-image: url(/assets/message-me.png);
background-repeat: no-repeat;
bottom: 0;
right: -11px
}
.tail-you {
background-image: url(/assets/message-you.png);
background-repeat: no-repeat;
bottom: 0;
left: -11px
}
HTML
<ion-item class="message-item tail-me" *ngFor="let item of firelist | async">
And it displays this in the browser:
As you can see, the tail is in the wrong position. If I make the position: absolute, it throws the message out totally. The left and bottom css attributes move the message bubbles. So I am guessing I am putting the tail-me on the wrong tag in the html. Any ideas?
On an iOS and Android device, it still does not display the tail:
It seems like the Android and iOS versions don't process pseudo elements correctly. I would try another method such as creating a class element that is placed in .message-me and .message-you.
Append that class element to each message box, and add an absolute positioning to it so that it's:
.tail-me {
background-image: url(/assets/message-me.png);
position: absolute;
bottom: 0;
right: -11px
}
and
.tail-you {
background-image: url(/assets/message-you.png);
position: absolute;
bottom: 0;
left: -11px
}
An absolutely positioned element inside of a relatively positioned element (your .message), will be placed inside of that relative position element.
It was a silly mistake on my part. It does work on a devise. The issue was the path to the image was incorrect, so the devise was not picking up the image.
Was:
background-image: url(/assets/message-me.png);
Should be:
background-image: url(../assets/message-me.png);
Related
I have to create a progress bar that has to be fully responsive. In order to be responsive I don't want the progress bar class to have a fixed width, but when I put auto in width, line of progress bar is detached from the star also if I give to them auto width
Fixed width: look good
Width auto
First how can I fix this issue, and perhaps someone can help me achieve this progress bar to be responsive on mobile also so that the line of progress bar will be vertical.
.progress-bar {
width: 750px;
display: flex;
margin: 40px 0;
}
.progress-bar .step {
text-align: center;
width: 100%;
}
.progress-bar .step .bullet {
position: relative;
height: 25px;
width: 25px;
display: inline-block;
}
.progress-bar .step:last-child .bullet:before,
.progress-bar .step:last-child .bullet::after {
display: none;
}
.progress-bar .step .bullet:before,
.progress-bar .step .bullet::after {
position: absolute;
content: "";
height: 3px;
right: -136px;
bottom: 11px;
width: 142px;
background: #C1C1C1;
}
.active-bullet {
z-index: 1;
}
.active-check {
z-index: 2;
}
<div class="progress-bar">
<div class="step">
<div class="bullet active-bullet">
<img src="star-pb-active.svg">
</div>
<div class="check active-check" style="
border-bottom: 2px solid black;
padding: 2px;
DISPLAY: table-cell;
LEFT: 40px;
POSITION: relative;
">Order placed</div>
</div>
<div class="step">
<div class="bullet">
<img src="star-pb.svg">
</div>
<div class="check">Jewerly Creation</div>
</div>
<div class="step">
<div class="bullet">
<img src="star-pb.svg">
</div>
<div class="check">Packing & Quality Control</div>
</div>
<div class="step">
<div class="bullet">
<img src="star-pb.svg">
</div>
<div class="check">Shipped</div>
</div>
<div class="step">
<div class="bullet">
<img src="star-pb.svg">
</div>
<div class="check">Estimated Delivery</div>
</div>
</div>
You should try taking a look at the flex-grow property from Flexbox.
By giving display: flex to the parent, and flex-grow: 1 to the children, you should be able to make every step be the same size and take all the width of their container.
It works the way you want, in fixed or auto width.
.progress-bar {
width: auto;
display: flex;
margin: 40px 0;
}
.progress-bar .step {
text-align: center;
position: relative;
isolation: isolate;
width: 100%;
}
.progress-bar .step::after {
content: "";
position: absolute;
z-index: -1;
height: 3px;
top: 12px; /* 1/2 of .bullet's height */
width: 100%;
background: #C1C1C1;
}
.progress-bar .step:last-child::after {
display: none;
}
.progress-bar .step .bullet {
position: relative;
height: 25px;
width: 25px;
display: inline-block;
}
.active-bullet {
z-index: 1;
}
.active-check {
z-index: 2;
}
Added pseudo element on the parent of .bullet.
Also you don't need ::before, one of those pseudo elements was enough.
try below code, your code some confusion.
use flex in css
below sample add one button which goes your activity to next step
it is fully responsive - on desktop this code horizontal and on mobile this code show vertical progressbar.
just use small js, css and for tick icon font awesome js.
if any query comment it.
let step = 'step1';
const step1 = document.getElementById('step1');
const step2 = document.getElementById('step2');
const step3 = document.getElementById('step3');
const step4 = document.getElementById('step4');
function next() {
if (step === 'step1') {
step = 'step2';
step1.classList.remove("is-active");
step1.classList.add("is-complete");
step2.classList.add("is-active");
} else if (step === 'step2') {
step = 'step3';
step2.classList.remove("is-active");
step2.classList.add("is-complete");
step3.classList.add("is-active");
} else if (step === 'step3') {
step = 'step4d';
step3.classList.remove("is-active");
step3.classList.add("is-complete");
step4.classList.add("is-active");
} else if (step === 'step4d') {
step = 'complete';
step4.classList.remove("is-active");
step4.classList.add("is-complete");
} else if (step === 'complete') {
step = 'step1';
step4.classList.remove("is-complete");
step3.classList.remove("is-complete");
step2.classList.remove("is-complete");
step1.classList.remove("is-complete");
step1.classList.add("is-active");
}
}
.progress-bar {
position: relative;
display: flex;
}
.progress-bar .progress-track {
position: absolute;
top: 5px;
width: 100%;
height: 5px;
background-color: #dfe3e4;
z-index: -1;
}
.progress-bar .progress-step {
position: relative;
width: 100%;
font-size: 12px;
text-align: center;
}
.progress-bar .progress-step:last-child:after {
display: none;
}
.progress-bar .progress-step:before {
content: "\f00c";
display: flex;
margin: 0 auto;
margin-bottom: 10px;
width: 10px;
height: 10px;
background: #fff;
border: 4px solid #dfe3e4;
border-radius: 100%;
color: transparent;
}
.progress-bar .progress-step:after {
content: "";
position: absolute;
top: 6px;
left: 50%;
width: 0%;
transition: width 1s ease-in;
height: 5px;
background: #dfe3e4;
z-index: -1;
}
#media screen and (max-width:700px) {
.progress-bar {
position: relative;
display: inline-block;
}
.progress-bar .progress-track {
position: absolute;
top: -10px;
width: 100%;
height: 5px;
background-color: #dfe3e4;
z-index: -1;
transform: rotate(90deg);
}
.progress-bar .progress-step {
position: relative;
width: 100%;
font-size: 12px;
text-align: center;
}
.progress-bar .progress-step:last-child:after {
display: none;
}
.progrestext
{
left: 44px;
position: absolute;
top: 0px;
}
.progress-bar .progress-step:after {
content: "";
position: absolute;
top: 20px;
left: 0%;
width: 0%;
transition: width 1s ease-in;
height: 5px;
background: #dfe3e4;
z-index: -1;
transform: rotate(90deg);
}
}
.progress-bar .progress-step.is-active {
color: #2183dd;
}
.progress-bar .progress-step.is-active:before {
border: 4px solid #777;
animation: pulse 2s infinite;
}
.progress-bar .progress-step.is-complete {
color: #009900;
}
.progress-bar .progress-step.is-complete:before {
font-family: FontAwesome;
font-size: 10px;
color: #fff;
background: #009900;
border: 4px solid transparent;
}
.progress-bar .progress-step.is-complete:after {
background: #2183dd;
animation: nextStep 1s;
animation-fill-mode: forwards;
}
#keyframes pulse {
0% {
box-shadow: 0 0 0 0 rgba(33, 131, 221, 0.8);
}
70% {
box-shadow: 0 0 0 10px rgba(33, 131, 221, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(33, 131, 221, 0);
}
}
#keyframes nextStep {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
.container {
margin: 50px 100px;
}
button {
position: absolute;
right: 50px;
bottom: 20px;
cursor: pointer;
}
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://use.fontawesome.com/c47bc38e87.js"></script>
<div class="container">
<div class="progress-bar">
<div class="progress-track"></div>
<div id="step1" class="progress-step">
<div class="progrestext">placed</div>
</div>
<div id="step2" class="progress-step">
<div class="progrestext">Creation</div>
</div>
<div id="step3" class="progress-step">
<div class="progrestext">Packing</div>
</div>
<div id="step4" class="progress-step">
<div class="progrestext">Delivered</div>
</div>
</div>
<button onClick=next()>Next Step</button>
</div>
I'm working on Bookmarklet. After removing not-important parts, I have bottom docking draggable window and I want to add resizing. I will probably do this by hand (using mouse down/move/up), but I want to know why resize: both property doesn't work.
I have code like this:
<div class="shell-wrapper docking">
<div class="shell-container">
<nav>
<span class="shell-dock"></span>
<span class="shell-destroy">[x]</span>
</nav>
</div>
<div class="shell-mask"></div>
</div>
.shell-wrapper nav {
cursor: row-resize;
color: #ccc;
border-bottom: 1px solid #ccc;
font-family: monospace;
text-align: right;
background: black;
font-size: 13px;
line-height: initial;
margin: 0;
width: 100%;
height: auto;
display: block;
}
.shell-container {
position: fixed;
background: black;
z-index: 99999;
bottom: 0;
left: 0;
right: 0;
height: 150px;
}
.shell-wrapper .shell-destroy {
padding: 5px;
cursor: pointer;
display: inline-block;
}
.shell-wrapper .shell-mask{
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
display: none;
z-index: 100
}
.shell-wrapper.drag .shell-mask {
display: block;
}
.shell-wrapper .shell-dock,
.shell-wrapper .shell-destroy {
padding: 5px 3px;
cursor: pointer;
display: inline-block;
}
.shell-wrapper.docking nav {
cursor: default;
}
.shell-wrapper .shell-dock::before {
content: "[■]";
}
.shell-wrapper.docking .shell-dock::before {
content: "[_]";
}
.shell-wrapper.docking .shell-container {
bottom: auto;
right: auto;
top: calc(var(--top, 0) * 1px);
left: calc(var(--left, 0) * 1px);
width: calc(var(--width, 500) * 1px);
height: calc(var(--height, 400) * 1px);
box-shadow: 1px 1px 10px 2px rgb(0 0 0 / 30%);
resize: both; /* this have no effect */
}
You can check the Demo on CodePen.
The code uses jQuery but the question is not related. The problem is in CSS.
I have some code which is meant to render a curved boundary from a vertical to the bottom right as shown in the attached picture:
But as you can see, the text is not in the right spot... granted, it's 10 pixels from the main vertical right wall of the main part of the DIV, but the padding from the top is not 7px. I've tried rendering the "padding" using line-height, but what you see here is at line-height: 0... going any lower doesn't make it go any higher... Increasing it however, does push it further down.
Is there any I can render this code such that "ELBOW 1" appears 7px from the top of the DIV, and yet still retain the text content within the tag as a data attribute?
JSFiddle: https://jsfiddle.net/eliseo_d/b83d9ytL/3/
Code below:
HTML:
<div class="elbow-1-botrt-wide0-grey1" data-text="elbow 1"></div>
CSS:
html {
background-color: rgb(0,0,0);
font-family: Impact;
}
body {
margin: 5px;
}
div[class$='-grey1'] {
background-color: rgb(102,102,102);
}
div[class^='elbow-'] {
/* default settings */
color: rgb(0,0,0);
font-size: 14pt;
height: 67px;
margin-bottom: 4px;
margin-right: 21px;
text-transform: uppercase;
width: 104px;
position: relative;
}
div[class^='elbow-1-'] {
padding-top: 46px;
}
div[class^='elbow-'][class*='-botrt-'] {
border-bottom-left-radius: 42px;
}
/* elbow bar */
div[class^='elbow-'][class*='-botrt-']:before {
content: '';
height: 30px;
left: 104px;
bottom: 0;
position: absolute;
margin-right: 4px;
}
div[class^='elbow-'][class*='-wide0-']:before {
width: 21px;
}
div[class^='elbow-'][class$='-grey1']:before {
background-color: rgb(102,102,102);
}
/* inside curve */
div[class^='elbow-'][class*='-botrt-']:after {
height: 21px;
width: 73px;
bottom: 30px;
left: 21px;
padding-right: 31px;
position: absolute;
content: attr(data-text);
text-indent:-59px;
color: rgb(0,0,0);
text-align: right;
}
div[class^='elbow-1-'][class*='-botrt-']:after {
line-height: 0;
}
div[class^='elbow-'][class*='-botrt-'][class$='-grey1']:after {
background: radial-gradient(circle at 100% 0%, rgba(102,102,102,0) 21px, rgba(102,102,102,1) 21px);
}
Update: For some reason the Impact font isn't rendering correctly in the Fiddle... This won't be an issue in my original local code, but the padding issue from above still stands...
Yep, here we go.
html {
background-color: rgb(0, 0, 0);
font-family: Impact;
}
body {
margin: 5px;
}
div[class$='-grey1'] {
background-color: rgb(102, 102, 102);
}
div[class^='elbow-'] {
/* default settings */
color: rgb(0, 0, 0);
font-size: 14pt;
height: 67px;
margin-bottom: 4px;
margin-right: 21px;
text-transform: uppercase;
width: 104px;
position: relative;
}
div[class^='elbow-1-'] {
padding-top: 46px;
}
div[class^='elbow-'][class*='-botrt-'] {
border-bottom-left-radius: 42px;
}
/* elbow bar & inner curve */
div[class^='elbow-'][class*='-botrt-']:before {
content: '';
height: 52px;
width: 21px;
left: 100%;
bottom: 0;
position: absolute;
/* inside curve */
background: radial-gradient(circle at top right, transparent, transparent 21px, rgb(102, 102, 102) 21px);
}
/* text content */
div[class^='elbow-'][class*='-botrt-']:after {
top: 10px;
left: 50%;
transform: translateX(-50%);
white-space: nowrap;
position: absolute;
content: attr(data-text);
color: rgb(0, 0, 0);
}
<div class="elbow-1-botrt-wide0-grey1" data-text="elbow 1"></div>
Please try this code sample sample pen
body {
background: #000;
}
.elbow {
background: rgb(102,102,102);
color: red;
width: 150px;
height: 100px;
padding: 10px 20px;
border-bottom-left-radius: 50px;
position: relative;
}
.elbow:before {
content: '';
width: 40px;
height: 75px;
background: #000;
position: absolute;
right: 0;
top: 0;
border-bottom-left-radius: 25px;
}
<div class="elbow">
ELBOW 1
</div>
I'm trying to float a number on the right top of an image.
I want this number to have a background-color and overlay on top of a small portion of the image on the right top corner.
I have tried :
<li class=topoulimg><span id=bell><img src=img-img/bell.png alt=alerts></span><span class=bellnumbers>10</span></li>
css
.bellnumbers{
float:right;
font-size:12px;
background-color:red;
width:10px;
height:10px;
color:#fff;
}
but it is not working.
http://jsfiddle.net/yv5q4gvm/
Use position:absolute instead float:right for your badge (Adjust your needs).
CSS
.bell {
display: inline-block;
position: relative;
width:64px;
}
.bellnumbers {
position: absolute;
font-size:12px;
background-color:red;
width:14px;
height:14px;
color:#fff;
top: -4px;
right: -4px;
}
The float CSS property specifies that an element should be taken from
the normal flow and placed along the left or right side of its
container, where text and inline elements will wrap around it.
DEMO HERE
You can try this...
<span class="bell">
<img src=https://cdn4.iconfinder.com/data/icons/simplicio/64x64/message.png alt=alerts>
<span class="bellnumbers">10</span>
</span>
.bell {
display: inline-block;
position: relative;
background-color: #eee;
width: 48px;
height: 42px;
text-align: center;
padding-top: 6px;
}
.bell img {
width: 24px;
height: 24px;
padding-top: 10px;
}
.bellnumbers {
font-size:12px;
background-color:red;
width:16px;
line-height: 16px;
text-align: center;
color:#fff;
z-index: 2;
border-radius: 3px;
position: absolute;
left: 28px;
}
JSFiddle
Insert content from html attribute (data-count).
<button data-count="16"></button>
Insert content before every <button> element's content, and style the inserted content:
button:before {
content: attr(data-count);
}
See the live example below:
button {
position: relative;
width: 64px;
height: 64px;
margin: 10px;
background-image: url("https://cdn4.iconfinder.com/data/icons/simplicio/64x64/message.png");
background-color: white
}
button:before {
content: attr(data-count);
width: 20px;
height: 20px;
line-height: 20px;
text-align: center;
display: block;
border-radius: 20%;
background: #FF9727;
border: 1px solid #FFF;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
color: #FFF;
position: absolute;
top: -10px;
left: -10px;
}
button.bell-top-right:before {
left: auto;
right: -10px;
}
button.bell-bottom-right:before {
left: auto;
top: auto;
right: -10px;
bottom: -10px;
}
button.bell-bottom-left:before {
top: auto;
bottom: -10px;
}
<button data-count="16" class="bell-top-right"></button>
<button data-count="16" class="bell-bottom-right"></button>
<button data-count="16"></button>
<button data-count="16" class="bell-bottom-left"></button>
try this.. perhaps it will solve your purpose (try bootstrap badges that can be a help to)
<li>
<span class=bell>
<img src="https://cdn4.iconfinder.com/data/icons/simplicio/64x64/message.png">
<span class=bellnumbers>10</span>
</span>
</li>
<style>
.bellnumbers{
vertical-align: top;
font-size:17px;
letter-spacing: 3px;
background-color:#F06861;
width:27px;
height:22px;
color:#fff;
border-radius: 3px;
padding-top: 3px;
text-align: center;
position: absolute;
margin-left: -1%;
margin-top: -5px;
}
.bell{
width:64px;
margin-top: 5%;
}
</style>
As others have shown, absolute/relative positioning and 'inline-block' on the li are ideal for this. I've got the code trimmed down quite a bit, however. Demo here: https://jsfiddle.net/r09d314v/
<style type="text/css">
li {
display: inline-block;
list-style-type: none;
position: relative;
}
span {
position: absolute;
top: -8px;
right: -10px;
background: red;
color: white;
padding: 2px;
}
</style>
<li>
<img src="https://cdn4.iconfinder.com/data/icons/simplicio/64x64/message.png">
<span class="number">11</span>
</li>
According to a trick found in Stack overflow, I can change the background of the parent element hovering a child like this:
parent sibling { }
parent sibling:hover { }
parent:hover sibling { }
But I need to change the background color hovering different child elements. For example, hovering the Facebook button, the background goes blue, while hovering the Google + button, the backgroud goes red.
I've tried this:
<div class="share_box">
<div class="white-container">
<div class="facebook-sibling"/>
<a class="facebook-child-button"/>
<div class="twitter-sibling"/>
<a class="twitter-child-button"/>
<div class="googleplus-sibling"/>
<a class="googleplus-child-button"/>
</div>
</div>
but for multiple buttons it didn't work. The result I expect is similar to:
If you set the parent position: relative, it will contain any position: absolute children.
Create a new element inside the end of the parent, then make it position: absolute and position and size it so that it fills the parent.
Then use z-index: -1 to set it behind the rest of the content (e.g. the buttons).
Then you can use the General Sibling Combinator (~) to select the new element after the hovered element.
.facebook:hover ~ .background { background-color: rgb(50, 100, 150); }
.twitter:hover ~ .background { background-color: rgb(50, 150, 250); }
.google:hover ~ .background { background-color: rgb(250, 75, 50); }
.share {
position: relative;
}
.background {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: -1;
} /* Following styling for demo purposes only, not relevant */ .facebook:before { background-position:-46px -28px; width:101px; } .twitter:before { background-position:-151px -28px; width:90px; } .google:before { background-position:-245px -28px; width:94px; } .button:before { display:inline-block; content: ""; height:36px; background-image:url("http://i.stack.imgur.com/AXvMk.png"); border-radius: 3px; box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.2); } .button { display:inline-block; padding: 2px; } .white-container { padding: 10px 20px; font-size: 0; background: #fff; border-radius: 3px; } .background { background: #fff; } body { margin: 0 4px; border: 1px solid #aaa; border-top: 0px; box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.1) } .share { padding: 10px 15px; box-shadow: 0px 5px 5px -5px rgba(0,0,0,0.3) inset } body:before { content: ''; height: 4px; display: block; background: #fff; border-bottom: 1px solid #aaa } html { background: #efefef }
<div class="share">
<div class="white-container">
<div class="background"></div>
</div>
</div>
Is this what you want?
DEMO 1: http://jsfiddle.net/t73431y8/
DEMO 2: http://jsfiddle.net/t73431y8/2/
HTML:
<div class="PARENT">
<div class="RED">RED</div>
<div class="BLUE">BLUE</div>
<div class="GREEN">GREEN</div>
</div>
CSS:
.PARENT{
position: relative;
}
.RED{
display: inline-block;
margin: 5px;
padding: 5px;
color: #BB0000;
background: #FFF;
}
.RED:hover:after{
display: block;
width: 100%;
height: 100%;
background: #BB0000;
position: absolute;
top: 0px;
left: 0px;
content: ' ';
z-index: -1;
}
.BLUE{
display: inline-block;
margin: 5px;
padding: 5px;
color: #0000BB;
background: #FFF;
}
.BLUE:hover:after{
display: block;
width: 100%;
height: 100%;
background: #0000BB;
position: absolute;
top: 0px;
left: 0px;
content: ' ';
z-index: -1;
}
.GREEN{
display: inline-block;
margin: 5px;
padding: 5px;
color: #00BB00;
background: #FFF;
}
.GREEN:hover:after{
display: block;
width: 100%;
height: 100%;
background: #00BB00;
position: absolute;
top: 0px;
left: 0px;
content: ' ';
z-index: -1;
}