CSS Sliding panel from left to right - html

I have this code working from right to left sliding.
#panel {
position: absolute;
right: 0;
width: 180px;
top: 0;
bottom: 0;
box-shadow: 0px 0px 15px black;
background: white;
padding: 10px;
-webkit-transform-origin: 100% 50%;
-webkit-transform: scaleX(0.00001);
-webkit-transition: -webkit-transform 0.2s ease-in-out;
outline: 0;
}
#panel:target {
-webkit-transform: scaleX(1);
}
<div>☰</div>
<p><a id="panel" href="#">This is the side panel.</a></p>
Now I like to have this sliding from left to right. I changed right:0; to left, then it is sliding from the center to the left. I did read almost all posts and tried a lot of different things but nothing worked. Can somebody help me? Thanks a lot.

Not sure, what exactly you are looking for. But perhaps you should be using translate property instead of scale, though you can achieve the same using scale as well.
#panel {
position: absolute;
left: 0;
width: 180px;
top: 0;
bottom: 0;
box-shadow: 0px 0px 15px black;
background: white;
padding: 10px;
-webkit-transform-origin: 100% 50%;
-webkit-transform: translateX(-100%);
-webkit-transition: -webkit-transform 0.2s ease-in-out;
outline: 0;
}
#panel:target {
-webkit-transform: translateX(0%);
}
<div>☰</div>
<p><a id="panel" href="#">This is the side panel.</a></p>

This is because of
-webkit-transform-origin
Is this what you're looking for ?
#panel {
position: absolute;
left: 0;
width: 180px;
top: 0;
bottom: 0;
box-shadow: 0px 0px 15px black;
background: white;
padding: 10px;
-webkit-transform-origin: 0% 50%;
-webkit-transform: scaleX(0.00001);
-webkit-transition: -webkit-transform 0.2s ease-in-out;
outline: 0;
}
#panel:target {
-webkit-transform: scaleX(1);
}
<div>☰</div>
<p><a id="panel" href="#">This is the side panel.</a></p>

You have also to change -webkit-transform-origin: 100% 50%; and make it -webkit-transform-origin: 0% 100%; to open it from left, check the snippet:
#panel {
position: absolute;
left: 0;
width: 180px;
top: 0;
bottom: 0;
box-shadow: 0px 0px 15px black;
background: white;
padding: 10px;
-webkit-transform-origin: 0% 100%;
-webkit-transform: scaleX(0.00001);
-webkit-transition: -webkit-transform 0.2s ease-in-out;
outline: 0;
}
#panel:target {
-webkit-transform: scaleX(1);
}
<div>
☰
</div>
<p>
<a id="panel" href="#">This is the side panel.</a>
</p>

You were correct to change right to left, but you also need to change the X axis of the transform-origin to zero:
#panel {
position: absolute;
left: 0;
width: 180px;
top: 0;
bottom: 0;
box-shadow: 0px 0px 15px black;
background: white;
padding: 10px;
-webkit-transform-origin: 0 50%;
-webkit-transform: scaleX(0.00001);
-webkit-transition: -webkit-transform 0.2s ease-in-out;
outline: 0;
}
#panel:target {
-webkit-transform: scaleX(1);
}
<div>☰</div>
<p><a id="panel" href="#">This is the side panel.</a></p>

Related

CSS fontAwesome icon doesn´t center [duplicate]

This question already has answers here:
Flexbox: center horizontally and vertically
(14 answers)
How can I center text (horizontally and vertically) inside a div block?
(27 answers)
Closed 1 year ago.
I am aware that the initial question is answered several times. Usually I know how to do it, so its more a bug fixing question instead of a general question. The code shows a cross which behaves as a toggle. If clicked another 3 elements appear, where the one on the middle gives me headache. I used a fontAwesome icon and can´t figure out why it will not center in this div element.
I am summon a CSS master which could solve my bug. ;)
<!-- fontawesome stylesheet https://fontawesome.com/ -->
<script src="https://kit.fontawesome.com/39094309d6.js" crossorigin="anonymous"></script>
<style>
html {
margin: auto;
width: 50%;
}
.modal-setting-toggle {
position: relative;
margin-top: 10px;
width:40px;
height: 40px;
border-radius: 10px;
background: #ecf0f3;
cursor: pointer;
box-shadow: 6px 6px 10px rgba(0, 0, 0, 0.1), -6px -6px 10px white;
}
.modal-setting-toggle::before, .modal-setting-toggle::after {
content: "";
background: #c3c2c7;
border-radius: 5px;
width: 20px;
height: 5px;
position: absolute;
left: 10px;
top: 18px;
transition: 0.2s ease;
z-index: 1;
}
.modal-setting-toggle::before {
transform: rotate(0deg);
}
.modal-setting-toggle::after {
transform: rotate(-90deg);
}
.modal-setting-toggle:hover::before {
transform: rotate(0deg);
background-color: #3498db;
}
.modal-setting-toggle:hover::after {
transform: rotate(-90deg);
background-color: #3498db;
}
.modal-setting-toggle.open::before {
transform: rotate(45deg);
background-color: #3498db;
}
.modal-setting-toggle.open::after {
transform: rotate(-45deg);
background-color: #3498db;
}
.modal-setting-toggle.open .modal-setting-button {
opacity: 1;
pointer-events: auto;
}
.modal-setting-toggle.open .modal-setting-button:first-of-type {
bottom: -50px;
background: url("https://bassets.github.io/cam.svg") no-repeat 50%/50% #ecf0f3;
}
.modal-setting-toggle.open .modal-setting-button:nth-of-type(2) {
bottom: -100px;
background: #ecf0f3;
justify-content: center;
align-items: center;
text-align: center;
transition-delay: 0.05s;
}
.modal-setting-toggle.open .modal-setting-button:last-of-type {
bottom: -150px;
background: url("https://bassets.github.io/music.svg") no-repeat 50% 45%/50% 45% #ecf0f3;
transition-delay: 0.1s;
}
.modal-setting-button {
width: 40px;
height: 40px;
border-radius: 10px;
cursor: pointer;
background: #ecf0f3;
position: absolute;
opacity: 0;
pointer-events: none;
box-shadow: inherit;
transition: 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28), 0.2s ease opacity, 0.2s cubic-bezier(0.08, 0.82, 0.17, 1) transform;
}
.modal-setting-button:hover {
transform: scale(1.1);
}
</style>
<section id="modal-setting" class="modal box-shadow">
<div style="float: right" class="modal-setting-toggle" onclick="this.classList.toggle('open')">
<div class="modal-setting-button"></div>
<div class="modal-setting-button"><i class="fas fa-link"></i></div>
<div class="modal-setting-button"></div>
</div>
</section>
Add display: flex to .modal-setting-toggle.open .modal-setting-button:nth-of-type(2) to make use of the align-items: center property.
html {
margin: auto;
width: 50%;
}
.modal-setting-toggle {
position: relative;
margin-top: 10px;
width: 40px;
height: 40px;
border-radius: 10px;
background: #ecf0f3;
cursor: pointer;
box-shadow: 6px 6px 10px rgba(0, 0, 0, 0.1), -6px -6px 10px white;
}
.modal-setting-toggle::before,
.modal-setting-toggle::after {
content: "";
background: #c3c2c7;
border-radius: 5px;
width: 20px;
height: 5px;
position: absolute;
left: 10px;
top: 18px;
transition: 0.2s ease;
z-index: 1;
}
.modal-setting-toggle::before {
transform: rotate(0deg);
}
.modal-setting-toggle::after {
transform: rotate(-90deg);
}
.modal-setting-toggle:hover::before {
transform: rotate(0deg);
background-color: #3498db;
}
.modal-setting-toggle:hover::after {
transform: rotate(-90deg);
background-color: #3498db;
}
.modal-setting-toggle.open::before {
transform: rotate(45deg);
background-color: #3498db;
}
.modal-setting-toggle.open::after {
transform: rotate(-45deg);
background-color: #3498db;
}
.modal-setting-toggle.open .modal-setting-button {
opacity: 1;
pointer-events: auto;
}
.modal-setting-toggle.open .modal-setting-button:first-of-type {
bottom: -50px;
background: url("https://bassets.github.io/cam.svg") no-repeat 50%/50% #ecf0f3;
}
.modal-setting-toggle.open .modal-setting-button:nth-of-type(2) {
bottom: -100px;
background: #ecf0f3;
justify-content: center;
align-items: center;
text-align: center;
transition-delay: 0.05s;
display: flex; /* ADD THIS */
}
.modal-setting-toggle.open .modal-setting-button:last-of-type {
bottom: -150px;
background: url("https://bassets.github.io/music.svg") no-repeat 50% 45%/50% 45% #ecf0f3;
transition-delay: 0.1s;
}
.modal-setting-button {
width: 40px;
height: 40px;
border-radius: 10px;
cursor: pointer;
background: #ecf0f3;
position: absolute;
opacity: 0;
pointer-events: none;
box-shadow: inherit;
transition: 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28), 0.2s ease opacity, 0.2s cubic-bezier(0.08, 0.82, 0.17, 1) transform;
}
.modal-setting-button:hover {
transform: scale(1.1);
}
<script src="https://kit.fontawesome.com/39094309d6.js" crossorigin="anonymous"></script>
<section id="modal-setting" class="modal box-shadow">
<div style="float: right" class="modal-setting-toggle" onclick="this.classList.toggle('open')">
<div class="modal-setting-button"></div>
<div class="modal-setting-button"><i class="fas fa-link"></i></div>
<div class="modal-setting-button"></div>
</div>
</section>

Draw ideal symmetric css border with border-radius

I'm trying to draw a border with border-radius: 8px;. It perfectly draws symmetrical border without border-radius but messed up with it. What am I doing wrong here?
setTimeout(function(){
document.getElementsByClassName('border')[0].classList.add('animate-border');
},100)
body {
background: white;
}
.main-container {
position:absolute;
top:50%;
left:50%;
transform: translate(-50%, -50%);
width: 300px;
height: 460px;
background: ;
}
.border:before {
border:2px solid black;
border-radius: 8px;
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 0;
height: 0;
border-top: 0;
border-left: 0;
pointer-events: none;
overflow: hidden;
opacity: 0;
transform: rotateZ(0) rotate(0);
}
.border.animate-border:before {
opacity: 1;
height: 100%;
width: 100%;
transition: opacity 0s ease,width 0.5s ease, height 0.5s 0.5s ease;
overflow: hidden;
transform: rotateZ(0) rotate(0);
}
.border:after {
border: 2px solid black;
border-radius: 8px;
content: '';
position: absolute;
top: 0;
right: 0;
width: 0;
height: 0;
border-bottom: 0;
border-right: 0;
opacity: 0;
overflow: hidden;
transform: rotateZ(0) rotate(0);
}
.border.animate-border:after {
opacity: 1;
height: 100%;
width: 100%;
overflow: hidden;
transition: opacity 0s 1s ease,width 0.5s 1s ease, height 0.5s 1.5s ease;
transform: rotateZ(0) rotate(0);
}
<div class='main-container border'></div>
CSS:
body {
background: white;
}
.main-container {
position:absolute;
top:50%;
left:50%;
transform: translate(-50%, -50%);
width: 300px;
height: 460px;
background: ;
}
.border:before {
border:2px solid black;
border-radius: 8px;
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 0;
height: 0;
border-top: 0;
border-left: 0;
pointer-events: none;
overflow: hidden;
opacity: 0;
transform: rotateZ(0) rotate(0);
}
.border.animate-border:before {
opacity: 1;
height: 100%;
width: 100%;
transition: opacity 0s ease,width 0.5s ease, height 0.5s 0.5s ease;
overflow: hidden;
transform: rotateZ(0) rotate(0);
}
.border:after {
border: 2px solid black;
border-radius: 8px;
content: '';
position: absolute;
top: 0;
right: 0;
width: 0;
height: 0;
border-bottom: 0;
border-right: 0;
opacity: 0;
overflow: hidden;
transform: rotateZ(0) rotate(0);
}
.border.animate-border:after {
opacity: 1;
height: 100%;
width: 100%;
overflow: hidden;
transition: opacity 0s 1s ease,width 0.5s 1s ease, height 0.5s 1.5s ease;
transform: rotateZ(0) rotate(0);
}
First of all, you may apply box-sizing: border-box in all elements (and pseudo-elements) to make the alignment easier. It makes the browser count the border on width and height calculation. That solves your misalignment problem.
Second, since you're resizing the element, the rounded corners get stretched in the middle of the animation. I see no easy way prevent that from happening. But you can disguise it by also animating the right property of the :after pseudo-element, like I did below. That and a faster timing may get you there with your animation.
BTW, it would be more performant if you animated transform: scaleX(...) scaleY(...) instead of width and height, because they're GPU accelerated.
setTimeout(function(){
document.getElementsByClassName('border')[0].classList.add('animate-border');
},100)
body {
background: white;
}
*, *:before, *:after { /* Applies to ALL elements and pseudo-elements */
box-sizing: border-box;
}
.main-container {
position:absolute;
top:50%;
left:50%;
transform: translate(-50%, -50%);
width: 300px;
height: 160px;
background: ;
}
.border:before {
border:2px solid black;
border-radius: 8px;
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 0;
height: 0;
border-top: 0;
border-left: 0;
pointer-events: none;
overflow: hidden;
opacity: 0;
transform: rotateZ(0) rotate(0);
}
.border.animate-border:before {
opacity: 1;
height: 100%;
width: 100%;
transition: opacity 0s ease,width 0.5s ease, height 0.5s 0.5s ease;
overflow: hidden;
transform: rotateZ(0) rotate(0);
}
.border:after {
border: 2px solid black;
border-radius: 8px;
content: '';
position: absolute;
top: 0;
right: 6px; /* a little offset to hide the squared edge */
width: 0;
height: 0;
border-bottom: 0;
border-right: 0;
opacity: 0;
overflow: hidden;
transform: rotateZ(0) rotate(0);
}
.border.animate-border:after {
opacity: 1;
height: 100%;
width: 100%;
right: 0; /* the wanted right position */
overflow: hidden;
transition: opacity 0s 1s ease,width 0.5s 1s ease, height 0.5s 1.5s ease,right 1s 1s ease; /* Animated 'right' so it slowly gets back to its position */
transform: rotateZ(0) rotate(0);
}
<div class='main-container border'></div>
PS.: I changed the box height to make it fit inside the snippet here.
You just need to specify properties below to pseudo elements because they are position absolute
Add top:0 to .border:before css and add left:0 to .border:after css

CSS folded corner takes over the whole panel

I am having quite a hard time trying to get a folded corner spread over the entire surface of my panel.
I don't want to set up a specific size for the folded corner as I want it to cover the entire surface, whatever the size of the panel (as it would show on mobile, tablet or desktop.
I can't figure out an easy solution to achieve this.
Here is my code :
.panel-default1 {
padding-top: 10px;
border-radius: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.10);
height: 400px;
width: 100%;
overflow: hidden;
margin: 0 auto;
position: relative;
}
.amg-corner-button_wrap {
display: block;
position: absolute;
bottom: 0;
right: 0;
width: 40px;
height: 40px;
}
.amg-corner-button_wrap:hover {
width: 120px;
height: 120px;
}
.amg-corner-button_wrap:hover div {
width: 120px;
height: 120px;
}
.amg-corner-button {
display: block;
position: absolute;
bottom: 0;
right: 0;
width: 40px;
height: 40px;
background-color: #46982b;
-webkit-transition: width 300ms, height 300ms;
-moz-transition: width 300ms, height 300ms;
-ms-transition: width 300ms, height 300ms;
-o-transition: width 300ms, height 300ms;
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
-o-transform: translateZ(0);
}
.amg-corner-button:before {
content: "";
position: absolute;
top: 0;
right: 0;
border-width: 0 0 120px 120px;
border-style: solid;
border-color: #46982b #fff;
}
.amg-corner-button_text {
font-size: 14px;
font-size: 1.4rem;
width: 120px;
position: absolute;
top: 60px;
right: 0;
left: 0;
-webkit-transform-origin: center top;
-moz-transform-origin: center top;
-ms-transform-origin: center top;
transform-origin: center top;
-webkit-transform-origin: center top center;
-moz-transform-origin: center top center;
-ms-transform-origin: center top center;
-o-transform-origin: center top center;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
text-align: center;
color: #ffffff;
}
<div class="panel panel-default1">
<div class="panel-body">
<div class='amg-corner-button_wrap'>
<div class='amg-corner-button'></div>
<span class='amg-corner-button_text'>Text Goes Here</span>
</div>
</div>
<!-- panel body -->
</div>
<!-- panel default -->
Any help on this would be very much appreciated.
Try using this as your css instead.
.panel-default1 {
padding-top: 10px;
border-radius: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.10);
height: 400px;
width: 100%;
overflow: hidden;
margin: 0 auto;
position: relative;
}
.amg-corner-button_wrap {
display: block;
position: absolute;
bottom: 0;
right: 0;
width: 40px;
height: 40px;
}
.amg-corner-button_wrap:hover {
width: 100%;
height: 100%;
}
.amg-corner-button_wrap:hover div {
width: 100%;
height: 100%;
}
.amg-corner-button {
display: block;
position: absolute;
bottom: 0;
right: 0;
width: 40px;
height: 40px;
background-color: #46982b;
-webkit-transition: width 300ms, height 300ms;
-moz-transition: width 300ms, height 300ms;
-ms-transition: width 300ms, height 300ms;
-o-transition: width 300ms, height 300ms;
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
-o-transform: translateZ(0);
}
.amg-corner-button:before {
content: "";
position: absolute;
top: 0;
right: 0;
border-width: 0 0 120px 120px;
border-style: solid;
border-color: #46982b #fff;
}
.amg-corner-button:hover::before {
border-width: 0;
}
.amg-corner-button_text {
font-size: 14px;
font-size: 1.4rem;
width: 120px;
position: absolute;
top: 60px;
right: 0;
left: 0;
-webkit-transform-origin: center top;
-moz-transform-origin: center top;
-ms-transform-origin: center top;
transform-origin: center top;
-webkit-transform-origin: center top center;
-moz-transform-origin: center top center;
-ms-transform-origin: center top center;
-o-transform-origin: center top center;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
text-align: center;
color: #ffffff;
}
We did two things. We updated .amg-corner-button_wrap:hover and .amg-corner-button_wrap:hover div to have a width and height of 100%. This way the panel would take up 100% of the panel.
The second change was adding:
.amg-corner-button:hover::before {
border-width: 0;
}
Without this we would be left with an extra triangle in panel. We need this triangle to create the green pocket shape we have in the bottom-right hand corner.

Hyperlink can't be clicked under div

I've tried experimenting with z-index and position:relative but I can't seem to get this to work.
I've made it so once you hover your mouse over the images, a hyperlink appears, but for some reason you can't click the hyperlink. Can someone please show me how to bring it to the front?
Here's my code:
.caption {
display: inline-block;
position: relative;
overflow: hidden;
-webkit-transform: translateZ(0);
margin-right: 1.25em;
margin-top: 1.250em;
margin-bottom: 2.188em;
margin-left: 1.25em;
top: 0;
bottom: 0;
right: 0;
display: block;
max-width: 100%;
height: auto;
}
.caption::before {
content: ' ';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: transparent;
transition: background .35s ease-out;
}
.imageh:hover+.caption::before {
box-shadow: inset 0 0 0 1000px rgba(0, 0, 0, .5);
}
.imageh {
position: absolute;
display: block;
height: 100%;
width: 100%;
z-index: 1;
top: 0;
bottom: 0;
right: 0;
}
.caption__overlay {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
padding: 10px;
color: white;
-webkit-transform: translateY(100%);
transform: translateY(100%);
transition: -webkit-transform .35s ease-out;
transition: transform .35s ease-out;
}
.imageh:hover+.caption .caption__overlay {
-webkit-transform: translateY(0);
transform: translateY(0);
}
.caption__media {
padding-top: 130px;
max-width: 100%;
}
<span class="imageh"></span>
<div class="caption">
<img src="http://bsnscb.com/data/out/78/27073638-free-farm-wallpapers.jpg" />
<div class="caption__overlay">
<div class="caption__overlay__content">
<h1 style="text-align:center" class="caption__media"><a style="color:white;" href="artists.html">OUR ARTISTS</a></h1>
</div>
</div>
</div>
Thanks
Instead of using the span element on hover which is a sibling to the image container(making it hard to avoid flickering during hover). You can just hover on the caption container div itself. See sample code below
.caption {
display: inline-block;
position: relative;
overflow: hidden;
-webkit-transform: translateZ(0);
margin-right: 1.25em;
margin-top: 1.250em;
margin-bottom: 2.188em;
margin-left: 1.25em;
top: 0;
bottom: 0;
right: 0;
display: block;
max-width: 100%;
height: auto;
}
.caption::before {
content: ' ';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: transparent;
transition: background .35s ease-out;
}
.caption:hover::before {
box-shadow: inset 0 0 0 1000px rgba(0, 0, 0, .5);
}
.imageh {
/* position: absolute;
display: block;
height: 100%;
width: 100%;
z-index: 1;
top: 0;
bottom: 0;
right: 0;*/
}
.caption__overlay {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
padding: 10px;
color: white;
-webkit-transform: translateY(100%);
transform: translateY(100%);
transition: -webkit-transform .35s ease-out;
transition: transform .35s ease-out;
}
.caption:hover .caption__overlay {
-webkit-transform: translateY(0);
transform: translateY(0);
}
.caption__media {
padding-top: 130px;
max-width: 100%;
}
<span class="imageh"></span>
<div class="caption">
<img src="https://homepages.cae.wisc.edu/~ece533/images/arctichare.png" />
<div class="caption__overlay">
<div class="caption__overlay__content">
<h1 style="text-align:center" class="caption__media"><a style="color:white;" href="artists.html">OUR ARTISTS</a></h1>
</div>
</div>
</div>
Keep everything as is except two things. Set the element with class "imageh" with z-index 0 and the element with class "caption__overlay__content" with z-index 1.

Pure CSS3 Responsive Lightbox Appears Half-Off Screen

Created a LightBox effect using pure CSS and HTML, no JS. The image appears, but on the right side of the screen, halfway cut off, and partially underneath my Nav bar. Half of the screen is shaded behind the image.
It appears like it would work, aside from it being off-center and behind the navigation. From the code at hand, is there anything that appears it could be doing this? I'd be happy to post more code if necessary. Thank you!
/*Eliminates padding, centers the thumbnail */
body,
html {
padding: 0;
margin: 0;
text-align: center;
float: left;
}
/* Styles the thumbnail */
a.lightbox img {
height: 150px;
border: 3px solid white;
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
margin: 94px 20px 20px 20px;
}
/* Styles the lightbox, removes it from sight and adds the fade-in transition */
.lightbox-target {
position: fixed;
top: -100%;
width: 100%;
background: rgba(0, 0, 0, 0.7);
width: 100%;
opacity: 0;
-webkit-transition: opacity .5s ease-in-out;
-moz-transition: opacity .5s ease-in-out;
-o-transition: opacity .5s ease-in-out;
transition: opacity .5s ease-in-out;
overflow: hidden;
clear: both;
}
/* Styles the lightbox image, centers it vertically and horizontally, adds the zoom-in transition and makes it responsive using a combination of margin and absolute positioning */
.lightbox-target img {
margin: auto;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
max-height: 0%;
max-width: 0%;
border: 3px solid white;
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
box-sizing: border-box;
-webkit-transition: .5s ease-in-out;
-moz-transition: .5s ease-in-out;
-o-transition: .5s ease-in-out;
transition: .5s ease-in-out;
}
/* Styles the close link, adds the slide down transition */
a.lightbox-close {
display: block;
width: 50px;
height: 50px;
box-sizing: border-box;
background: white;
color: black;
text-decoration: none;
position: absolute;
top: -80px;
right: 0;
-webkit-transition: .5s ease-in-out;
-moz-transition: .5s ease-in-out;
-o-transition: .5s ease-in-out;
transition: .5s ease-in-out;
}
/* Provides part of the "X" to eliminate an image from the close link */
a.lightbox-close:before {
content: "";
display: block;
height: 30px;
width: 1px;
background: black;
position: absolute;
left: 26px;
top: 10px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
/* Provides part of the "X" to eliminate an image from the close link */
a.lightbox-close:after {
content: "";
display: block;
height: 30px;
width: 1px;
background: black;
position: absolute;
left: 26px;
top: 10px;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
}
/* Uses the :target pseudo-class to perform the animations upon clicking the .lightbox-target anchor */
.lightbox-target:target {
opacity: 1;
top: 0;
bottom: 0;
}
.lightbox-target:target img {
max-height: 100%;
max-width: 100%;
}
.lightbox-target:target a.lightbox-close {
top: 0px;
}
<div id="gravel-button">
<a class="lightbox" href="#gravel-1">
<h7>Photo & Info</h7>
</a>
</div>
<div class="lightbox-target" id="gravel-1">
<img src="http://www.sbsg.com/wp-content/uploads/2010/02/58minus.jpg">
<a class="lightbox-close"></a>
</div>