CSS only lightbox- Click to close & zoom - css

I'm trying to create a versitile (for mobile, desktops and tablets) lightbox pop-up. I'm inputting it through Gravityforms, so the link itself can only be HTML.
This code works- but it's a little messy. It has to be gallery, and text, which I've achieved already. I'm using wordpress 4.0 so if there's a better plugin solution I'm open to it.
A nice transition when opening
Resize to fit mobile/smaller screens
Click background to close
There will be multiple galleries on one page.
My code so far
#gallery .item a {
overflow: hidden;
}
#gallery .item a img {
height: 100%;
align-self: center;
}
.lightbox {
/** Hide the lightbox */
display: none;
/** Apply basic lightbox styling */
position: fixed;
z-index: 9999;
width: 100%;
height: 100%;
top: 0;
left: 0;
color:#333333;
}
.lightbox:target {
/** Show lightbox when it is target */
display: block;
outline: none;
}
.lightbox .box {
width: -webkit-min-content;
width: -moz-min-content;
width: min-content;
min-width:500px;
margin: 2% auto;
padding:10px 20px 10px 20px;
background-color:#FFF;
box-shadow: 0px 1px 26px -3px #777777;
}
.lightbox .title {
margin:0;
padding:0 0 10px 0px;
border-bottom:1px #ccc solid;
font-size:22px;
}
.lightbox .content {
display:block;
position:relative;
}
.lightbox .content .desc {
z-index:99;
bottom:0;
position:absolute;
padding:10px;
margin:0 0 4px 0;
background:rgba(0,0,0,0.8);
color:#fff;
font-size:17px;
opacity:0.75;
transition: opacity ease-in-out 0.5s;
}
.lightbox .content:hover .desc {
opacity:0.8;
}
.lightbox .next,
.lightbox .prev,
.lightbox .close {
display:block;
text-decoration:none;
font-family:Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size:22px;
color:#858585;
}
.prev {
float:left;
}
.next, .close {
float:right;
}
.clear {
display:block;
clear:both;
}
I think this is the kind of transition I want:
html { min-height: 100%; position: relative; }
body { margin: 0; height: 100%; margin-right: 2em; background: #110; }
dl { float: left; }
dd a {
background: #fff; display: inline-block;
transition: 4s box-shadow ease-in;
A zoom feature would be great too, (ie from within the lightbox) but I'm unsure that's possible.
Any help is much appreciated
My latest JSFiddle Click here

A nice transition when opening.
Use CSS transition
Resize to fit mobile/smaller screens Use max-width: 100%You might want to experiment with the length of the description in .desc as it seems to be too long for the width of a mobile screen
Click background to close. I think this can be achieved using javascript.
Check out the FIDDLE here.

Related

Is there a way to inherit CSS properties from the parent while modifing some?

For example, CSS properites with multiple inputs:
Is something like this possible?
.button:active {
background-color: rgba(inherit, inherit, inherit, 0.5);
}
Is the only way to do this with a scripted-css like LESS?
You can achieve an answer to the example given by tackling the problem slightly differently. By putting the background colour on a pseudo element with a z-index of -1 so that it sits behind the content (which is given a z-index of 1), and then changing just the opacity... you've achieved what you wanted above without any LESS.
See this fiddle: https://jsfiddle.net/3uopd059/
.button {
padding:1em;
position:relative;
float:left;
color:#000;
z-index:1;
}
.button::after {
content:"";
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
background-color: grey;
z-index:-1;
}
.button:active::after {
opacity:0.5;
}
Of course, if you wanted to change each of the colours independently then you'd need to use another method.
After giving it some thought, here's a workaround that would achieve what you want without anything else but what you gracefully called vanilla CSS. Passing opacity (along with background color) to a pseudo element, absolutely positioned:
#import url('https://fonts.googleapis.com/css?family=Shadows+Into+Light');
button {
font-family: 'Shadows Into Light', cursive;
position: relative;
font-size: 2rem;
color: white;
margin: 1rem;
min-width: 15rem;
background-color: transparent;
-webkit-appearance: none;
-moz-appearance: none;
border: none;
cursor: pointer;
}
button>span {
position: relative;
z-index: 1;
}
button::before {
content: '';
display: block;
position: absolute;
top: 0; left:0;
width: 100%;
height: 100%;
opacity: 1;
transition: opacity .3s cubic-bezier(.4,0,.2,1);
z-index: 0;
background-color: #bada55;
border-radius: .4rem;
}
button[orange]:before {
background-color: #f50;
}
button:hover::before {
opacity:.65; /* <-- the juice is here */
}
/* don't mind the below, i'm just playing */
body {
margin: 0; padding: 0;
}
center-me-please {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
background: transparent url(http://lorempixel.com/g/1200/800/fashion) no-repeat 50% 50% /cover;
}
<center-me-please>
<button><span>#bada55</span></button>
<button orange><span>not so #bada55</span></button>

Two floating columns in container, best way to increase container height to match columns?

I've searched at the Stack Overflow and other sources, for example here.
This is the code, I'm talking about:
.container{
width: 100%;
height: 100%; /*adjust this manually and no issue*/
background: #222222;
margin: 0;
padding: 0;
}
There is a jsfiddle of the section I'm talking about. If the container is changed to (say) 180% it solves all because it's made bigger than everything so everything is sitting on top of it.
I have a container which is the parent here and a child called content which has 2 columns in it. When I write too much in the column, it goes over the container as they are both floating. I can change it manually, so once I'm happy with the text just change the height which is OK. But, I don't think this is good practice and I'm sure there is another way that does it automatically by canceling all the floats. I cant get it to work though.
You need to adjust your CSS like this:
/*
Dark Grey: #222222
Orange: #ff8a00
Light Orange: #ffcc8f
White: #ffffff
*/
body {
background: url("images/river.jpg") no-repeat top center fixed;
background-color: #222222;
background-size: cover;
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
h2 {
color:#ff8a00;
font-size: 1.75em;
letter-spacing: 8px;
padding:30px;
border-bottom: 1px dotted #ff8a00;
width:50%;
margin:0 auto;
padding-top:5%;
}
h3 {
color:#ff8a00;
font-size: 1.1em;
letter-spacing: 8px;
border-bottom: 1px dotted #ff8a00;
margin:0 auto;
padding-top:5%;
}
.container {
width: 100%;
height: auto;
background: #222222;
margin: 0;
padding: 0;
position:relative;
}
.content {
margin:0 auto;
width: 60%;
height: auto;
text-align:center;
background: #fc0;
/*Change to #222222 */
font-family: proximaNova;
font-size:1.1em;
color:white;
display:block;
}
.bio {
margin:0 auto;
width: 70%;
height: auto;
text-align:center;
background: #222222;
/*Change to #222222 */
font-family: proximaNova;
font-size:1em;
font-style:normal;
margin-top:30px;
line-height: 30px;
}
.left-column {
width: 48%;
display:inline-block;
height: auto;
text-align:left;
background: black;
/*Change to #222222 */
font-family: proximaNova;
font-size:1.0em;
margin-top:5%;
}
.right-column {
display:inline-block;
width: 48%;
height: auto;
text-align:left;
background: black;
/*Change to #222222 */
font-family: proximaNova;
font-size:1.0em;
margin-top:5%;
}
.footer {
width:100%;
background-color: white;
text-align:center;
color:#222222;
font-size:1em;
font-family: proximaNova;
}
.nav-text {
margin-left:20px;
margin-top:25px;
font-family:trench;
font-size:22px;
color: white;
float:left;
}
You're adding 100% height everywhere, as if that's the solution to everything, and that's the cause to most of your issues. If you want to auto adjust sizes to anything then the logical answer for the property is... auto. By setting all your 100% heights to auto and getting rid of your floats (you could use floats, but you must clear them, as we're at it, so showing you another option), you can do this easily, without the ultra complicated and convoluted ways you were trying.
I've forked your fiddle so you can add paddings, margins etc. Also changed the background on one of your divs just so you see how the box model works, but of course you can (and should) change it to anything
See MDN page for more info on HEIGHT PROPERTY syntax, behavior and examples
Try this
jsfiddle
.container{
width: 100%;
background: #222222;
margin: 0;
padding: 0;
float:left;
}

How can I make the content area a different colour from the wrapper?

I'd like to do two things: the first of these is to centre a content area of 1200px width. I'd like the navigation menu to be this width as well. The second thing I'd like to do is change the colour of this content area to white; whilst allowing a background area (wrapper) around the edge of the content area to remain the same colour.
/* BACKGROUND */
body {
background-color: #ECF0F1;
overflow-y: scroll;
}
*{
margin:0;
padding:0;
}
img {
border:0;
}
/* AREA */
#wrapper {
margin:0 auto;
position: absolute;
width: 1200px;
background:#339999;
font-size:1.20em;
}
/* HEADER */
#header {
margin-top: 40px;
height: 100px;
width: 100%;
}
/* PAGE */
#content {
min-height:400px;
padding:23px;
text-align:justify;
line-height:1.5;
}
It would be great if you could- for me and other users looking to format a webpage in a similar manner- tell me how to set up this content area and navigation bar
Thank You!
#menu {
position: fixed;
z-index: +1;
width: 1200px;
background-color: #E74C3C;
height: 100px;
margin: 0 auto; /* add this to make it center */
left: 0; /* to give position of fixed menu */
right: 0; /* to give position of fixed menu */
}
#content {
min-height: 400px;
background-color: #fff; /* to color white your content */
padding: 23px;
text-align: justify;
line-height: 1.5;
}
Here is a smaller sample (in pixels) of what you're looking for:
D E M O
Ofcourse you can change the width to 1200px as needed..
/* BACKGROUND */
html { height:100%; width:100%;}
body {
background-color: #ECF0F1;
height:100%; width:100%;
}
*{
margin:0;
padding:0;
}
img {
border:0;
}
/* AREA */
#wrapper {
margin:0 auto;
height:100%;
width: 300px;
border:3px solid #339999;
font-size:1.20em;
box-sizing:border-box;
}
/* HEADER */
#header {
background:#ff6600;
margin:0 auto;
height: 100px;
width: 100%;
text-align:center;
font:bold 16px/100px arial;
}
/* PAGE */
#content {
height:calc(100% - 100px);
margin:0 auto;
text-align:center;
font:bold 16px/200px arial;
background:white;
}
Well you have to do so many things here. Update the following class in your CSS. This will give basic alignment.
#menu {
position: relative;
z-index: 1;
width: 1200px;
background-color: #E74C3C;
height: 100%;
margin: 0px auto;
}
#header
{
/* margin-top: 40px; */
height: 100px;
width: 100%;
}
#content {
min-height:400px;
padding:23px;
text-align:justify;
line-height:1.5;
background-color: #fff;
}

Css 100% height: footer scrolling in to content when re-sizing page

I been following a tutorial for making my webpage css 100% height from this SITE. I been able to achieve what i want but now I am having an issue with my footer. Every time I resize the page smaller the footer will slightly scroll upwards into the content. Is there a way i can stop that? Here is my Live EXAMPLE
Thank you
css
<style>
html, body {
margin:0;
padding:0;
height:100%; /* needed for container min-height */
background:#333333;
font-family: trebuchet, 'trebuchet ms', 'tahoma', sans-serif;
font-size:small;
color:#5e5e5e;
line-height: 130%;
}
/****** COLORBLOCK: this is the orangey-yellow bar behind the wrapper in the background. ******/
#colorblock {
position: absolute;
top: 60px;
left: 0px;
background: #c69a55;
z-index: 0;
height: 65px;
width: 100%;
padding: 0px;
margin: 0px;
}
/**************************************************/
div#container {
position:relative; /* needed for footer positioning*/
margin:0 auto; /* center, not in IE5 */
width:925px;
background:#f0f0f0;
height:auto !important; /* real browsers */
height:100%; /* IE6: treaded as min-height*/
min-height:100%; /* real browsers */
border-right: 15px solid #000000;
border-left: 15px solid #000000;
}
div#contentArea {
padding:1em 1em 5em; /* bottom padding for footer */
}
div#contentArea p {
text-align:justify;
padding:0 1em;
}
#content {
margin-left: 240px;
margin-right: 0 auto;
background: #ebebeb;
padding: 5px;
width:635px;
height: 400px;
}
/****** TOP BANNER: This is the banner with Greg's List logo and main navigation. Also includes the styles for the main navigation links. ******/
div#header {
/*padding:1em;*/
height: 175px;
border-top:15px solid #000000;
}
div#header p {
margin:0;
}
/****** LEFT COLUMN: This is the left gray column next to the content. Features the styling for the log-in form and the location links. ******/
#left2 {
float: left;
width: 200px;
background: #dddddd;
-moz-border-radius: 10px;
border-radius: 10px;
margin-right: 15px;
padding: 5px;
height: 400px;
}
/****** FOOTER: This is the junk at the bottom of the page. Do NOT remove the clear div; it's what makes it stick to the bottom. ******/
div#footer {
position:absolute;
width:100%;
bottom:0; /* stick to bottom */
background:#7A7A7A;
border-bottom:15px solid #000000;
}
div#footer p {
padding:1em;
margin:0;
}
a.footer {
color: #c7c7c7;
font-size: 80%;
padding-right: 20px;
letter-spacing: 1px;
}
p {
margin:0 0 1em;
}
</style>
Add margin-bottom:60px; to the #content css definition.
Full block:
#content {
margin-left: 240px;
margin-right: 0 auto;
margin-bottom: 60px;
background: #ebebeb;
padding: 5px;
width:635px;
height: 400px;
}
Since you have an explicit height set on your content div, you could do:
padding-bottom:36px; on your div#container line 32
But if your content div changes in height, it may not account for that padding anymore.

CSS: positioning issue

So i have a slideshow, here's the css to start with:
#slideshow {
position:relative;
height:300px;
width: 477px;
border: 1px solid #FFF;
float: left;
margin-bottom: 30px;
margin-left: 20px;
}
#slideshow IMG {
position:absolute;
top:0;
left:0;
z-index:8;
opacity:0.0;
}
#slideshow IMG.active {
z-index:10;
opacity:1.0;
}
#slideshow IMG.last-active {
z-index:9;
}
And then i have a box, that i want to be on top of the slideshow.. but right now its under the slideshow, even if its position absolute..
#regForm {
position: absolute;
top: 120px;
left: 500px;
background: #000;
color: #FFF;
width: 500px;
height: 240px;
border: 6px solid #18110c;
text-align: center;
margin: 40px;
padding: 1px;
opacity: 0.75;
-moz-opacity: 0.75; /* older Gecko-based browsers */
filter:alpha(opacity=75); /* For IE6&7 */
}
How should i positioning it right so the div box comes on top of the slideshow and not under?
Add z-index:11; to the #regForm style declaration.

Resources