CSS circular menu <a href> - css

I want to add links to circularmenu found on https://jsfiddle.net/zv5dr670/4/.
<a href="http://www.google.com" target="_blank">
<li>
<input id='1' type='checkbox'>
<label for='1'>Option 1</label>
</li>
</a>
The link is displayed in browser status bar, but dooesn't react on a click. I don't work CSS in school for now, only HTML. Can you help me?

You could add a custom attribute to li element as follows
<li class='link' data-url='https://jsfiddle.net'>
<input id='c1' type='checkbox'/>
<label for='c1'>Menu 1</label>
</li>
Then with jQuery you can bind the link class' click event like this:
$('li.link').click(function(e) {
window.location=$(this).attr('data-url');
});

If you want to make outer circles just links you don't have to use input tag:
HTML
<div class='selector'>
<ul>
<li>Google</li>
<li>Google</li>
<li>Google</li>
<li>Google</li>
<li>Google</li>
<li>Google</li>
<li>Google</li>
<li>Google</li>
<li>Google</li>
</ul>
<button>Click</button>
</div>
<button class ="mycbutton">Click2</button>
CSS
html,
body { height: 100%; }
body {
margin: 0;
background: linear-gradient(#eeeeee, #cccccc);
overflow: hidden;
}
.mycbutton {
}
.selector {
position: absolute;
left: 50%;
top: 50%;
width: 140px;
height: 140px;
margin-top: -70px;
margin-left: -70px;
}
.selector,
.selector button {
font-family: 'Oswald', sans-serif;
font-weight: 300;
}
.selector button {
float:right;
position: relative;
width: 100%;
height: 100%;
padding: 10px;
background: #428bca;
border-radius: 50%;
border: 0;
color: white;
font-size: 20px;
cursor: pointer;
box-shadow: 0 3px 3px rgba(0, 0, 0, 0.1);
transition: all .1s;
}
.selector button:hover { background: #3071a9; }
.selector button:focus { outline: none; }
.selector ul {
position: absolute;
list-style: none;
padding: 0;
margin: 0;
top: -20px;
right: -20px;
bottom: -20px;
left: -20px;
}
.selector li {
position: absolute;
width: 0;
height: 100%;
margin: 0 50%;
-webkit-transform: rotate(-360deg);
transition: all 0.8s ease-in-out;
}
.selector li a {
position: absolute;
left: 50%;
bottom: 100%;
width: 0;
height: 0;
line-height: 1px;
margin-left: 0;
background: #fff;
border-radius: 50%;
text-align: center;
font-size: 1px;
overflow: hidden;
cursor: pointer;
box-shadow: none;
transition: all 0.8s ease-in-out, color 0.1s, background 0.1s;
text-decoration: none;
color: black;
}
.selector li a:hover { background: #f0f0f0; }
.selector.open li a {
width: 80px;
height: 80px;
line-height: 80px;
margin-left: -40px;
box-shadow: 0 3px 3px rgba(0, 0, 0, 0.1);
font-size: 14px;
}
JS
var nbOptions = 9;
var angleStart = -360;
// jquery rotate animation
function rotate(li,d) {
$({d:angleStart}).animate({d:d}, {
step: function(now) {
$(li)
.css({ transform: 'rotate('+now+'deg)' })
.find('a')
.css({ transform: 'rotate('+(-now)+'deg)' });
}, duration: 0
});
}
// show / hide the options
function toggleOptions(s) {
$(s).toggleClass('open');
var li = $(s).find('li');
var deg = $(s).hasClass('half') ? 180/(li.length-1) : 360/li.length;
for(var i=0; i<li.length; i++) {
var d = $(s).hasClass('half') ? (i*deg)-90 : i*deg;
$(s).hasClass('open') ? rotate(li[i],d) : rotate(li[i],angleStart);
}
}
$('.selector button').click(function(e) {
toggleOptions($(this).parent());
});
$('.mycbutton').click(function(e) {
toggleOptions($(this).parent());
});
setTimeout(function() { toggleOptions('.selector'); }, 100);
Run it on JSFiddle

Related

CSS: Reverse :checked functionality

Hello fellow developers,
I'm building a sidebar component with view and am struggling to reverse the :checked functionality.
The issue is somewhere here:
#menu__toggle:checked ~ .menu__box {
left: 0 !important;
}
Expected result: I want the sidebar menu to be open by default. I want it to toggle -> close when I clicked.
The code snippet is pure html and css. I hope someone has a good idea how to fix this.
Thank you in advance.
#menu__toggle {
opacity: 0;
}
#menu__toggle:checked + .menu__btn > span {
transform: rotate(45deg);
}
#menu__toggle:checked + .menu__btn > span::before {
top: 0;
transform: rotate(0deg);
}
#menu__toggle:checked + .menu__btn > span::after {
top: 0;
transform: rotate(90deg);
}
#menu__toggle:checked ~ .menu__box {
left: 0 !important;
}
.menu__btn {
position: fixed;
top: 20px;
left: 20px;
width: 26px;
height: 26px;
cursor: pointer;
z-index: 1;
}
.menu__btn > span,
.menu__btn > span::before,
.menu__btn > span::after {
display: block;
position: absolute;
width: 100%;
height: 2px;
background-color: #616161;
transition-duration: .25s;
}
.menu__btn > span::before {
content: '';
top: -8px;
}
.menu__btn > span::after {
content: '';
top: 8px;
}
.menu__box {
display: block;
position: fixed;
top: 0;
left: -100%;
width: 300px;
height: 100%;
margin: 0;
padding: 80px 0;
list-style: none;
background-color: #ECEFF1;
box-shadow: 2px 2px 6px rgba(0, 0, 0, .4);
transition-duration: .25s;
}
.menu__item {
display: block;
padding: 12px 24px;
color: #333;
font-family: 'Roboto', sans-serif;
font-size: 20px;
font-weight: 600;
text-decoration: none;
transition-duration: .25s;
}
.menu__item:hover {
background-color: #CFD8DC;
}
<div class="hamburger-menu">
<input id="menu__toggle" type="checkbox" />
<label class="menu__btn" for="menu__toggle">
<span></span>
</label>
<ul class="menu__box">
<li><a class="menu__item" href="#">Home</a></li>
<li><a class="menu__item" href="#">About</a></li>
<li><a class="menu__item" href="#">Team</a></li>
<li><a class="menu__item" href="#">Contact</a></li>
<li><a class="menu__item" href="#">Twitter</a></li>
</ul>
</div>
You can reverse selectors with the :not pseudo selector.
In your case simply combine it with the :checked selector.
#menu__toggle:not(:checked)

vuejs show hide nav with transitions

www.bluecanvasdigital.co.uk have a full screen nav menu with icons that fade in quite nicely. However I would to go in the opposite direction when the .open class is removed from the nav-container class when the user clicks the 'cross' button.
So in more detail the images fade out to the right one by one and the blue background fades up. I can only get one way to work. Is there a nice clever way to do this with vuejs2 and css?
I want to not use JS if i can and just keep this css to save code.
Here is the code:
App.vue:-
<script>
export default {
name: 'App',
data() {
return {
navIsActive: false
}
},
methods: {
toggleNav() {
this.navIsActive = !this.navIsActive
}
}
}
</script>
<template>
<div id="app">
<a href="" id="logo">
<img src="./static/img/logo.svg" alt="logo" v-bind:class="{ hide: navIsActive }">
</a>
<div class="hamburger-menu" v-on:click="toggleNav" v-bind:class="{ active: navIsActive }">
<span class="top"></span>
<span class="middle"></span>
<span class="bottom"></span>
</div>
<div id="nav-container" v-bind:class="{ open: navIsActive }">
<p v-if="!navIsActive">hello</p>
<nav>
<ul>
<li>
<img src="./static/img/github.svg" alt="Github">
Github
</li>
<li>
<img src="./static/img/behance.svg" alt="Behance">
Behance
</li>
<li>
<img src="./static/img/medium.svg" alt="Medium">
Medium
</li>
</ul>
</nav>
</div>
<div class="landing-container">
<div class="landing-title">
<h1>Stay tuned</h1>
<p class="landing-subtitle">website launching soon</p>
</div>
<vue-particles
color="#ffffff"
:particleOpacity="0.1"
linesColor="#FFF"
:particlesNumber="120"
shapeType="circle"
:particleSize="3"
:linesWidth="2"
:lineLinked="true"
:lineOpacity="0.8"
:linesDistance="150"
:moveSpeed="0.8"
:hoverEffect="true"
hoverMode="grab"
:clickEffect="true"
clickMode="push"
>
</vue-particles>
</div>
</div>
</template>
<style lang="scss">
#import 'src/static/styles/_global.scss';
</style>
_nav.scss:-
[#import 'src/static/styles/_hamburger.scss';
#nav-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 0%;
opacity: 0;
visibility: hidden;
overflow: hidden;
transition: opacity .35s, visibility .35s, height .35s;
&.open {
opacity: $nav-fullscreen-opacity;
visibility: visible;
height: 100%;
background: $nav-fullscreen-bg;
transition: opacity .35s, visibility .35s, height .35s;
z-index: 101;
li {
animation: fadeInRight .5s ease forwards;
animation-delay: .35s;
margin-bottom: 36%;
img {
height: 75%;
margin: 0;
}
&:nth-of-type(2) {
animation-delay: .4s;
}
&:nth-of-type(3) {
animation-delay: .45s;
}
&:nth-of-type(4) {
img {
margin: 0px 0px -10px 0px;
}
animation-delay: .50s;
margin-bottom: 0;
}
}
}
nav {
position: relative;
height: 100%;
top: 50%;
padding-top: 4%;
padding-bottom: 4%;
transform: translateY(-50%);
font-size: 50px;
font-weight: bold;
text-align: center;
#media (max-width: 767px) {
margin-top: 6%;
margin-bottom: 4%;
padding: none;
}
}
ul {
list-style: none;
padding: 0;
margin: 0 auto;
display: inline-block;
position: relative;
height: 100%;
li {
display: block;
height: 25%;
height: calc(100% / 4);
min-height: 50px;
position: relative;
opacity: 0;
a {
display: block;
position: relative;
color: $nav-fullscreen-color;
font-family: 'HalisGR-Bold', Arial, sans-serif;
font-size: 2.5rem;
text-transform: uppercase;
text-decoration: none;
overflow: hidden;
#media (max-width: 767px) {
font-size: 1.4rem;
}
&:hover:after,
&:focus:after,
&:active:after {
width: 100%;
}
&:after {
content: '';
position: absolute;
bottom: 0;
left: 50%;
width: 0%;
transform: translateX(-50%);
height: 3px;
background: $hamburger-link;
transition: .35s;
}
}
}
}
}
#keyframes fadeInRight {
0% {
opacity: 0;
left: 20%;
}
100% {
opacity: 1;
left: 0;
}
}
][1]

Slight glitch in CSS animation

There's a very small glitch in a CSS animation I've made for a responsive menu icon that turns into an "X" when clicked. The top line of the menu icon flickers down about 1px once the X shape has been made, so it is effectively still moving once the others have stopped. I've been messing around with it for hours but haven't been able to stop it happening – can anyone think of a way in which I could do this, or even a better way of achieving that animation?
https://jsfiddle.net/8nj5y4t1/58/
HTML:
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</span>
CSS:
.menu-button {
position: relative;
top: 0;
right: 0;
display: inline-block;
z-index: 10;
width: 21px;
height: 14px;
padding: 2px 0 2px 0;
cursor: pointer;
vertical-align: middle;
}
.bar {
display: block;
position: absolute;
width: 21px;
height: 2px;
background-color:#888;
-webkit-transition: all .8s;
transition: all .8s;
}
.bar:nth-child(3n) {
top: 2px;
}
.bar:nth-child(3n+1) {
top: 8px;
opacity:1;
}
.bar:nth-child(3n+2) {
top: 14px;
}
.bar.open {
background-color:#666;
}
.bar:nth-child(3n).open {
transform: rotate(45deg);
width: 23px;
left: -1px;
top: 7.5px;
}
.bar:nth-child(3n+1).open {
opacity:0;
}
.bar:nth-child(3n+2).open {
transform: rotate(-45deg);
width: 23px;
left: -1px;
top: 7.5px;
}
jQuery:
jQuery(document).ready(function($) {
$('.menu-button').click(function() {
$('.bar').toggleClass('open');
});
});
.bar:nth-child(3n+1) top property and .bar:nth-child(3n).open and .bar:nth-child(3n+2).open top properties should be off same value;
Example
I replaced top:7.5px with top:8px at .bar:nth-child(3n).open and .bar:nth-child(3n+2).open
jQuery(document).ready(function($) {
$('.menu-button').click(function() {
$('.bar').toggleClass('open');
});
});
.menu-button {
position: relative;
top: 0;
right: 0;
display: inline-block;
z-index: 10;
width: 21px;
height: 14px;
padding: 2px 0 2px 0;
cursor: pointer;
vertical-align: middle;
}
.bar {
display: block;
position: absolute;
width: 21px;
height: 2px;
background-color:#888;
-webkit-transition: all .8s;
transition: all .8s;
}
.bar:nth-child(3n) {
top: 2px;
}
.bar:nth-child(3n+1) {
top: 8px;
opacity:1;
}
.bar:nth-child(3n+2) {
top: 14px;
}
.bar.open {
background-color:#666;
}
.bar:nth-child(3n).open {
transform: rotate(45deg);
width: 23px;
left: -1px;
top: 8px; /* Changed this from 7.5px to 8px */
}
.bar:nth-child(3n+1).open {
opacity:0;
}
.bar:nth-child(3n+2).open {
transform: rotate(-45deg);
width: 23px;
left: -1px;
top: 8px; /* Changed this from 7.5px to 8px */
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span class="menu-button">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</span>

AngularJS ng-class after :active or :focus

I have a form I am trying to create using CSS to achieve a halfway "material" feel. I achieved a lot of the animations by ditching the stock bootstrap forms entirely and rewriting them to get the maximum amount of flexibility.
EDIT: Forgot to link Codepen - http://codepen.io/h3xc0ntr0l/pen/ONwdLm
Essentially, the "form groups" are set to position:relative and used to position the input and a couple pseudo elements absolutely, yada yada. I am using angular and am not able to incorporate jquery into the project.
my problem is as follows
<div class="-form-group">
<input type="email" class="-form-input" ng-class='{"content":"user.email"}' ng-model="user.email"/>
<span class="in-email"></span>
</div>
this does not have the behavior i need. I guess if I have "ng-model", then whatever is in there is going to evaluate to true.
I also tried the following with scss:
.-form-input{
border: none;
box-shadow: none;
border-radius: 0;
font-size: 1rem;
background: none;
outline: none;
width: 100%;
margin-top: 2em;
position: relative;
z-index:4;
&:active, &:focus{
.in-email &{ //
&:before{
top: -50%;
color: transparent;
border-bottom: transparent;
}
}
}
}
the effects are achieved via
.in-email, .in-pwd{
&:before{
position: absolute;
top: 50%;
left: 0%;
width: 100%;
z-index:3;
color: black;
transition: 500ms ease all;
border-bottom: 1.5px solid rgba(128,128,128, .5);
}
}
I can not think of anything else that would prevent the span from coming back down after i leave the hover regardless of whether or not there is any content. does anyone have any tips?
(function(){
angular.module('app').controller([
'$scope', function($scope){
$scope.user = undefined;
}
]);
})();
form {
width: 100%;
padding: 1em;
border: .25px solid #e9e9e9;
box-shadow: 0 1rem 3rem 0 rgba(0, 0, 0, 0.33);
height: 20rem;
margin: 0 auto;
}
form .-form-group {
position: relative;
width: 100%;
height: auto;
transition: 500ms ease;
margin: 0 1em 2em 0;
}
form .-form-group .-form-input {
border: none;
box-shadow: none;
border-radius: 0;
font-size: 1rem;
background: none;
outline: none;
width: 100%;
margin-top: 2em;
position: relative;
z-index: 4;
}
.in-email form .-form-group .-form-input:active:before, .in-email form .-form-group .-form-input:focus:before {
top: -50%;
color: transparent;
border-bottom: transparent;
}
form .-form-group input:-webkit-autofill {
background-color: #e9e9e9 !important;
}
form .-form-group:after {
content: "";
display: block;
transition: 250ms 500ms ease all;
border-bottom: 1.5px solid #288690;
width: 0;
}
form .-form-group:hover:after, form .-form-group:focus:after, form .-form-group:active:after {
content: "";
width: 100%;
top: 90%;
}
form .-form-group:hover .in-email:before, form .-form-group:hover .in-pwd:before, form .-form-group:focus .in-email:before, form .-form-group:focus .in-pwd:before, form .-form-group:active .in-email:before, form .-form-group:active .in-pwd:before {
top: -50%;
color: transparent;
border-bottom: transparent;
}
form .button {
border-radius: 1px;
border: none;
}
form .in-email:before, form .in-pwd:before {
position: absolute;
top: 50%;
left: 0%;
width: 100%;
z-index: 3;
color: black;
transition: 500ms ease all;
border-bottom: 1.5px solid rgba(128, 128, 128, 0.5);
}
.content:before {
content: "" !important;
}
.in-email:before {
content: "Email Address";
}
.in-pwd:before {
content: "Password";
}
.nav, .pagination, .carousel, .panel-title a {
cursor: pointer;
}
#ui-root {
margin-top: 5rem;
padding: 1rem;
}
.ui-container {
position: relative;
width: 100%;
padding: 0 10% 0 10%;
}
.button {
background-color: #288690 !important;
}
<link rel="stylesheet" href="http://getbootstrap.com/dist/css/bootstrap.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<div class="container">
<div class="ui-container">
<div class="row" id="ui-root">
<div class="col-sm-12 col-md-4 col-md-offset-4">
<form autocomplete="off" class="text-center">
<!-- chrome autcomplete -->
<div class="-form-group">
<input type="email" class="-form-input" ng-class='{"content": "user.email"}' ng-model="user.email"/>
<span class="in-email"></span>
</div>
<div class="-form-group">
<input type="password" class="-form-input" ng-class='{"content": "user.password"}' ng-model="user.password" />
<span ng-class='{"content": "user.password"}' class="in-pwd"></span>
</div>
<button class="btn btn-primary button">Login</button>
</form>
</div>
</div>
</div>
</div>

JS free Button linked with a "popup"/overlay

I try to open a 'popup'/overlay with a javascript button. Unfortunately my button does not to open it.
Where I am making mistake? Is there a better way to do it?
It should be javascript free.
…………………………………………………………………………………………………………………
/* popup */
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity 500ms;
visibility: hidden;
opacity: 0;
}
.overlay:target {
visibility: visible;
opacity: 1;
}
.popup {
margin: 70px auto;
padding: 20px;
background: #fff;
border-radius: 5px;
width: 80%;
height: 80%;
position: relative;
transition: all 5s ease-in-out;
}
.popup h2 {
margin-top: 0;
color: #333;
font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
position: absolute;
top: 2%;
right: 4%;
transition: all 200ms;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #333;
}
.popup .close:hover {
color: orange;
}
.popup .content {
max-height: 30%;
overflow: auto;
}
<button href="#popup4">btn1</button>
<div id="popup4" class="overlay">
<div class="popup"><h2>Here i am</h2>
<a class="close" href="#">×</a>
<div class="content">
Thank to pop me out of that button, but now i'm done so you can close this window.
</div>
</div>
</div>
Your button alone doesn't do anything, it has to submit via a form.
<form method="get" action="#popup4">
<button>btn1</button>
</form>

Resources