Off-screen navigation - right and left - css only - html

I'm trying to create a right and left off-screen navigation drawer with only css and I'm having problems getting each side to work properly.
I'm using checkboxes as my buttons like this:
<input type="checkbox" id="toggle-right">
<input type="checkbox" id="toggle-left">
If I have the toggle-right place on top then the right drawer opens, but not the left.
If I reverse the order like this:
<input type="checkbox" id="toggle-left">
<input type="checkbox" id="toggle-right">
Toggle left will work, but not toggle right.
I made a JSFiddle to show you what I mean.
If someone has time to take a look and help me figure this out I would appreciate it.
While reviewing the JSFiddle, reverse the order of the checkbox toggles to see what I'm talking about.

The problem lies with the usage of + - adjacent sibling selector. As it works only for next element to your checkbox, it will only works for one of them. The solution is to use ~ - general sibling selector.
header {
width: 100%;
height: 90px;
background-color:#f1f1f1;}
.menu-toggle {
text-decoration: none;
text-align: center;
width: 44px;
height: 44px;
font-size: 30px;
color: rgba(0, 0, 0, 0.5);
-webkit-transition: all 0.15s ease-out 0s;
-moz-transition: all 0.15s ease-out 0s;
transition: all 0.15s ease-out 0s;
position: absolute;
top: 0px;
right: auto;
bottom: 0;
left: 20px;
z-index: 2; }
.menu-toggle:hover {
color: #000000; }
#toggle-left {
display: none; }
#toggle-left:checked ~ .page-wrap nav.menu {
left: 0px; }
#toggle-left:checked ~ .page-wrap .menu-toggle {
left: 220px; }
.profile-toggle {
text-decoration: none;
text-align: center;
width: 44px;
height: 44px;
font-size: 30px;
color: rgba(0, 0, 0, 0.5);
-webkit-transition: all 0.15s ease-out 0s;
-moz-transition: all 0.15s ease-out 0s;
transition: all 0.15s ease-out 0s;
position: absolute;
top: 0px;
right: 40px;
bottom: 0;
left: auto;
z-index: 2; }
.profile-toggle:hover {
color: #000000; }
#toggle-right {
display: none; }
#toggle-right:checked + .page-wrap nav.profile {
right: 0px; }
#toggle-right:checked + .page-wrap .profile-toggle {
right: 220px; }
nav.menu {
position: fixed;
top: 0px;
right: auto;
bottom: 0px;
left: -270px;
-webkit-transition: all 0.15s ease-out 0s;
-moz-transition: all 0.15s ease-out 0s;
transition: all 0.15s ease-out 0s;
height: auto;
width: 200px;
background: #111111;
z-index: 2000; }
nav.profile {
position: fixed;
top: 0px;
right: -270px;
bottom: 0px;
left: auto;
-webkit-transition: all 0.15s ease-out 0s;
-moz-transition: all 0.15s ease-out 0s;
transition: all 0.15s ease-out 0s;
height: auto;
width: 200px;
background: #990000;
z-index: 2000; }
<input type="checkbox" id="toggle-left">
<input type="checkbox" id="toggle-right">
<div class="page-wrap">
<header>
<div class="top-bar">
<label for="toggle-left" class="menu-toggle">☰</label>
<label for="toggle-right" class="profile-toggle"><b>+</b></label>
</div>
<div class="middle-line"></div>
<div class="bottom-bar"></div>
</header>
<nav class="menu">
</nav>
<nav class="profile">
</nav>

Related

need to link the snippet to a url

Please I need your assistance to link the toggle to 2 separate links.. example..1 is www.google.com and second is www.ask.com
I need the 2 links linked to any of the ends of the switch so when it is selected , the switch moves to the selected end and also opens a new windows relating to the link above
.flipswitch {
position: relative;
width: 195px;
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select: none;
}
.flipswitch input[type=checkbox] {
display: none;
}
.flipswitch-label {
display: block;
overflow: hidden;
cursor: pointer;
border: 2px solid #999999;
border-radius: 50px;
}
.flipswitch-inner {
width: 200%;
margin-left: -100%;
-webkit-transition: margin 0.3s ease-in 0s;
-moz-transition: margin 0.3s ease-in 0s;
-ms-transition: margin 0.3s ease-in 0s;
-o-transition: margin 0.3s ease-in 0s;
transition: margin 0.3s ease-in 0s;
}
.flipswitch-inner:before, .flipswitch-inner:after {
float: left;
width: 50%;
height: 34px;
padding: 0;
line-height: 34px;
font-size: 18px;
color: white;
font-family: Trebuchet, Arial, sans-serif;
font-weight: bold;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.flipswitch-inner:before {
content: "ask view";
padding-left: 13px;
background-color: #256799;
color: #FFFFFF;
}
.flipswitch-inner:after {
content: "google View";
padding-right: 13px;
background-color: #EBEBEB;
color: #888888;
text-align: right;
}
.flipswitch-switch {
width: 31px;
margin: 1.5px;
background: #FFFFFF;
border: 2px solid #999999;
border-radius: 50px;
position: absolute;
top: 0;
bottom: 0;
right: 160px;
-webkit-transition: all 0.3s ease-in 0s;
-moz-transition: all 0.3s ease-in 0s;
-ms-transition: all 0.3s ease-in 0s;
-o-transition: all 0.3s ease-in 0s;
transition: all 0.3s ease-in 0s;
}
.flipswitch-cb:checked + .flipswitch-label .flipswitch-inner {
margin-left: 0;
}
.flipswitch-cb:checked + .flipswitch-label .flipswitch-switch {
right: 0;
}
<div class="flipswitch">
<input type="checkbox" checked="" id="fs" class="flipswitch-cb" name="flipswitch">
<label for="fs" class="flipswitch-label">
<div class="flipswitch-inner"> </div>
<div class="flipswitch-switch"></div>
</label>
</div>
Like this
document.getElementById("fs").addEventListener("change",function() {
const loc = this.checked ? "https://www.google.com" : "https://ask.com/";
console.log(loc)
// window.open(loc,"_blank"); // only works if browser allows it
location = loc; // will work in all cases where the target allows it
})
.flipswitch {
position: relative;
width: 195px;
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select: none;
}
.flipswitch input[type=checkbox] {
display: none;
}
.flipswitch-label {
display: block;
overflow: hidden;
cursor: pointer;
border: 2px solid #999999;
border-radius: 50px;
}
.flipswitch-inner {
width: 200%;
margin-left: -100%;
-webkit-transition: margin 0.3s ease-in 0s;
-moz-transition: margin 0.3s ease-in 0s;
-ms-transition: margin 0.3s ease-in 0s;
-o-transition: margin 0.3s ease-in 0s;
transition: margin 0.3s ease-in 0s;
}
.flipswitch-inner:before, .flipswitch-inner:after {
float: left;
width: 50%;
height: 34px;
padding: 0;
line-height: 34px;
font-size: 18px;
color: white;
font-family: Trebuchet, Arial, sans-serif;
font-weight: bold;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.flipswitch-inner:before {
content: "ask view";
padding-left: 13px;
background-color: #256799;
color: #FFFFFF;
}
.flipswitch-inner:after {
content: "google View";
padding-right: 13px;
background-color: #EBEBEB;
color: #888888;
text-align: right;
}
.flipswitch-switch {
width: 31px;
margin: 1.5px;
background: #FFFFFF;
border: 2px solid #999999;
border-radius: 50px;
position: absolute;
top: 0;
bottom: 0;
right: 160px;
-webkit-transition: all 0.3s ease-in 0s;
-moz-transition: all 0.3s ease-in 0s;
-ms-transition: all 0.3s ease-in 0s;
-o-transition: all 0.3s ease-in 0s;
transition: all 0.3s ease-in 0s;
}
.flipswitch-cb:checked + .flipswitch-label .flipswitch-inner {
margin-left: 0;
}
.flipswitch-cb:checked + .flipswitch-label .flipswitch-switch {
right: 0;
}
<div class="flipswitch">
<input type="checkbox" checked="" id="fs" class="flipswitch-cb" name="flipswitch">
<label for="fs" class="flipswitch-label">
<div class="flipswitch-inner"> </div>
<div class="flipswitch-switch"></div>
</label>
</div>

-webkit-transition not working on google chrome

I've been working on a site and I've encountered a problem with transitions which only only happens in Chrome. Somehow Chrome doesn't want to do the transition which every other browser I use ( Safari, Firefox ) does.
Here's the HTML:
<div class="kategoria_box">
<div class="kategoria_box_header">
<h4>Fürdő</h4>
</div>
<div class="kategoria_box_image">
<a href="termekek/kategoriak/furdo/">
<img src="http://mondano.hu/img/furdo.jpg">
<span class="caption">
<p>Fürdőszoba</p>
</span>
</a>
</div>
</div>
and here's the CSS:
div.kategoria_box_image {
font-size: 1.5em;
font-weight: 200;
cursor: pointer;
float: left;
position: relative;
overflow: hidden;
}
div.kategoria_box_image img {
left: 0;
max-width: 460px;
-webkit-transition: all 600ms ease-out;
-moz-transition: all 600ms ease-out;
-o-transition: all 600ms ease-out;
-ms-transition: all 600ms ease-out;
transition: all 600ms ease-out;
}
div.kategoria_box_image .caption {
opacity: 0;
height: 100%;
text-align: left;
padding: 60px 0 0px 0px;
background-color: #fff;
position: absolute;
color: #5d5d5d;
z-index: 100;
-webkit-transition: all 600ms ease-out;
-moz-transition: all 600ms ease-out;
-o-transition: all 600ms ease-out;
-ms-transition: all 600ms ease-out;
transition: all 600ms ease-out;
left: 0;
}
div.kategoria_box_image:hover .caption {
opacity: 0.82;
}
Is something wrong about my code apart from being coded in my own unique style ?
You don't need the webkit- prefix anymore. You forgot to set top:0 for span.caption
http://caniuse.com/#feat=css-transitions
Here's my codepen:
http://codepen.io/dschu/pen/XbwYom
div.kategoria_box_image {
font-size: 1.5em;
font-weight: 200;
cursor: pointer;
float: left;
position: relative;
overflow: hidden;
}
div.kategoria_box_image img {
left: 0;
max-width: 460px;
transition: all 600ms ease-out;
}
div.kategoria_box_image .caption {
opacity: 0;
height: 100%;
text-align: left;
padding: 60px 0 0px 0px;
background-color: #fff;
position: absolute;
color: #5d5d5d;
z-index: 100;
transition: all 600ms ease-out;
top: 0;
left: 0;
}
div.kategoria_box_image:hover .caption {
opacity: 0.82;
}

CSS Transitions for checkbox not working

I have this piece of HTML (placed on CSSDesk):
<section style="margin-top: 50px;">
<header style="margin-bottom: 30px;">My checkboxes</header>
<div class="checkbox">
<input type="checkbox" id="checkbox"/>
<label for="checkbox"></label>
</div>
</section>
And this piece of CSS, also placed on CSSDesk:
input[type="checkbox"]{
display: none;
}
.checkbox{
position: relative;
width: 60px;
height: 2px;
background-color: black;
border-radius: 10%;
}
.checkbox input[type="checkbox"] + label{
top: -10px;
cursor: pointer;
position: absolute; /*otherwise ,,left: x px;" isn't working*/
display: block;
width: 20px;
height: 20px;
border-radius: 100%;
background-color: blue;
-webkit-transition: all .5s ease;
-moz-transition: all .5s ease;
-o-transition: all .5s ease;
-ms-transition: all .5s ease;
transition: all .5s ease;
}
.checkbox input[type="checkbox"]:checked + label{
left: 80%;
}
Impressed by Paul Underwood checkboxes I follow his tutorial: How To Style A Checkbox With CSS. Unfortunately, transition (I copied in 100% from tutorial) didn't work. And I don;t have any idea why. Here is my entire code, placed in CSS Desk: CSS Desk Decorative checkboxes. I will be pleased if anybody decides to help me - thank you in advance. My browser - Opera 25.0
You forgot to insert left: 0px in .checkbox label{...} class , because you expect that transition will be applied to transformation in x-Axis. Here is a working snippet.
input[type="checkbox"] {
display: none;
}
.checkbox {
position: relative;
width: 60px;
height: 2px;
background-color: black;
border-radius: 10%;
}
.checkbox label {
/*insert next line*/
left: 0px;
top: -10px;
cursor: pointer;
position: absolute;
/*otherwise ,,left: x px;" isn't working*/
display: block;
width: 20px;
height: 20px;
border-radius: 100%;
background-color: blue;
-webkit-transition: all .5s ease;
-moz-transition: all .5s ease;
-o-transition: all .5s ease;
-ms-transition: all .5s ease;
transition: all .5s ease;
}
.checkbox input[type="checkbox"]:checked + label {
left: 80%;
}
<section style="margin-top: 50px;">
<header style="margin-bottom: 30px;">My checkboxes</header>
<div class="checkbox">
<input type="checkbox" id="checkbox" />
<label for="checkbox"></label>
</div>
</section>

Move checkbox label when box is checked

I'm looking for some help to move my checkbox label after the label has been checked. When it starts out, the label is in the middle of the code. After I click on it, however, I would like for it to be moved. I thought that I had it, but it doesn't look that way now. Is there anybody that would be willing to lend a hand?
JSFiddle: http://jsfiddle.net/50c419nL/4/
Markup:
<div id="vera-gallery">
<div class="vera-check">
<label for="vone">e x i l e</label>
<input type="checkbox" id="vone" name="main" />
<div class="vera-bar">I'm controlled by toggle. No JavaScript!</div>
</div>
</div>
CSS:
#vera-gallery {
width: 500px;
height: 500px;
overflow: hidden;
background-image:url(http://i.imgur.com/ZOmzzeE.png);
margin: auto;
position: relative;
}
#vera-gallery input[type=checkbox] {
display: none;
}
.vera-check {
width: 500px;
height: 500px;
}
.vera-check input[type=checkbox] {
position: absolute;
top: 50%;
left: 50%;
}
.vera-check input[type=checkbox]:checked ~ .vera-bar {
margin-left: 0;
}
.vera-check label {
cursor: pointer;
}
.vera-check label[for=vone] {
top: 235px;
width: 80px;
text-align: center;
font-family: oxygen;
font-size: 8px;
text-transform: uppercase;
letter-spacing: 1px;
color: #fff;
text-align: center;
padding: 10px;
position: absolute;
background-color: rgba(0, 0, 0, 0.8);
left: 200px;
border: 1px solid #fff;
}
.vera-check input[type=checkbox]:checked ~ label[for=vone] {
top: 10px;
left: 10px;
}
.vera-bar {
width: 470px;
padding: 15px;
background-color: rgba(0, 0, 0, 0.8);
float: left;
top: 0px;
height: 100%;
font-family: oxygen;
font-weight: bold;
color: #fff;
margin-left: -500px;
transition: 0.5s all ease;
-webkit-transition: 0.5s all ease;
-moz-transition: 0.5s all ease;
-ms-transition: 0.5s all ease;
-o-transition: 0.5s all ease;
}
.vera-ships {
width: 225px;
padding: 15px;
background-color: rgba(0, 0, 0, 0.8);
float: left;
top: 0px;
height: 100%;
font-family: oxygen;
font-weight: bold;
color: #fff;
margin-left: -255px;
transition: 0.5s all ease;
-webkit-transition: 0.5s all ease;
-moz-transition: 0.5s all ease;
-ms-transition: 0.5s all ease;
-o-transition: 0.5s all ease;
}
.vera-two {
position: absolute;
}
.vera-two .vera-chk {
float: left
}
.vera-two input[type=checkbox] {
display: none
}
The general sibling selector will not work in this case, with the markup as-is, since the checkbox input does not precede the label.
The ~ combinator separates two selectors and matches the second
element only if it is preceded by the first, and both share a common
parent.
If, however, you move the label after the div, it works: http://jsfiddle.net/50c419nL/5/
<div id="vera-gallery">
<div class="vera-check">
<input type="checkbox" id="vone" name="main" />
<div class="vera-bar">I'm controlled by toggle. No JavaScript!</div>
<label for="vone">e x i l e</label><!-- moved to here -->
</div>
</div>

CSS Drop Down List Hover mouse not work

i have a code HTML CODE:
<div class="wrapper-demo">
<div id="dd" class="wrapper-dropdown-2" tabindex="1">Sign in with
<ul class="dropdown">
<li><i class="icon-twitter icon-large"></i>Twitter</li>
<li><i class="icon-github icon-large"></i>Github</li>
<li><i class="icon-facebook icon-large"></i>Facebook</li>
</ul>
</div>
</div>
AND CSS:
.wrapper-dropdown-2 {
position: relative;
width: 200px;
margin: 0 auto;
padding: 10px 15px;
background: #fff;
border-left: 5px solid orange;
cursor: pointer;
text-align: left;
cursor: pointer;
outline: none;
}
.wrapper-dropdown-2:after {
content: "";
width: 0;
height: 0;
position: absolute;
right: 16px;
top: 50%;
margin-top: -3px;
border-width: 6px 6px 0 6px;
border-style: solid;
border-color: grey transparent;
}
.dropdown {
display:none;
}
.wrapper-dropdown-2:hover ul.dropdown {
position: absolute;
display:block;
top: 100%;
left: -5px;
right: 0px;
background: white;
-webkit-transition: all 0.3s ease-out;
-moz-transition: all 0.3s ease-out;
-ms-transition: all 0.3s ease-out;
-o-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
list-style: none;
opacity: 0;
pointer-events: none;
}
.wrapper-dropdown-2 .dropdown li a {
display: block;
text-decoration: none;
color: #333;
border-left: 5px solid;
padding: 10px;
-webkit-transition: all 0.3s ease-out;
-moz-transition: all 0.3s ease-out;
-ms-transition: all 0.3s ease-out;
-o-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
}
http://jsfiddle.net/pvt3e/
and i try, in hover mouse to: Sign in with open the drop down but its not work !
i cant work with js. Because I have a problem with 1.8.2, but I think we can find a solution with CSS
try this
.wrapper-dropdown-2:hover ul{
display:block;
}
updated jsFiddle File
also remove .dropdown:hover from your style
You are missing to add hover code to see drop down when hover over. add css for hover.
.wrapper-dropdown-2:hover .dropdown
{
display:block;
}
Live Demo
Just Replace Your This CSS
.dropdown:hover {
/* Size & position */
position: absolute;
display:block;
top: 100%;
left: -5px;
right: 0px;
/* Styles */
background: white;
-webkit-transition: all 0.3s ease-out;
-moz-transition: all 0.3s ease-out;
-ms-transition: all 0.3s ease-out;
-o-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
list-style: none;
/* Hiding */
opacity: 0;
pointer-events: none;
}
To My CSS and Get Result
.wrapper-dropdown-2:hover > .dropdown {
position: absolute;
display:block;
left: -45px;
background: white;
top:24px;
}
You will need to initialize your javascript as well as link to jquery. I see you are using a dropdown from Codrops why dont you just download the source?