Create a rectangle with a pointer? [duplicate] - html

This question already has an answer here:
Breadcrumb Chevrons CSS
(1 answer)
Closed 10 months ago.
Is there a way to create this in HMTL & CSS? I've been trying for a few hours now and I can't seem to get anywhere close to it.
I saw this example but it used SCSS and I can't use it for this
project I'm working on. https://codepen.io/gditoro/pen/oNzrJeV
I also saw this but when I applied it to my div only the width
height and background color changed.
https://css-tricks.com/the-shapes-of-css/#aa-pointer-via-amsakanna-alt
HTML
<div class="steps">
Pin Check
</div>
CSS
.steps {
width: 200px;
height: 40px;
position: relative;
background: red;
}
#steps:after {
content: "";
position: absolute;
left: 0;
bottom: 0;
width: 0;
height: 0;
border-left: 20px solid white;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
#steps:before {
content: "";
position: absolute;
right: -20px;
bottom: 0;
width: 0;
height: 0;
border-left: 20px solid red;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
Thank you,

There's nothing very magic about SCSS, it just translates some stuff into pure CSS before you run.
So, if you run that first codepen and use the browser devtools you can copy the CSS and the HTML and try that.
This is what I got:
.pointer .text-content p {
text-align: center;
}
p {
display: block;
margin-block-start: 1em;
margin-block-end: 1em;
margin-inline-start: 0px;
margin-inline-end: 0px;
}
.pointer .text-content {
display: inline-block;
position: relative;
top: calc(0.25em* -0.5);
left: calc(0.25em* 2.5);
min-width: calc(0.25em* 28);
min-height: calc(0.25em* 17);
margin-right: calc(0.25em* 4);
vertical-align: middle;
color: #ffffff;
}
.pointer {
display: inline-block;
font-size: 16px;
padding-left: calc(0.25em*5);
padding-right: calc(0.25em*5);
padding-top: calc(0.25em*2);
padding-bottom: calc(0.25em*2);
height: calc(0.25em*16);
position: relative;
background: #777777;
max-width: calc(0.25em*32);
min-width: calc(0.25em*12);
-webkit-clip-path: polygon(calc(0.25em* 42 * 0.85) 0, calc(0.25em* 42) 50%, calc(0.25em* 42 * 0.85) 100%, 0% 100%, calc(0.25em* 32 * 0.15) 50%, 0% 0%);
clip-path: polygon(calc(0.25em* 42 * 0.85) 0, calc(0.25em* 42) 50%, calc(0.25em* 42 * 0.85) 100%, 0% 100%, calc(0.25em* 32 * 0.15) 50%, 0% 0%);
}
<div class="pointer">
<div class="text-content">
<p>L</p>
</div>
</div>
<div class="pointer">
<div class="text-content">
<p>Lorem ipsum dolor sit amet</p>
</div>
</div>
<div class="pointer">
<div class="text-content">
<p>Lorem ipsum dolor sit amet</p>
</div>
</div>
Obviously you'll want to look at the actual dimensions to suit your use case but this at least gives a basic start.

Use this -
.steps {
padding-left: 0;
list-style: none;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 12px;
line-height: 1;
margin: 30px auto;
border-radius: 3px;
}
.steps strong {
font-size: 14px;
display: block;
line-height: 1.4;
}
.steps>li {
position: relative;
display: block;
/* border: 1px solid #ddd; */
padding: 12px 50px 8px 50px;
width: 140px;
height: 40px;
}
#media (min-width: 768px) {
.steps>li { float: left; }
.steps .past { color: #666; background: #ececec; }
.steps .present { color: #000; }
.steps .future { color: #777; background: #efefef; }
.steps li > span:after,
.steps li > span:before {
content: "";
display: block;
width: 0px;
height: 0px;
position: absolute;
top: 0;
left: 0;
border: solid transparent;
border-left-color: #f0f0f0;
border-width: 30px;
}
.steps li > span:after {
top: -5px;
z-index: 1;
border-left-color: white;
border-width: 34px;
}
.steps li > span:before { z-index: 2; }
.steps li.past + li > span:before { border-left-color: #ececec; }
.steps li.present + li > span:before { border-left-color: #fff; }
.steps li.future + li > span:before { border-left-color: #efefef; }
.steps li:first-child > span:after,
.steps li:first-child > span:before { display: none; }
/* Arrows at start and end */
.steps li:first-child i,
.steps li:last-child i {
display: block;
position: absolute;
top: 0;
left: 0;
border: solid transparent;
border-left-color: white;
border-width: 30px;
}
.steps li:last-child i {
left: auto;
right: -30px;
border-left-color: transparent;
border-top-color: white;
border-bottom-color: white;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<ul class="steps">
<li class="past">
<span>
<strong>Step 1</strong>
Blah blah blah.
</span><i></i>
</li>
<li class="present">
<span>
<strong>Step 2</strong>
Blah blah blah.
</span><i></i>
</li>
<li class="future">
<span>
<strong>Step 3</strong>
Blah blah blah.
</span><i></i>
</li>
</ul>
</body>
</html>

Related

Why won't the text in this span underline on hover?

I am trying to get the span to underline the text on hover over anywhere in the image, but it won't work. I can change the color on the hover, but not the text decoration. Is it possible to make it underlined? My HTML and CSS are as follows:
.main__story a {
color: white;
}
.main__story a:hover {
text-decoration: underline;
color: blue;
}
.main__story span {
display:block;
font-weight: bold;
font-size: 40px;
}
#main__story__img {
border-radius: 20px;
}
.main__story {
position: relative;
}
span {
position: absolute;
bottom: 0;
margin-bottom: 30px;
margin-left: 20px;
}
.myfilter{
position: relative;
}
.myfilter:after{
position: absolute; content: ''; display: block; top: 0; left: 0; height: 100%; width: 100%;
background: linear-gradient(to bottom,rgba(245, 245, 245, 0) 0%, rgba(0, 0, 0, 0.54) 100%);
mix-blend-mode: darken;
border-radius: 20px;
}
.contain {
margin-left: 135px;
margin-right: 135px;
margin-top: 20px;
}
<body>
<div class="contain">
<div class="col-6 main__story">
<a href="https://www.google.com">
<div class="myfilter">
<img
id="main__story__img"
class="img-fluid"
src="https://media.istockphoto.com/photos/handsome-guy-and-an-attractive-girl-kiss-each-other-near-a-large-picture-id997518432"
/>
</div>
<span id="main__story__span">This is the story of a ...</span>
</a>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/#popperjs/core#2.10.2/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.min.js"></script>
</body>
A long-time user, but a first-time poster, as the issue doesn't make sense to me, that I can change some attributes, but not others. Any help would be greatly appreciated.
You are selecting and changing styles of a tag in your :hover. You need to select the child span inside a:hover as follows:
.main__story a:hover span{
text-decoration: underline;
color: blue;
}
.main__story a {
color: white;
}
.main__story a:hover span{
text-decoration: underline;
color: blue;
}
.main__story span {
display:block;
font-weight: bold;
font-size: 40px;
}
#main__story__img {
border-radius: 20px;
}
.main__story {
position: relative;
}
span {
position: absolute;
bottom: 0;
margin-bottom: 30px;
margin-left: 20px;
}
.myfilter{
position: relative;
}
.myfilter:after{
position: absolute; content: ''; display: block; top: 0; left: 0; height: 100%; width: 100%;
background: linear-gradient(to bottom,rgba(245, 245, 245, 0) 0%, rgba(0, 0, 0, 0.54) 100%);
mix-blend-mode: darken;
border-radius: 20px;
}
.contain {
margin-left: 135px;
margin-right: 135px;
margin-top: 20px;
}
<body>
<div class="contain">
<div class="col-6 main__story">
<a href="https://www.google.com">
<div class="myfilter">
<img
id="main__story__img"
class="img-fluid"
src="https://media.istockphoto.com/photos/handsome-guy-and-an-attractive-girl-kiss-each-other-near-a-large-picture-id997518432"
/>
</div>
<span id="main__story__span">This is the story of a ...</span>
</a>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/#popperjs/core#2.10.2/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.min.js"></script>
</body>

How do I make CSS arrow the same width as the container?

I currently have arrows below the containers as shown in this fiddle: https://jsfiddle.net/xo9vwks1/
HTML:
<ul class="arrows">
<li><div>sadf sdfsdsdf</div></li>
<li><div>sdsa sdss sdsd s </div></li>
<li><div>sdfsdf sad assdssds s sdsdds sn</div></li>
<li><div>sdsd sadfsdf asdf sadfon</div></li>
<li><div>sdf sdfsdf sss ssdss ss s asd sa gsdsdf</div></li>
</ul>
CSS:
ul.arrows li {
background-color: #ddd !important;
display: block;
margin-bottom: 40px !important;
padding: 0 10px !important;
text-align: center;
list-style: none;
max-width: 400px;
}
ul.arrows li div::after {
border-color: #ddd transparent transparent;
border-style: solid;
border-width: 30px;
content: " ";
height: 0;
position: absolute;
right: 0;
left: 50%;
top: 100%;
width: 0;
z-index: 10;
margin-left: -30px;
}
ul.arrows li:last-child div::after {
border-width: 0;
}
ul.arrows li div {
display: inline-block;
line-height: normal;
padding: 15px 0;
position: relative;
}
I would like to have the arrows extend all the way from left to right so that they are equal to the width of the container like shown in the image below. The arrows must also be responsive. I couldn't work it out. How do I do this?
CSS linear-gradient is one way to do it, if you're only looking to support newer-ish browsers:
ul.arrows li {
background-color: #ddd !important;
display: block;
margin-bottom: 40px !important;
text-align: center;
list-style: none;
max-width: 400px;
}
ul.arrows li div {
line-height: normal;
padding: 15px 10px;
position: relative;
}
ul.arrows li div::before {
position: absolute;
left: 0;
top: 100%;
width: 50%;
height: 30px;
background: linear-gradient(to left bottom, #ddd 50%, rgba(0, 0, 0, 0) 50%);
content: " ";
}
ul.arrows li div::after {
position: absolute;
left: 50%;
top: 100%;
width: 50%;
height: 30px;
background: linear-gradient(to right bottom, #ddd 50%, rgba(0, 0, 0, 0) 50%);
content: " ";
}
ul.arrows li:last-child div::after,
ul.arrows li:last-child div::before {
display: none
}
<ul class="arrows">
<li>
<div>sadf sdfsdsdf</div>
</li>
<li>
<div>sdsa sdss sdsd s </div>
</li>
<li>
<div>sdfsdf sad assdssds s sdsdds sn</div>
</li>
<li>
<div>sdsd sadfsdf asdf sadfon</div>
</li>
<li>
<div>sdf sdfsdf sss ssdss ss s asd sa gsdsdf</div>
</li>
</ul>
Shorter code and you can see the smoothness of the triangle :)
* {
margin: 0;
padding: 0; }
ul.arrows li {
background-color: #ddd !important;
display: block;
margin-bottom: 50px !important;
padding: 15px 0;
text-align: center;
list-style: none;
max-width:400px;
position: relative; }
ul.arrows li:before {
position: absolute;
top: 48px;
left: 0;
content: "";
border-right: 200px solid transparent;
border-left: 200px solid transparent;
border-top: 30px solid #ddd; }
<ul class="arrows">
<li>
<div>sadf sdfsdsdf</div>
</li>
<li>
<div>sdsa sdss sdsd s </div>
</li>
</ul>
Just tweak your code into this. Actually you got the idea of using the pseudo element border. However, you didn't specify a value for border-right and border-left width.
Hope it helps :)

CSS 3D effect banner

I am trying to figure out how to illustrate a banner that goes behind the body and continues in the background.
I want to achieve something like this:
But the difficult part is the wrap-around when it goes to the background (3D-effect).
This is what I got so far: https://jsfiddle.net/4v6xLtyf/
<body>
<div class="navbar background-banner">
</div>
<div class="body-content">
<div style="height:1000px" class="container content-block">
<h1 style="text-align: center">My Website</h1>
<div class="navbar navbar-inverse navbar-top navbar-custom-top">
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a>Home</a></li>
<li><a>About Us</a></li>
<li><a>Login</a></li>
</ul>
</div>
</div>
<p>Content goes here</p>
</div>
</div>
</body>
You can play with :before, :after and border to do the trick, something close to what you need could be adding the following CSS rules:
.navbar-custom-top:before {
content: "";
background-color: transparent;
width: 30px;
height: 50px;
position: absolute;
border-left: 25px solid transparent;
border-top: 31px solid #bb5911;
top: 50px;
left:0;
}
.navbar-custom-top:after {
content: "";
background-color: transparent;
width: 30px;
height: 50px;
position: absolute;
border-right: 25px solid transparent;
border-top: 31px solid #bb5911;
top: 50px;
right: 0;
}
Working fiddle
Then play with the size, position and colors to match exactly what you need.
Update answer......
I made an example from #user2570380 reference link.
Just take a look my link_codpen .
New CSS with two new class ribbonoutline & ribbonul
/***********************/
.ribbonul:before, .ribbonul:after {
content: "";
position: absolute;
display: block;
border-style: solid;
border-color: #BB5911 transparent transparent transparent;
bottom: -1em;
}
.ribbonul:before {
left:0;
border-width: 1em 0 0 1em;
}
.ribbonul:after {
right: 0;
border-width: 1em 1em 0 0;
}
.ribbonoutline:after {
content: "";
position: absolute;
display: block;
background-image: linear-gradient(rgb(234, 115, 29), rgb(255, 168, 0)) !important;
height: 28px;
width: 100%;
margin-top: -10px;
left: 0;
z-index: -9999;
}
html,
body {
background-image: linear-gradient(rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.7)) !important;
background-attachment: fixed;
font-family: Algerian;
}
/* Set padding to keep content from hitting the edges */
.body-content {
padding-bottom: 100px;
padding-left: 15px;
padding-right: 15px;
position:relative;
z-index:1
}
/* Override the default bootstrap behavior where horizontal description lists
will truncate terms that are too long to fit in the left column
*/
.dl-horizontal dt {
white-space: normal;
}
/* Set width on the form input elements since they're 100% wide by default */
input,
select,
textarea {
max-width: 280px;
}
.content-block {
background-color: white;
border-radius: 5px;
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
margin-top: 20px;
margin-bottom: 20px;
padding: 22px;
width: 70%;
margin: auto;
height: 500px;
}
.background-banner {
background-image: linear-gradient(rgb(234, 115, 29), rgb(255, 168, 0)) !important;
margin-top: 150px;
border-radius: 0px;
border: 0px;
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
position: absolute;
width: 100%;
z-index: 0;
}
a {
color: black;
text-decoration: none;
}
a:hover,
a:focus {
color: white;
text-decoration: none;
}
.navbar-custom-top {
background-image: linear-gradient(rgb(234, 115, 29), rgb(255, 168, 0)) !important;
margin-top: 50px;
margin-left: -40px;
margin-right: -40px;
border-radius: 0px;
border: 0px;
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}
.custom-container {
padding-right: 0px;
padding-left: 0px;
margin-right: auto;
margin-left: auto;
}
.navbar-fixed-top,
.navbar-fixed-bottom {
border-top-width: 0px;
border-bottom-width: 0px;
}
.navbar-header {
float: left;
width: 100%;
text-align: center;
}
ul.navbar-nav > li {
display: inline;
}
ul.navbar-nav {
float: none;
margin: 0 auto;
text-align: center;
display: block;
position: relative;
}
.content {
min-height: 1000px;
}
.navbar-inverse .navbar-nav > li > a {
color: black;
margin-left: 50px;
margin-right: 50px;
padding-top: 10px;
padding-bottom: 10px;
font-weight: bold;
font-size: 25px;
border-bottom: 2px solid transparent;
}
.navbar-inverse .navbar-nav > li > a:hover {
color: black;
border-bottom: 2px solid transparent;
border-bottom-color: #fff;
}
.navbar-inverse .navbar-nav > .active > a,
.navbar-inverse .navbar-nav > .active > a:hover,
.navbar-inverse .navbar-nav > .active > a:focus {
color: #000000;
background-color: transparent;
border-bottom: 2px solid transparent;
border-bottom-color: black;
}
/***********************/
/***********************/
/***********************/
.ribbonul:before, .ribbonul:after {
content: "";
position: absolute;
display: block;
border-style: solid;
border-color: #BB5911 transparent transparent transparent;
bottom: -1em;
}
.ribbonul:before {
left:0;
border-width: 1em 0 0 1em;
}
.ribbonul:after {
right: 0;
border-width: 1em 1em 0 0;
}
.ribbonoutline:after {
content: "";
position: absolute;
display: block;
background-image: linear-gradient(rgb(234, 115, 29), rgb(255, 168, 0)) !important;
height: 28px;
width: 100%;
margin-top: -10px;
left: 0;
z-index: -9999;
}
<div class="navbar background-banner">
</div>
<div class="body-content">
<div class="container content-block">
<h1 style="text-align: center">My Website</h1>
<div class="navbar navbar-inverse navbar-top navbar-custom-top">
<div class="navbar-collapse collapse ribbonoutline">
<ul class="nav navbar-nav ribbonul">
<li><a>Home</a></li>
<li><a>About Us</a></li>
<li><a>Login</a></li>
</ul>
</div>
</div>
<p>Content goes here</p>
</div>
</div>

CSS ribbon "menu" isn't working as desired

So I've created part of a ribbon menu I plan on using myself. So here is what it looks like so far:
Before hover:
On hover:
Basically, I want it to show my social icon as well as being able to use my other banners when i add them in.
Here is the code that I am using so far:
<body>
<ul class="social">
<li class="ribbon" media="facebook"><i class="fa fa-facebook" aria-hidden="true"></i></li>
</ul>
<script src="https://use.fontawesome.com/c2f336433a.js"></script>
</body>
Here is the CSS:
#import 'reset';
#import 'mixins';
ul.social {
position: absolute;
z-index: 4;
margin: -225px auto;
list-style: none;
right: 0;
li.ribbon {
float: right;
cursor: pointer;
position: relative;
width: 75px;
height: 250px;
border: none;
color: white;
padding: 5px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
#include transition(all .2s ease-in-out);
#include filter(drop-shadow(0 1px 10px rgba(0, 0, 0, 0.5)));
span {
line-height: 20px;
font-size: 5em;
}
}
li.ribbon:hover {
margin-top: 70px;
color: white;
}
li.ribbon:before {
content: '';
position: absolute;
top: 100%; left: 0;
width: 0; height: 0;
border-top: 25px solid blue;
border-right: 50px solid transparent;
}
li.ribbon:after {
content: '';
position: absolute;
top: 100%; right: 0;
width: 0; height: 0;
border-top: 25px solid blue;
border-left: 50px solid transparent;
}
li.ribbon[media="facebook"] {
background: #3b5998;
color: #1e2e4f;
margin-right: 5px;
}
li.ribbon[media="facebook"]:before,
li.ribbon[media="facebook"]:after {
border-top-color: #3b5998;
}
}
Note that the reset is just an eric meyer reset and the mixins are just for transitions etc...
The reason why you weren't able to see the icon was because there was a negative margin of 225px on the ul. On hover, only the margin-top of the li was being set to 70px but the ul still has the negative margin, so the li is still around 155px above the viewport. This means that the a which is not positioned (that is, has static positioning) and is near the top of the li is still not visible.
You can correct this by avoiding the margin on the ul and just moving the li around. I've used the transform: translateY() to move the li around because that is better for performance than using margins (which need repainting).
I have also added some extra properties like text-align, line-height etc for a better look.
ul.social {
position: absolute;
z-index: 4;
margin: 0px auto; /* modified */
list-style: none;
right: 0;
}
ul.social li.ribbon {
float: right;
cursor: pointer;
position: relative;
width: 75px;
height: 100px; /* modified */
border: none;
color: white;
padding: 5px;
text-align: center; /* added */
line-height: 100px; /* added, equal to height */
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
transform: translateY(-100%); /* added */
transition: all .2s ease-in-out;
-webkit-filter: drop-shadow(0 1px 10px rgba(0, 0, 0, 0.5));
}
ul.social li.ribbon span {
line-height: 20px;
font-size: 5em;
}
ul.social li.ribbon:hover {
transform: translateY(0%); /* added */
/* margin-top: 70px; removed for better performance */
}
ul.social li.ribbon:before {
content: '';
position: absolute;
top: 100%;
left: 0;
width: 0;
height: 0;
border-top: 25px solid blue;
border-right: 50px solid transparent;
}
ul.social li.ribbon:after {
content: '';
position: absolute;
top: 100%;
right: 0;
width: 0;
height: 0;
border-top: 25px solid blue;
border-left: 50px solid transparent;
}
ul.social li.ribbon[media="facebook"] {
background: #3b5998;
color: #1e2e4f;
margin-right: 5px;
}
ul.social li.ribbon[media="facebook"]:before,
ul.social li.ribbon[media="facebook"]:after {
border-top-color: #3b5998;
}
/* added */
ul.social li.ribbon a {
color: white;
}
<body>
<ul class="social">
<li class="ribbon" media="facebook"><i class="fa fa-facebook" aria-hidden="true"></i>
</li>
</ul>
<script src="https://use.fontawesome.com/c2f336433a.js"></script>
</body>

How to style the background of the parent element when hovering more then one child element?

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;
}