I am trying to achieve six divisions of circular menu in here
(function(window) {
'use strict';
// class helper functions from bonzo https://github.com/ded/bonzo
function classReg(className) {
return new RegExp("(^|\\s+)" + className + "(\\s+|$)");
}
// classList support for class management
// altho to be fair, the api sucks because it won't accept multiple classes at once
var hasClass, addClass, removeClass;
if ('classList' in document.documentElement) {
hasClass = function(elem, c) {
return elem.classList.contains(c);
};
addClass = function(elem, c) {
elem.classList.add(c);
};
removeClass = function(elem, c) {
elem.classList.remove(c);
};
} else {
hasClass = function(elem, c) {
return classReg(c).test(elem.className);
};
addClass = function(elem, c) {
if (!hasClass(elem, c)) {
elem.className = elem.className + ' ' + c;
}
};
removeClass = function(elem, c) {
elem.className = elem.className.replace(classReg(c), ' ');
};
}
function toggleClass(elem, c) {
var fn = hasClass(elem, c) ? removeClass : addClass;
fn(elem, c);
}
var classie = {
// full names
hasClass: hasClass,
addClass: addClass,
removeClass: removeClass,
toggleClass: toggleClass,
// short names
has: hasClass,
add: addClass,
remove: removeClass,
toggle: toggleClass
};
// transport
if (typeof define === 'function' && define.amd) {
// AMD
define(classie);
} else {
// browser global
window.classie = classie;
}
})(window);
// EventListener | #jon_neal | //github.com/jonathantneal/EventListener
!window.addEventListener && window.Element && (function() {
function addToPrototype(name, method) {
Window.prototype[name] = HTMLDocument.prototype[name] = Element.prototype[name] = method;
}
var registry = [];
addToPrototype("addEventListener", function(type, listener) {
var target = this;
registry.unshift({
__listener: function(event) {
event.currentTarget = target;
event.pageX = event.clientX + document.documentElement.scrollLeft;
event.pageY = event.clientY + document.documentElement.scrollTop;
event.preventDefault = function() {
event.returnValue = false
};
event.relatedTarget = event.fromElement || null;
event.stopPropagation = function() {
event.cancelBubble = true
};
event.relatedTarget = event.fromElement || null;
event.target = event.srcElement || target;
event.timeStamp = +new Date;
listener.call(target, event);
},
listener: listener,
target: target,
type: type
});
this.attachEvent("on" + type, registry[0].__listener);
});
addToPrototype("removeEventListener", function(type, listener) {
for (var index = 0, length = registry.length; index < length; ++index) {
if (registry[index].target == this && registry[index].type == type && registry[index].listener == listener) {
return this.detachEvent("on" + type, registry.splice(index, 1)[0].__listener);
}
}
});
addToPrototype("dispatchEvent", function(eventObject) {
try {
return this.fireEvent("on" + eventObject.type, eventObject);
} catch (error) {
for (var index = 0, length = registry.length; index < length; ++index) {
if (registry[index].target == this && registry[index].type == eventObject.type) {
registry[index].call(this, eventObject);
}
}
}
});
})();
* {
position: relative;
-moz-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
list-style: none;
}
html,
body {
height: 100%;
}
body {
color: #fff;
}
.content-div {
position: relative;
margin-bottom: 3em;
height: 15em;
font-family: 'Lato', Arial, sans-serif;
}
.main_button {
position: absolute;
top: 100%;
left: 50%;
z-index: 11;
margin-top: -2.25em;
margin-left: -2.25em;
padding-top: 0;
width: 4.5em;
height: 4.5em;
border: none;
border-radius: 50%;
background: none;
background-color: #fff;
color: green;
text-align: center;
font-weight: 700;
font-size: 1.5em;
text-transform: uppercase;
cursor: pointer;
}
.csstransforms .main_wrapper {
position: absolute;
top: 100%;
left: 50%;
z-index: 10;
margin-top: -13em;
margin-left: -13.5em;
width: 27em;
height: 27em;
border-radius: 50%;
background: transparent;
opacity: 0;
-webkit-transition: all .3s ease 0.3s;
-moz-transition: all .3s ease 0.3s;
transition: all .3s ease 0.3s;
-webkit-transform: scale(0.1);
-ms-transform: scale(0.1);
-moz-transform: scale(0.1);
transform: scale(0.1);
pointer-events: none;
overflow: hidden;
}
.csstransforms .main_wrapper:after {
content: ".";
display: block;
font-size: 2em;
width: 6.2em;
height: 6.2em;
position: absolute;
left: 50%;
margin-left: -3.1em;
top: 50%;
margin-top: -3.1em;
border-radius: 50%;
z-index: 10;
color: transparent;
}
.csstransforms .opened-nav {
border-radius: 50%;
opacity: 1;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
transition: all .3s ease;
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
pointer-events: auto;
}
.csstransforms .main_wrapper li {
position: absolute;
top: 50%;
left: 50%;
overflow: hidden;
margin-top: -1.3em;
margin-left: -10em;
width: 10em;
height: 10em;
font-size: 1.5em;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
transition: all .3s ease;
-webkit-transform: rotate(75deg) skew(62deg);
-moz-transform: rotate(75deg) skew(62deg);
-ms-transform: rotate(75deg) skew(62deg);
transform: rotate(75deg) skew(62deg);
-webkit-transform-origin: 100% 100%;
-moz-transform-origin: 100% 100%;
transform-origin: 100% 100%;
pointer-events: none;
}
.csstransforms .main_wrapper li a {
position: absolute;
right: -7.25em;
bottom: -7.25em;
display: block;
width: 14.5em;
height: 14.5em;
border-radius: 50%;
background: green;
background: -webkit-radial-gradient(transparent 35%, green 35%);
background: -moz-radial-gradient(transparent 35%, green 35%);
background: radial-gradient(transparent 35%, green 35%);
color: #fff;
text-align: center;
text-decoration: none;
font-size: 1.2em;
line-height: 2;
-webkit-transform: skew(-62deg) rotate(-75deg) scale(1);
-moz-transform: skew(-62deg) rotate(-75deg) scale(1);
-ms-transform: skew(-62deg) rotate(-75deg) scale(1);
transform: skew(-62deg) rotate(-75deg) scale(1);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
pointer-events: auto;
}
.csstransforms .main_wrapper li a span {
position: relative;
top: 1em;
display: block;
font-size: .5em;
font-weight: 700;
text-transform: uppercase;
}
.csstransforms .main_wrapper li a:hover,
.csstransforms .main_wrapper li a:active,
.csstransforms .main_wrapper li a:focus {
background: -webkit-radial-gradient(transparent 35%, red 35%);
background: -moz-radial-gradient(transparent 35%, red 35%);
background: radial-gradient(transparent 35%, red 35%);
}
.csstransforms .opened-nav li {
-webkit-transition: all .3s ease .3s;
-moz-transition: all .3s ease .3s;
transition: all .3s ease .3s;
}
.csstransforms .opened-nav li:first-child {
-webkit-transform: skew(62deg);
-moz-transform: skew(62deg);
-ms-transform: skew(62deg);
transform: skew(62deg);
}
.csstransforms .opened-nav li:nth-child(2) {
-webkit-transform: rotate(30deg) skew(62deg);
-moz-transform: rotate(30deg) skew(62deg);
-ms-transform: rotate(30deg) skew(62deg);
transform: rotate(60deg) skew(62deg);
}
.csstransforms .opened-nav li:nth-child(3) {
-webkit-transform: rotate(60deg) skew(62deg);
-moz-transform: rotate(60deg) skew(62deg);
-ms-transform: rotate(60deg) skew(62deg);
transform: rotate(120deg) skew(62deg);
}
.csstransforms .opened-nav li:nth-child(4) {
-webkit-transform: rotate(90deg) skew(62deg);
-moz-transform: rotate(90deg) skew(62deg);
-ms-transform: rotate(90deg) skew(62deg);
transform: rotate(180deg) skew(62deg);
}
.csstransforms .opened-nav li:nth-child(5) {
-webkit-transform: rotate(120deg) skew(62deg);
-moz-transform: rotate(120deg) skew(62deg);
-ms-transform: rotate(120deg) skew(62deg);
transform: rotate(240deg) skew(62deg);
}
.csstransforms .opened-nav li:nth-child(6) {
-webkit-transform: rotate(150deg) skew(62deg);
-moz-transform: rotate(150deg) skew(62deg);
-ms-transform: rotate(150deg) skew(62deg);
transform: rotate(300deg) skew(62deg);
}
.no-csstransforms .main_wrapper {
overflow: hidden;
margin: 10em auto;
padding: .5em;
text-align: center;
}
.no-csstransforms .main_wrapper ul {
display: inline-block;
}
.no-csstransforms .main_wrapper li {
float: left;
width: 5em;
height: 5em;
background-color: #fff;
text-align: center;
font-size: 1em;
line-height: 5em;
}
.no-csstransforms .main_wrapper li a {
display: block;
width: 100%;
height: 100%;
color: inherit;
text-decoration: none;
}
.no-csstransforms .main_wrapper li a:hover,
.no-csstransforms .main_wrapper li a:active,
.no-csstransforms .main_wrapper li a:focus {
background-color: #f8f8f8;
}
.no-csstransforms .main_wrapper li.active a {
background-color: #6F325C;
color: #fff;
}
.no-csstransforms .main_button {
display: none;
}
#media only screen and (max-width: 620px) {
.no-csstransforms li {
width: 4em;
height: 4em;
line-height: 4em;
}
}
#media only screen and (max-width: 500px) {
.no-ccstransforms .main_wrapper {
padding: .5em;
}
.no-csstransforms .main_wrapper li {
width: 4em;
height: 4em;
font-size: .9em;
line-height: 4em;
}
}
#media only screen and (max-width: 480px) {
.csstransforms .main_wrapper {
font-size: .68em;
}
.main_button {
font-size: 1em;
}
}
#media only screen and (max-width:420px) {
.no-csstransforms .main_wrapper li {
width: 100%;
height: 3em;
line-height: 3em;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.js"></script>
<div class="container">
<div class="content-div">
<button class="main_button" id="main_button">Content</button>
<div class="main_wrapper opened-nav" id="main_wrapper">
<ul>
<li><span>PIE 1</span></li>
<li><span>PIE 2</span></li>
<li><span>PIE 3</span></li>
<li><span>PIE 4</span></li>
<li><span>PIE 5</span></li>
<li><span>PIE 6</span></li>
</ul>
</div>
</div>
</div>
I couldn't adjust the size of each pie, as you can see huge gap in between each pie.
Please let me know how to adjust the size of pie?
Here is another idea based on this previous answer where you have CSS variables to easily control the gap and the size of your elements:
.palette {
--g: 10px; /* The gap between shapes*/
--s: 80px; /* the size*/
height: 300px;
width: 300px;
position: relative;
display: block;
margin:auto;
overflow: hidden;
}
.palette>* {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border: var(--s) solid red;
border-radius: 50%;
clip-path: polygon(
calc(50% + var(--g)/2) 50%,
calc(50% + var(--g)/2) 0%,
100% 0%,
100% calc(21.13% - var(--g)/2),
50% calc(50% - var(--g)/2));
}
.palette>*:nth-child(1) {
transform: rotate(72deg);
}
.palette>*:nth-child(2) {
transform: rotate(144deg);
}
.palette>*:nth-child(3) {
transform: rotate(-72deg);
}
.palette>*:nth-child(4) {
transform: rotate(-144deg);
}
.palette a {
color: #fff;
display: block;
text-align: center;
transform: translate(42%, calc(-1*var(--s)/2)) rotate(35deg);
font-size: 20px;
}
.palette *:hover {
border-color:blue;
}
<div class="palette">
<div>link</div>
<div>link</div>
<div>link</div>
<div>link</div>
<div>link</div>
<div>link</div>
</div>
Related
I want to create segment(s) to the exterior of a circular segment, I've looked and implemented a few sites, including, Codrops site, and implemented a partial solution PFA, partial solution, but what i really want is something more like, PFA target solution image, target solution
The desired goal would be to fit as many segments as we can, relative to the interior segment, for example, an interior segment of 120 deg can fit 3 circular rectangular segments of 40 deg each, or 2 of them with 60 deg each respectively.
This is how my current code looks like in REACT, I tried fiddling around with the z-index and rotations of the outer (second) layer, but they just wont stay in the same aligned positions.
import React, { useEffect, useState } from 'react';
import styled from 'styled-components';
const RadialMenuStyles = styled.div`
.cn-wrapper {
font-size:1em;
width: 65em;
height: 65em;
overflow: hidden;
position: fixed;
z-index: 10;
bottom: -13em;
left: 50%;
border-radius: 50%;
margin-left: -13em;
transform: scale(0.1);
transition: all .3s ease;
}
/* class applied to the container via JavaScript that will scale the navigation up */
.opened-nav {
border-radius: 50%;
transform: scale(1);
}
.cn-button {
border:none;
background:none;
color: white;
text-align: Center;
font-size: 1.5em;
padding-bottom: 1em;
height: 3.5em;
width: 3.5em;
background-color: #111;
position: fixed;
left: 50%;
margin-left: -1.75em;
bottom: -1.75em;
border-radius: 50%;
cursor: pointer;
z-index: 11
}
.cn-button:hover,
.cn-button:active,
.cn-button:focus{
background-color: #222;
}
.cn-overlay{
width:100%
height:100%;
background-color: rgba(0,0,0,0.6);
position:fixed;
top:0;
left:0;
bottom:0;
right:0;
opacity:0;
transition: all .3s ease;
z-index:2;
pointer-events:none;
}
/* Class added to the overlay via JavaScript to show it when navigation is open */
.cn-overlay.on-overlay{
pointer-events:auto;
opacity:1;
}
.cn-wrapper li {
position: absolute;
font-size: 1.5em;
width: 10em;
height: 10em;
transform-origin: 100% 100%;
overflow: hidden;
z-index: 10000;
left: 50%;
top: 50%;
margin-top: -1.3em;
margin-left: -10em;
transition: border .3s ease;
}
.cn-wrapper .second-layer li {
position: absolute;
z-index: 100;
font-size: 1.5em;
width: 10em;
height: 10em;
transform-origin: 100% 100%;
left: 40%;
top: 40%;
overflow: hidden;
margin-top: -1.5em;
margin-left: -10em;
transition: border .3s ease;
}
.cn-wrapper li a {
display: block;
font-size: 1.18em;
height: 14.5em;
width: 14.5em;
position: absolute;
bottom: -7.25em;
right: -7.25em;
border-radius: 50%;
text-decoration: none;
color: #fff;
padding-top: 1.8em;
text-align: center;
transform: skew(-50deg) rotate(-70deg) scale(1);
transition: opacity 0.3s, color 0.3s;
}
.cn-wrapper .second-layer li a {
display: block;
font-size: 1.18em;
height: 8.75em;
width: 8.75em;
position: absolute;
bottom: -4.375em;
right: -4.375em;
border-radius: 50%;
text-decoration: none;
color: #fff;
padding-top: 0.8em;
text-align: center;
transform: skew(-30deg) rotate(-60deg) scale(1.5);
transition: opacity 0.3s, color 0.3s;
}
.cn-wrapper li a span {
font-size: 1.1em;
opacity: 0.7;
}
/* for a central angle x, the list items must be skewed by 90-x degrees
in our case x=40deg so skew angle is 50deg
items should be rotated by x, minus (sum of angles - 180)2s (for this demo) */
.cn-wrapper li:first-child {
transform: rotate(-10deg) skew(50deg);
}
.cn-wrapper li:nth-child(2) {
transform: rotate(30deg) skew(50deg);
}
.cn-wrapper li:nth-child(3) {
transform: rotate(70deg) skew(50deg)
}
.cn-wrapper li:nth-child(4) {
transform: rotate(110deg) skew(50deg);
}
.cn-wrapper li:nth-child(5) {
transform: rotate(150deg) skew(50deg);
}
.cn-wrapper li:nth-child(odd) a {
background-color: #a11313;
background-color: hsla(0, 88%, 63%, 1);
}
.cn-wrapper li:nth-child(even) a {
background-color: #a61414;
background-color: hsla(0, 88%, 65%, 1);
}
/* active style */
.cn-wrapper li.active a {
background-color: #b31515;
background-color: hsla(0, 88%, 70%, 1);
}
.cn-wrapper .second-layer li:first-child {
transform: rotate(-10deg) skew(30deg);
}
.cn-wrapper .second-layer li:nth-child(2) {
transform: rotate(50deg) skew(30deg);
}
// .cn-wrapper .second-layer li:nth-child(3) {
// transform: rotate(80deg) skew(50deg)
// }
/* hover style */
.cn-wrapper li:not(.active) a:hover,
.cn-wrapper li:not(.active) a:active,
.cn-wrapper li:not(.active) a:focus {
background-color: #b31515;
background-color: hsla(0, 88%, 70%, 1);
}
.cn-wrapper li:not(.active) a:focus {
position: fixed; /* fix the "displacement" bug in webkit browsers when using tab key */
}
`;
export const RadialMenuComponent: React.FC = () => {
const [openRadialMenu, setOpenRadialMenu] = useState<boolean>(false);
return (
<RadialMenuStyles>
{/* <button className='cn-button' onClick={() => setOpenRadialMenu(true)}>+</button>
{openRadialMenu &&
<ul>
</ul>
} */}
<button className="cn-button" id="cn-button" onClick={() => setOpenRadialMenu(!openRadialMenu)}>+</button>
{openRadialMenu && <div className="opened-nav cn-wrapper" id="cn-wrapper">
<ul>
<li><span className="icon-picture">1</span></li>
<li><span className="icon-headphones">2</span></li>
<li><span className="icon-home">3</span></li>
<li><span className="icon-facetime-video">4</span></li>
<li><span className="icon-envelope-alt">5</span></li>
</ul>
<div className="second-layer">
<ul>
<li><span className="icon-picture">6</span></li>
<li><span className="icon-headphones">7</span></li>
{/* <li><span className="icon-home">8</span></li> */}
{/* <li><span className="icon-facetime-video">4</span></li>
<li><span className="icon-envelope-alt">5</span></li> */}
</ul>
</div>
</div>}
<div id="cn-overlay" className="cn-overlay"></div>
</RadialMenuStyles>
);
};
I did 8 menus with the radical circle menu. But I have 8 numbers that need to surround a circle menu. I am having a bit of a problem, thought it would be a good idea to have a circle menu with numbers surrounding it, the problem that I have is that only the number circle is not placed properly, maybe I mess up something in the code, could you help me?
I am just confused about this number circle.
.component {
position: relative;
margin-bottom: 3em;
height: 15em;
}
.cn-button {
position: absolute;
top: 115%;
left: 56%;
z-index: 11;
margin-top: -4.5em;
margin-left: -5em;
padding: 0;
width: 8em;
height: 8em;
border: none;
border-radius: 50%;
background: none;
background-color: #004691;
color: #5f259f;
text-align: center;
font-weight: 700;
font-size: 1em;
text-transform: uppercase;
cursor: pointer;
-webkit-backface-visibility: hidden;
border: 6px solid #fff;
}
.circle-wrapper {
// width: 680px;
height: 501px;
border-radius: 51%;
// background: Chartreuse;
position: relative;
// margin: 100px;
transform: rotate(23deg);
}
.circle {
display: block;
position: absolute;
top: 54%;
left: 54%;
width: 50px;
height: 50px;
margin: -48px -48px -48px -53px;
background: red;
border-radius: 51%;
text-align: center;
line-height: 50px;
}
.deg-0 {
transform: rotate(45deg) translate(251px) rotate(-65deg);
background: #5ede29;
color: white;
font-weight: 600;
}
.deg-45 {
transform: rotate(90deg) translate(251px) rotate(-110deg);
background: #ffe816;
color: white;
font-weight: 600;
}
.deg-90 {
transform: rotate(135deg) translate(251px) rotate(-158deg);
background: #f74015;
color: white;
font-weight: 600;
}
.deg-135 {
transform: rotate(180deg) translate(251px) rotate(-200deg);
background: #54bef8;
color: white;
font-weight: 600;
}
.deg-180 {
transform: rotate(225deg) translate(251px) rotate(-248deg);
background: #5ede29;
color: white;
font-weight: 600;
}
.deg-225 {
transform: rotate(270deg) translate(251px) rotate(-289deg);
background: #ffe816;
color: white;
font-weight: 600;
}
.deg-270 {
transform: rotate(315deg) translate(251px) rotate(-338deg);
background: #f74015;
color: white;
font-weight: 600;
}
.deg-315 {
background: #54bef8;
transform: rotate(360deg) translate(251px) rotate(-380deg);
color: white;
font-weight: 600;
}
.btnDeactivated {
background-color: #f7f4f4 !important;
color: rgb(184 124 38);
border: 2px solid #a57c2633 !important;
}
.csstransforms .cn-wrapper {
position: absolute;
top: 100%;
left: 50%;
z-index: 10;
margin-top: -16em;
margin-left: -15.5em;
width: 34em;
height: 34em;
border-radius: 50%;
font-weight: bold;
background: transparent;
/* opacity: 0; */
-webkit-transition: all 0.3s ease 0.3s;
-moz-transition: all 0.3s ease 0.3s;
transition: all 0.3s ease 0.3s;
-webkit-transform: scale(0.1);
-ms-transform: scale(0.1);
-moz-transform: scale(0.1);
transform: scale(0.1);
pointer-events: none;
overflow: hidden;
}
/*cover to prevent extra space of anchors from being clickable*/
.csstransforms .cn-wrapper:after {
content: ".";
display: block;
font-size: 2em;
width: 6.2em;
height: 6.2em;
position: absolute;
left: 50%;
margin-left: -3.1em;
top: 50%;
margin-top: -3.1em;
border-radius: 50%;
z-index: 10;
color: transparent;
}
.csstransforms .opened-nav {
border-radius: 50%;
/* opacity: 0.2; */
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
transition: all 0.3s ease;
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
pointer-events: auto;
}
.cn-wrapper ul {
position: relative;
list-style: none;
margin: 0;
}
.csstransforms .cn-wrapper li {
position: absolute;
top: 50%;
left: 50%;
overflow: hidden;
// margin-top: -1.3em;
margin-left: -12em;
width: 12em;
height: 12em;
font-size: 1.5em;
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
transition: all 0.3s ease;
-webkit-transform: rotate(60deg) skew(60deg);
-moz-transform: rotate(60deg) skew(60deg);
-ms-transform: rotate(60deg) skew(60deg);
transform: rotate(60deg) skew(60deg);
-webkit-transform-origin: 100% 100%;
-moz-transform-origin: 100% 100%;
transform-origin: 100% 100%;
pointer-events: none;
border: 4px solid #fff;
}
.csstransforms .cn-wrapper li a {
position: absolute;
right: -7.25em;
bottom: -7.25em;
display: block;
width: 14.5em;
height: 14.5em;
border-radius: 50%;
-moz-box-sizing: border-box;
box-sizing: border-box;
color: #271b1b;
text-align: center;
text-decoration: none;
font-size: 1.2em;
line-height: 2;
-webkit-transform: skew(-44deg) rotate(-68deg);
-moz-transform: skew(-44deg) rotate(-68deg);
-ms-transform: skew(-44deg) rotate(-68deg);
transform: skew(-44deg) rotate(-68deg);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
pointer-events: auto;
letter-spacing: 1px;
}
.csstransforms .cn-wrapper li a span {
position: relative;
top: 3.8em;
display: block;
font-size: 0.7em;
font-weight: bolder;
text-transform: uppercase;
left: -22px;
}
.csstransforms .cn-wrapper li a:hover {
color: white;
}
.csstransforms .cn-wrapper li a {
top: 32px;
transition: top 1s ease 0s;
}
.csstransforms .cn-wrapper li a:active,
.csstransforms .cn-wrapper li a:focus {
color: rgb(255, 255, 255);
font-size: 30px;
font-weight: 600;
text-shadow: 2px 2px 10px black;
top: 19px;
}
.csstransforms .cn-wrapper li a:focus {
position: fixed; /* fix the displacement bug in webkit browsers when using tab key */
}
.csstransforms .opened-nav li {
-webkit-transition: all 0.3s ease 0.3s;
-moz-transition: all 0.3s ease 0.3s;
transition: all 0.3s ease 0.3s;
}
.csstransforms .opened-nav li:first-child {
transform: rotate(45deg) skew(45deg);
background: #5ede29;
}
.csstransforms .opened-nav li:nth-child(2) {
transform: rotate(90deg) skew(45deg);
background: #ffe816;
}
.csstransforms .opened-nav li:nth-child(3) {
transform: rotate(135deg) skew(45deg);
background: #f74015;
}
.csstransforms .opened-nav li:nth-child(4) {
transform: rotate(180deg) skew(45deg);
background: #54bef8;
}
.csstransforms .opened-nav li:nth-child(5) {
transform: rotate(225deg) skew(45deg);
background: #5ede29;
}
.csstransforms .opened-nav li:nth-child(6) {
transform: rotate(270deg) skew(45deg);
background: #ffe816;
}
.csstransforms .opened-nav li:nth-child(7) {
transform: rotate(315deg) skew(45deg);
background: #f74015;
}
.csstransforms .opened-nav li:nth-child(8) {
background: #54bef8;
transform: rotate(360deg) skew(45deg);
}
.no-csstransforms .cn-wrapper {
overflow: hidden;
margin: 10em auto;
padding: 0.5em;
text-align: center;
}
.no-csstransforms .cn-wrapper ul {
display: inline-block;
}
.no-csstransforms .cn-wrapper li {
float: left;
width: 5em;
height: 5em;
background-color: #fff;
text-align: center;
font-size: 1em;
line-height: 5em;
}
.no-csstransforms .cn-wrapper li a {
display: block;
width: 100%;
height: 100%;
color: inherit;
text-decoration: none;
}
.no-csstransforms .cn-wrapper li a:hover,
.no-csstransforms .cn-wrapper li a:active,
.no-csstransforms .cn-wrapper li a:focus {
background-color: #f8f8f8;
}
.no-csstransforms .cn-wrapper li.active a {
background-color: #6f325c;
color: #fff;
}
.no-csstransforms .cn-button {
display: none;
}
.learn {
transform: rotate(23deg);
}
.learn1 {
transform: rotate(-20deg);
}
.learn2 {
transform: rotate(-67deg);
}
.learn3 {
transform: rotate(-112deg);
}
.learn4 {
transform: rotate(-157deg);
}
.learn5 {
transform: rotate(-201deg);
}
.learn6 {
transform: rotate(-247deg);
}
.learn7 {
transform: rotate(69deg);
}
<div class="component csstransforms">
<button class="cn-button" id="cn-button">
<img
style="height: auto; width: 117px"
src="../../assets/Integro-Bank-Logo-Black-background_prev_ui.c022b598.png"
alt="logo"
/>
</button>
<div class="cn-wrapper opened-nav" id="cn-wrapper">
<ul>
<li>
<a #click="showMore" href="javascript:void(0)"
><span class="learn">Learn</span></a
>
</li>
<li>
<a #click="showMore2" href="javascript:void(0)"
><span class="learn1">Review</span></a
>
</li>
<li>
<a #click="showMore3" href="javascript:void(0)"
><span class="learn2">Evaluate</span></a
>
</li>
<li>
<a #click="showMore4" href="javascript:void(0)"
><span class="learn3">Sign-up</span></a
>
</li>
<li>
<a #click="showMore5" href="javascript:void(0)"
><span class="learn4">Engage</span></a
>
</li>
<li>
<a #click="showMore6" href="javascript:void(0)"
><span class="learn5">Share</span></a
>
</li>
<li>
<a #click="showMore7" href="javascript:void(0)"
><span class="learn6">Impact</span></a
>
</li>
<li>
<a #click="showMore8" href="javascript:void(0)"
><span class="learn7">Transform</span></a
>
</li>
</ul>
</div>
<!-- End of Nav Structure -->
</div>
<div class="circle-wrapper">
<div class="circle deg-180 btnDeactivated" id="btn1">1</div>
<div class="circle deg-225 btnDeactivated" id="btn2">2</div>
<div class="circle deg-270 btnDeactivated" id="btn3">3</div>
<div class="circle deg-315 btnDeactivated" id="btn4">4</div>
<div class="circle deg-0 btnDeactivated" id="btn5">5</div>
<div class="circle deg-45 btnDeactivated" id="btn6">6</div>
<div class="circle deg-90 btnDeactivated" id="btn7">7</div>
<div class="circle deg-135 btnDeactivated" id="btn8">8</div>
</div>
It's quite messy, but this is the closest I could get. Comments are added in the snippet below. To sum up, I added some wrappers (see HTML) and changed CSS a little bit.
Please let me know if this is good enough.
.component {
position: relative;
margin-bottom: 3em;
height: 15em;
display: flex; /* Added */
justify-content: center; /* Added */
}
/* Added */
.cn-button-wrapper {
width: 100%;
height: calc(34rem + 250px);
display: flex;
justify-content: center;
align-items: center;
margin-left: 15px;
}
.cn-button {
position: absolute;
/* top: 115%; */ /* Removed */
/* left: 56%; */ /* Removed */
z-index: 11;
/* margin-top: -4.5em; */ /* Removed */
/* margin-left: -5em; */ /* Removed */
padding: 0;
width: 8em;
height: 8em;
border: none;
border-radius: 50%;
background: none;
background-color: #004691;
color: #5f259f;
text-align: center;
font-weight: 700;
font-size: 1em;
text-transform: uppercase;
cursor: pointer;
-webkit-backface-visibility: hidden;
border: 6px solid #fff;
}
/* Added */
.circle-wrapper-outer {
width: 100%;
position: absolute;
top: 0;
top: 100px;
}
.circle-wrapper {
width: 34rem; /* Added */
height: 34rem; /* Added */
border-radius: 50%;
position: relative;
transform: rotate(23deg);
margin-left: auto; /* Added */
margin-right: auto; /* Added */
top: 0; /* Added */
}
.circle {
display: block;
position: absolute;
top: 54%;
left: 54%;
width: 50px;
height: 50px;
margin: -48px -48px -48px -53px;
background: red;
border-radius: 51%;
text-align: center;
line-height: 50px;
}
.deg-0 {
transform: rotate(45deg) translate(251px) rotate(-65deg);
background: #5ede29;
color: white;
font-weight: 600;
}
/* Added */
.deg-0-new {
transform: rotate(45deg) translate(325px) rotate(-65deg);
background: #5ede29;
color: white;
font-weight: 600;
}
.deg-45 {
transform: rotate(90deg) translate(251px) rotate(-110deg);
background: #ffe816;
color: white;
font-weight: 600;
}
/* Added */
.deg-45-new {
transform: rotate(90deg) translate(325px) rotate(-110deg);
background: #ffe816;
color: white;
font-weight: 600;
}
.deg-90 {
transform: rotate(135deg) translate(251px) rotate(-158deg);
background: #f74015;
color: white;
font-weight: 600;
}
/* Added */
.deg-90-new {
transform: rotate(135deg) translate(325px) rotate(-158deg);
background: #f74015;
color: white;
font-weight: 600;
}
.deg-135 {
transform: rotate(180deg) translate(251px) rotate(-200deg);
background: #54bef8;
color: white;
font-weight: 600;
}
/* Added */
.deg-135-new {
transform: rotate(180deg) translate(325px) rotate(-200deg);
background: #54bef8;
color: white;
font-weight: 600;
}
.deg-180 {
transform: rotate(225deg) translate(251px) rotate(-248deg);
background: #5ede29;
color: white;
font-weight: 600;
}
/* Added */
.deg-180-new {
transform: rotate(225deg) translate(305px) rotate(-248deg);
background: #5ede29;
color: white;
font-weight: 600;
}
.deg-225 {
transform: rotate(270deg) translate(251px) rotate(-289deg);
background: #ffe816;
color: white;
font-weight: 600;
}
/* Added */
.deg-225-new {
transform: rotate(270deg) translate(305px) rotate(-289deg);
background: #ffe816;
color: white;
font-weight: 600;
}
.deg-270 {
transform: rotate(315deg) translate(251px) rotate(-338deg);
background: #f74015;
color: white;
font-weight: 600;
}
/* Added */
.deg-270-new {
transform: rotate(315deg) translate(315px) rotate(-338deg);
background: #f74015;
color: white;
font-weight: 600;
}
.deg-315 {
background: #54bef8;
transform: rotate(360deg) translate(251px) rotate(-380deg);
color: white;
font-weight: 600;
}
/* Added */
.deg-315-new {
background: #54bef8;
transform: rotate(360deg) translate(325px) rotate(-380deg);
color: white;
font-weight: 600;
}
.btnDeactivated {
background-color: #f7f4f4 !important;
color: rgb(184 124 38);
border: 2px solid #a57c2633 !important;
}
.csstransforms .cn-wrapper {
position: absolute;
/* top: 100%; */ /* Removed */
/* left: 50%; */ /* Removed */
z-index: 10;
top: 100px; /* Added */
/* margin-top: -16em; */ /* Removed */
/* margin-left: -15.5em; */ /* Removed */
width: 34em;
height: 34em;
border-radius: 50%;
font-weight: bold;
background: transparent;
-webkit-transition: all 0.3s ease 0.3s;
-moz-transition: all 0.3s ease 0.3s;
transition: all 0.3s ease 0.3s;
-webkit-transform: scale(0.1);
-ms-transform: scale(0.1);
-moz-transform: scale(0.1);
transform: scale(0.1);
pointer-events: none;
overflow: hidden;
}
.csstransforms .cn-wrapper:after {
content: ".";
display: block;
font-size: 2em;
width: 6.2em;
height: 6.2em;
position: absolute;
left: 50%;
margin-left: -3.1em;
top: 50%;
margin-top: -3.1em;
border-radius: 50%;
z-index: 10;
color: transparent;
}
.csstransforms .opened-nav {
border-radius: 50%;
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
transition: all 0.3s ease;
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
pointer-events: auto;
}
.cn-wrapper ul {
position: relative;
list-style: none;
margin: 0;
}
.csstransforms .cn-wrapper li {
position: absolute;
top: 50%;
left: 50%;
overflow: hidden;
margin-left: -12em;
width: 12em;
height: 12em;
font-size: 1.5em;
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
transition: all 0.3s ease;
-webkit-transform: rotate(60deg) skew(60deg);
-moz-transform: rotate(60deg) skew(60deg);
-ms-transform: rotate(60deg) skew(60deg);
transform: rotate(60deg) skew(60deg);
-webkit-transform-origin: 100% 100%;
-moz-transform-origin: 100% 100%;
transform-origin: 100% 100%;
pointer-events: none;
border: 4px solid #fff;
}
.csstransforms .cn-wrapper li a {
position: absolute;
right: -7.25em;
bottom: -7.25em;
display: block;
width: 14.5em;
height: 14.5em;
border-radius: 50%;
-moz-box-sizing: border-box;
box-sizing: border-box;
color: #271b1b;
text-align: center;
text-decoration: none;
font-size: 1.2em;
line-height: 2;
-webkit-transform: skew(-44deg) rotate(-68deg);
-moz-transform: skew(-44deg) rotate(-68deg);
-ms-transform: skew(-44deg) rotate(-68deg);
transform: skew(-44deg) rotate(-68deg);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
pointer-events: auto;
letter-spacing: 1px;
}
.csstransforms .cn-wrapper li a span {
position: relative;
top: 3.8em;
display: block;
font-size: 0.7em;
font-weight: bolder;
text-transform: uppercase;
left: -22px;
}
.csstransforms .cn-wrapper li a:hover {
color: white;
}
.csstransforms .cn-wrapper li a {
top: 32px;
transition: top 1s ease 0s;
}
.csstransforms .cn-wrapper li a:active,
.csstransforms .cn-wrapper li a:focus {
color: rgb(255, 255, 255);
font-size: 30px;
font-weight: 600;
text-shadow: 2px 2px 10px black;
top: 19px;
}
.csstransforms .cn-wrapper li a:focus {
position: fixed;
}
.csstransforms .opened-nav li {
-webkit-transition: all 0.3s ease 0.3s;
-moz-transition: all 0.3s ease 0.3s;
transition: all 0.3s ease 0.3s;
}
.csstransforms .opened-nav li:first-child {
transform: rotate(45deg) skew(45deg);
background: #5ede29;
}
.csstransforms .opened-nav li:nth-child(2) {
transform: rotate(90deg) skew(45deg);
background: #ffe816;
}
.csstransforms .opened-nav li:nth-child(3) {
transform: rotate(135deg) skew(45deg);
background: #f74015;
}
.csstransforms .opened-nav li:nth-child(4) {
transform: rotate(180deg) skew(45deg);
background: #54bef8;
}
.csstransforms .opened-nav li:nth-child(5) {
transform: rotate(225deg) skew(45deg);
background: #5ede29;
}
.csstransforms .opened-nav li:nth-child(6) {
transform: rotate(270deg) skew(45deg);
background: #ffe816;
}
.csstransforms .opened-nav li:nth-child(7) {
transform: rotate(315deg) skew(45deg);
background: #f74015;
}
.csstransforms .opened-nav li:nth-child(8) {
background: #54bef8;
transform: rotate(360deg) skew(45deg);
}
.no-csstransforms .cn-wrapper {
overflow: hidden;
margin: 10em auto;
padding: 0.5em;
text-align: center;
}
.no-csstransforms .cn-wrapper ul {
display: inline-block;
}
.no-csstransforms .cn-wrapper li {
float: left;
width: 5em;
height: 5em;
background-color: #fff;
text-align: center;
font-size: 1em;
line-height: 5em;
}
.no-csstransforms .cn-wrapper li a {
display: block;
width: 100%;
height: 100%;
color: inherit;
text-decoration: none;
}
.no-csstransforms .cn-wrapper li a:hover,
.no-csstransforms .cn-wrapper li a:active,
.no-csstransforms .cn-wrapper li a:focus {
background-color: #f8f8f8;
}
.no-csstransforms .cn-wrapper li.active a {
background-color: #6f325c;
color: #fff;
}
.no-csstransforms .cn-button {
display: none;
}
.learn {
transform: rotate(23deg);
}
.learn1 {
transform: rotate(-20deg);
}
.learn2 {
transform: rotate(-67deg);
}
.learn3 {
transform: rotate(-112deg);
}
.learn4 {
transform: rotate(-157deg);
}
.learn5 {
transform: rotate(-201deg);
}
.learn6 {
transform: rotate(-247deg);
}
.learn7 {
transform: rotate(69deg);
}
<div class="component csstransforms">
<div class="cn-button-wrapper">
<button class="cn-button" id="cn-button">
<img style="height: auto; width: 117px" src="../../assets/Integro-Bank-Logo-Black-background_prev_ui.c022b598.png" alt="logo" />
</button>
</div>
<div class="cn-wrapper opened-nav" id="cn-wrapper">
<ul>
<li>
<a #click="showMore" href="javascript:void(0)"><span class="learn">Learn</span></a>
</li>
<li>
<a #click="showMore2" href="javascript:void(0)"><span class="learn1">Review</span></a>
</li>
<li>
<a #click="showMore3" href="javascript:void(0)"><span class="learn2">Evaluate</span></a>
</li>
<li>
<a #click="showMore4" href="javascript:void(0)"><span class="learn3">Sign-up</span></a>
</li>
<li>
<a #click="showMore5" href="javascript:void(0)"><span class="learn4">Engage</span></a>
</li>
<li>
<a #click="showMore6" href="javascript:void(0)"><span class="learn5">Share</span></a>
</li>
<li>
<a #click="showMore7" href="javascript:void(0)"><span class="learn6">Impact</span></a>
</li>
<li>
<a #click="showMore8" href="javascript:void(0)"><span class="learn7">Transform</span></a>
</li>
</ul>
</div>
<!-- End of Nav Structure -->
</div>
<div class="circle-wrapper-outer">
<div class="circle-wrapper">
<div class="circle deg-180-new btnDeactivated" id="btn1">1</div>
<div class="circle deg-225-new btnDeactivated" id="btn2">2</div>
<div class="circle deg-270-new btnDeactivated" id="btn3">3</div>
<div class="circle deg-315-new btnDeactivated" id="btn4">4</div>
<div class="circle deg-0-new btnDeactivated" id="btn5">5</div>
<div class="circle deg-45-new btnDeactivated" id="btn6">6</div>
<div class="circle deg-90-new btnDeactivated" id="btn7">7</div>
<div class="circle deg-135-new btnDeactivated" id="btn8">8</div>
</div>
</div>
I have a menu that I want to drop down when you click on the hamburger icon. The list items show up after the button is clicked, but is still seen when the button is not clicked. I can't figure out how to hide the menu.
I have the code here: Codepen
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
$(document).ready(function() {
$('#nav-icon3').on('click', function() {
$(this).toggleClass('open');
});
});
* {
box-sizing: border-box;
}
html, body {
padding: 0;
margin: 0;
width: 100%;
height: 100%;
font-size: 1rem;
}
.header {
background-color: #FFF;
width: 100%;
margin: 0px auto;
display: block;
top: 0;
margin-top: 7%;
height: 80px;
}
h1 {
margin-left: 5%;
padding-left: 1%;
font-family: 'Lobster', cursive;
margin-top: 0;
float: left;
margin-bottom: 0;
color: #D18E8F;
}
#nav-icon {
width: 30px;
height: 30px;
position: relative;
margin-right: 7%;
margin-top: 8px;
/*padding-right: 1%;*/
float: right;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transition: .5s ease-in-out;
-moz-transition: .5s ease-in-out;
-o-transition: .5s ease-in-out;
cursor: pointer;
}
#nav-icon3 span {
display: block;
position: absolute;
height: 4px;
width: 100%;
background: #8c8c8c;
border-radius: 6px;
opacity: 1;
left: 0;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transition: .25s ease-in-out;
-moz-transition: .25s ease-in-out;
-o-transition: .25s ease-in-out;
transition: .25s ease-in-out;
}
#nav-icon3 span:nth-child(1) {
top: 0px;
}
#nav-icon3 span:nth-child(2), #nav-icon3 span:nth-child(3) {
top: 10px;
}
#nav-icon3 span:nth-child(4) {
top: 20px;
}
#nav-icon3.open span:nth-child(1) {
top: 10px;
width: 0%;
left: 50%;
}
#nav-icon3.open span:nth-child(2) {
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
#nav-icon3.open span:nth-child(3) {
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
}
#nav-icon3.open span:nth-child(4) {
top: 10px;
width: 0%;
left: 50%;
}
.topnav.responsive {
/*display: none;*/
clear: both;
padding: 0;
height: 160px;
}
ul.topnav.responsive {
list-style: none;
font-family: 'Raleway', 'sans-serif';
float: left;
margin-left: 7%;
/*padding-left: 2%;*/
margin-top: 0;
width: 85%;
margin-bottom: 0;
}
ul.topnav.responsive li {
padding-top: 16px;
padding-bottom: 16px;
border-bottom: 1px solid #c6c6c6;
}
ul.topnav.responsive li a {
text-decoration: none;
color: #8c8c8c;
}
ul.topnav.responsive li a:hover {
color: #7EBEA3;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial scale=1.0">
<title>Gabriella Farfan</title>
<link href="https://fonts.googleapis.com/css?family=Lobster|Raleway" rel="stylesheet">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link rel="stylesheet" href="http://fortawesome.github.io/Font-Awesome/assets/font-awesome/css/font-awesome.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="js/main.js"></script>
</head>
<body>
<div class="header">
<h1>Gabriella Farfan</h1>
<div id="nav-icon">
<div id="nav-icon3">
<a id="nav-icon3" onclick="myFunction();">
<span></span>
<span></span>
<span></span>
<span></span>
</a>
</div>
</div>
<ul class="topnav" id="myTopnav">
<li>
Work
</li>
<li>
About Me
</li>
<li style="border-bottom: none">
Contact
</li>
</ul>
</div>
</body>
</html>
Just add .topnav { display: none; } and .topnav.responsive { display: block; } and your code will work fine.
.topnav {
display: none;
}
.topnav.responsive {
display: block;
clear: both;
padding: 0;
height: 160px;
}
You can also add this for make full hamburger clickable (not only line).
#nav-icon3 {
width: 30px;
height: 30px;
display: block;
}
Working fork of your code: Сodepen
I have made this little fix. Hope it helps.
CSS:
* {
box-sizing: border-box;
}
html, body {
padding: 0;
margin: 0;
width: 100%;
height: 100%;
font-size: 1rem;
}
.header {
background-color: #FFF;
width: 100%;
margin: 0px auto;
display: block;
top: 0;
margin-top: 7%;
height: 80px;
}
h1 {
margin-left: 5%;
padding-left: 1%;
font-family: 'Lobster', cursive;
margin-top: 0;
float: left;
margin-bottom: 0;
color: #D18E8F;
}
#nav-icon {
width: 30px;
height: 30px;
position: relative;
margin-right: 7%;
margin-top: 8px;
/*padding-right: 1%;*/
float: right;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transition: .5s ease-in-out;
-moz-transition: .5s ease-in-out;
-o-transition: .5s ease-in-out;
cursor: pointer;
}
#nav-icon3 span {
display: block;
position: absolute;
height: 4px;
width: 100%;
background: #8c8c8c;
border-radius: 6px;
opacity: 1;
left: 0;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transition: .25s ease-in-out;
-moz-transition: .25s ease-in-out;
-o-transition: .25s ease-in-out;
transition: .25s ease-in-out;
}
#nav-icon3 span:nth-child(1) {
top: 0px;
}
#nav-icon3 span:nth-child(2), #nav-icon3 span:nth-child(3) {
top: 10px;
}
#nav-icon3 span:nth-child(4) {
top: 20px;
}
#nav-icon3.open span:nth-child(1) {
top: 10px;
width: 0%;
left: 50%;
}
#nav-icon3.open span:nth-child(2) {
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
#nav-icon3.open span:nth-child(3) {
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
}
#nav-icon3.open span:nth-child(4) {
top: 10px;
width: 0%;
left: 50%;
}
.responsive {
/*display: none;*/
clear: both;
padding: 0;
height: 160px;
}
ul.responsive {
list-style: none;
font-family: 'Raleway', 'sans-serif';
float: left;
margin-left: 7%;
/*padding-left: 2%;*/
margin-top: 0;
width: 85%;
margin-bottom: 0;
}
ul.responsive li {
padding-top: 16px;
padding-bottom: 16px;
border-bottom: 1px solid #c6c6c6;
}
ul.responsive li a {
text-decoration: none;
color: #8c8c8c;
}
ul.responsive li a:hover {
color: #7EBEA3;
}
.topnav{
display:none;
}
JS:
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className = " responsive";
} else {
x.className = "topnav";
}
}
Please let me know if this is what you wanted.
I'm not that much experienced in HTML and I wanted to use a designed radio Button.
So, I used these codes from a website and modified it a little bit.
The problem now is whenever I write a sentence in the label it is not appearing in the same line.
Do you have any idea why is that happening ?
Here are the codes
html {
font-family: "Segoe UI";
}
*, *::after, *::before {
box-sizing: border-box;
}
html, body {
height: 100%;
min-height: 100%;
}
body {
margin: 0;
font-family: 'Raleway', Arial, sans-serif;
}
.toggle-button {
position: relative;
display: inline-block;
color: black;
margin: 0 20px;
}
/*tested*/
.toggle-button label {
display: inline-block;
text-transform: uppercase;
cursor: pointer;
text-align: left;
}
/*tested*/
.toggle-button input {
display: none;
}
.toggle-button__icon {
cursor: pointer;
pointer-events: none;
}
/*to let radio button invites clicking*/
.toggle-button__icon:before, .toggle-button__icon:after {
content: "";
position: absolute;
transition: 0.200s ease-out;
}
/*to make radio button clickable*/
.toggle-button--maa label {
width: 110px; /*space between the options*/
height: 20px;
line-height: 20px; /*line spacing*/
transition: all 0.2s;
}
.toggle-button--maa label:before, .toggle-button--maa label:after {
position: absolute;
top: 0;
left: 30px;
width: 110px;
transition: all 0.2s .1s ease-out;
}
.toggle-button--maa label:before {
content: attr(data-text);
}
.toggle-button--maa input:checked ~ .toggle-button__icon:before {
animation: wave .7s ease-out;
}
.toggle-button--maa input:checked ~ .toggle-button__icon:after {
transform: scale(1);
animation: zoomIn .2s;
}
.toggle-button--maa .toggle-button__icon {
position: absolute;
left: 0;
top: 0;
height: 20px;
width: 20px;
border-radius: 50%;
background: #fff;
box-shadow: inset 1px 1px 10px rgba(0, 0, 0, 0.15);
}
.toggle-button--maa .toggle-button__icon:before, .toggle-button--maa .toggle-button__icon:after {
border-radius: 50%;
}
.toggle-button--maa .toggle-button__icon:before {
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.8);
}
.toggle-button--maa .toggle-button__icon:after {
top: 4px;
left: 4px;
width: 60%;
height: 60%;
background: #61B136;
animation: zoomOut .2s ease-out;
transform: scale(0);
transition: none;
}
.toggle-button--maa:hover input:not(:checked) ~ .toggle-button__icon {
animation: hover .2s;
}
.toggle-button--maa:hover input:not(:checked) ~ label:before {
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}
#keyframes zoomOut {
0% {
transform: scale(1);
}
30% {
transform: scale(1.2);
}
100% {
transform: scale(0);
}
}
#keyframes zoomIn {
0% {
transform: scale(0);
}
90% {
transform: scale(1.2);
}
100% {
transform: scale(1);
}
}
#keyframes hover {
0% {
transform: scale(1);
}
30% {
transform: scale(1.1);
}
100% {
transform: scale(1);
}
}
#keyframes wave {
0% {
opacity: 1;
transform: scale(1);
}
40% {
opacity: 0.2;
}
100% {
opacity: 0;
transform: scale(1.5);
}
}
#keyframes zoomFadeOut {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
#keyframes zoomFadeIn {
0% {
opacity: 0;
transform: scale(3);
}
90% {
opacity: 1;
transform: scale(1);
}
100% {
transform: scale(1);
}
}
#keyframes hover {
0% {
transform: scale(1);
}
30% {
transform: scale(1.1);
}
100% {
transform: scale(1);
}
<div id="ButtonsDiv" class="auto-style4" >
<div class="toggle-button toggle-button--maa">
<input id="toggleButton7" name="radio3" type="radio"/>
<label for="toggleButton7" data-text="Bachelor accounting student" ></label>
<div class="toggle-button__icon"></div>
</div>
<div class="toggle-button toggle-button--maa">
<input id="toggleButton8" name="radio3" type="radio"/>
<label for="toggleButton8" data-text="Bachelor finance student" class="auto-style5"></label>
<div class="toggle-button__icon"></div>
</div>
</div>
The problem is that you set the label and the :before fixed width. Also, you set position:absolute to the :before element.
html {
font-family: "Segoe UI";
}
*, *::after, *::before {
box-sizing: border-box;
}
html, body {
height: 100%;
min-height: 100%;
}
body {
margin: 0;
font-family: 'Raleway', Arial, sans-serif;
}
.toggle-button {
position: relative;
display: inline-block;
color: black;
margin: 0 20px;
}
/*tested*/
.toggle-button label {
display: inline-block;
text-transform: uppercase;
cursor: pointer;
text-align: left;
}
/*tested*/
.toggle-button input {
display: none;
}
.toggle-button__icon {
cursor: pointer;
pointer-events: none;
}
/*to let radio button invites clicking*/
.toggle-button__icon:before, .toggle-button__icon:after {
content: "";
position: absolute;
transition: 0.200s ease-out;
}
/*to make radio button clickable*/
.toggle-button--maa label {
height: 20px;
line-height: 20px; /*line spacing*/
transition: all 0.2s;
}
.toggle-button--maa label:before, .toggle-button--maa label:after {
margin-left:25px;
transition: all 0.2s .1s ease-out;
}
.toggle-button--maa label:before {
content: attr(data-text);
}
.toggle-button--maa input:checked ~ .toggle-button__icon:before,
.toggle-button--maa:hover input ~ .toggle-button__icon:before{
animation: wave .7s ease-out;
}
.toggle-button--maa input:checked ~ .toggle-button__icon:after,
.toggle-button--maa:hover input ~ .toggle-button__icon:after {
transform: scale(1);
animation: zoomIn .2s;
}
.toggle-button--maa .toggle-button__icon {
position: absolute;
left: 0;
top: 0;
height: 20px;
width: 20px;
border-radius: 50%;
background: #fff;
box-shadow: inset 1px 1px 10px rgba(0, 0, 0, 0.15);
}
.toggle-button--maa .toggle-button__icon:before, .toggle-button--maa .toggle-button__icon:after {
border-radius: 50%;
}
.toggle-button--maa .toggle-button__icon:before {
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.8);
}
.toggle-button--maa .toggle-button__icon:after {
top: 4px;
left: 4px;
width: 60%;
height: 60%;
background: #61B136;
animation: zoomOut .2s ease-out;
transform: scale(0);
transition: none;
}
/*.toggle-button--maa:hover input:not(:checked) ~ .toggle-button__icon:after {
background:#CACACA;
transform: scale(1);
animation: zoomIn .2s;
}*/
/*.toggle-button--maa:hover input:not(:checked) ~ .toggle-button__icon {
animation: hover .2s;
}*/
.toggle-button--maa:hover input:not(:checked) ~ label:before {
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}
#keyframes zoomOut {
0% {
transform: scale(1);
}
30% {
transform: scale(1.2);
}
100% {
transform: scale(0);
}
}
#keyframes zoomIn {
0% {
transform: scale(0);
}
90% {
transform: scale(1.2);
}
100% {
transform: scale(1);
}
}
#keyframes hover {
0% {
transform: scale(1);
}
30% {
transform: scale(1.1);
}
100% {
transform: scale(1);
}
}
#keyframes wave {
0% {
opacity: 1;
transform: scale(1);
}
40% {
opacity: 0.2;
}
100% {
opacity: 0;
transform: scale(1.5);
}
}
#keyframes zoomFadeOut {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
#keyframes zoomFadeIn {
0% {
opacity: 0;
transform: scale(3);
}
90% {
opacity: 1;
transform: scale(1);
}
100% {
transform: scale(1);
}
}
#keyframes hover {
0% {
transform: scale(1);
}
30% {
transform: scale(1.1);
}
100% {
transform: scale(1);
}
<div id="ButtonsDiv" class="auto-style4" >
<div class="toggle-button toggle-button--maa">
<input id="toggleButton7" name="radio3" type="radio"/>
<label for="toggleButton7" data-text="Bachelor accounting student" ></label>
<div class="toggle-button__icon"></div>
</div>
<div class="toggle-button toggle-button--maa">
<input id="toggleButton8" name="radio3" type="radio"/>
<label for="toggleButton8" data-text="Bachelor finance student" class="auto-style5"></label>
<div class="toggle-button__icon"></div>
</div>
</div>
I've been using Foundaiton Orbit image slider and found it great. Now I am having trouble with the height.
I have some images in the gallery that are considerably 'taller' than others and therefore the container that contains the gallery is set to the height of the 'tallest' image. Is there anyway of changing it so the container adapts it's height according to the height of the current image that it is showing?
Click here for live example of site
here is the code:
<div class="slideshow-wrapper preloader">
<ul data-orbit data-options="animation:fade;
pause_on_hover:false;
animation_speed:500;
timer_speed: 4000;
navigation_arrows:true;
slide_number: false;
swipe: true;
bullets:false;">
<li>
<img src="img/jpg/weapon-wall.jpg" alt="Armoury Tromp l'oeil">
</li>
<li>
<img src="img/jpg/vikings.jpg" alt="Vikings attacking from the sea mural">
</li>
<li>
<img src="img/jpg/chariot.jpg" alt="Ancient chariot Trompe l'oeil">
</li>
<li>
<img src="img/jpg/egypt.jpg" alt="Karen specialises in Trompe l'oeil, Egypt">
</li>
<li>
<img src="img/jpg/army.jpg" alt="army Trompe l'oeil">
</li>
</ul>
css:
.data-orbit img {
max-width: 70%;
min-height:auto;
}
/* Orbit Graceful Loading */
.orbit-container ul li { min-height: auto; overflow: hidden; }
.orbit-container ul li img { width: 100%; }
.slideshow-wrapper {
margin-top: 40px;
margin-bottom: 40px;
position: relative; }
.slideshow-wrapper ul {
list-style-type: none;
margin: 0; }
.slideshow-wrapper ul li,
.slideshow-wrapper ul li .orbit-caption {
display: none; }
.slideshow-wrapper ul li:first-child {
display: block; }
.slideshow-wrapper .orbit-container {
background-color: transparent; }
.slideshow-wrapper .orbit-container li {
display: block; }
.slideshow-wrapper .orbit-container li .orbit-caption {
display: block;}
.slideshow-wrapper .orbit-container li .orbit-caption p {
color: white;
margin-left: 45px;
font-size: 14px;
font-family: "Open Sans"; }
.slideshow-wrapper .preloader {
display: block;
width: 40px;
height: 40px;
position: absolute;
top: 50%;
left: 50%;
margin-top: -20px;
margin-left: -20px;
border: solid 3px;
border-color: #555555 white;
border-radius: 1000px;
animation-name: rotate;
animation-duration: 1.5s;
animation-iteration-count: infinite;
animation-timing-function: linear; }
.orbit-container {
height: auto;
overflow: hidden;
width: 100%;
position: relative;
background: none; }
.orbit-container .orbit-slides-container {
list-style: none;
margin: 0;
padding: 0;
position: relative;
-webkit-transform: translateZ(0); }
.orbit-container .orbit-slides-container img {
display: block;
max-width: 60%; }
.orbit-container .orbit-slides-container.fade li {
opacity: 0;
transition: opacity 500ms ease-in-out;
-ms-transform: translate(0, 0);
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-o-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0); }
.orbit-container .orbit-slides-container.fade li.animate-in {
opacity: 1;
z-index: 20;
transition: opacity 500ms ease-in-out; }
.orbit-container .orbit-slides-container.fade li.animate-out {
z-index: 10;
transition: opacity 500ms ease-in-out; }
.orbit-container .orbit-slides-container.swipe-next li {
-ms-transform: translate(100%, 0);
-webkit-transform: translate3d(100%, 0, 0);
-moz-transform: translate3d(100%, 0, 0);
-o-transform: translate3d(100%, 0, 0);
transform: translate3d(100%, 0, 0); }
.orbit-container .orbit-slides-container.swipe-next li.animate-in {
-ms-transform: translate(0, 0);
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-o-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
transition-duration: 500ms; }
.orbit-container .orbit-slides-container.swipe-next li.animate-out {
-ms-transform: translate(-100%, 0);
-webkit-transform: translate3d(-100%, 0, 0);
-moz-transform: translate3d(-100%, 0, 0);
-o-transform: translate3d(-100%, 0, 0);
transform: translate3d(-100%, 0, 0);
transition-duration: 500ms; }
.orbit-container .orbit-slides-container.swipe-prev li {
-ms-transform: translate(-100%, 0);
-webkit-transform: translate3d(-100%, 0, 0);
-moz-transform: translate3d(-100%, 0, 0);
-o-transform: translate3d(-100%, 0, 0);
transform: translate3d(-100%, 0, 0); }
.orbit-container .orbit-slides-container.swipe-prev li.animate-in {
-ms-transform: translate(0, 0);
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-o-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
transition-duration: 500ms; }
.orbit-container .orbit-slides-container.swipe-prev li.animate-out {
-ms-transform: translate(100%, 0);
-webkit-transform: translate3d(100%, 0, 0);
-moz-transform: translate3d(100%, 0, 0);
-o-transform: translate3d(100%, 0, 0);
transform: translate3d(100%, 0, 0);
transition-duration: 500ms; }
.orbit-container .orbit-slides-container li {
position: absolute;
top: 0;
left: 0;
width: 100%;
-ms-transform: translate(100%, 0);
-webkit-transform: translate3d(100%, 0, 0);
-moz-transform: translate3d(100%, 0, 0);
-o-transform: translate3d(100%, 0, 0);
transform: translate3d(100%, 0, 0); }
.orbit-container .orbit-slides-container li.active {
opacity: 1;
top: 0;
left: 0;
-ms-transform: translate(0, 0);
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-o-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0); }
.orbit-container .orbit-slides-container li .orbit-caption {
position: absolute;
bottom: 0;
background-color: rgba(51, 51, 51, 0.8);
color: white;
width: 100%;
padding: 0.625rem 0.875rem;
font-size: 0.875rem; }
.orbit-container .orbit-slide-number {
position: absolute;
top: 10px;
left: 10px;
font-size: 12px;
color: white;
background: rgba(0, 0, 0, 0);
z-index: 10; }
.orbit-container .orbit-slide-number span {
font-weight: 700;
padding: 0.3125rem; }
.orbit-container .orbit-timer {
position: absolute;
top: 12px;
right: 10px;
height: 6px;
width: 100px;
z-index: 10; }
.orbit-container .orbit-timer .orbit-progress {
height: 3px;
background-color: rgba(112, 180, 191, 1);
display: block;
width: 0%;
position: relative;
right: 20px;
top: 5px; }
.orbit-container .orbit-timer > span {
display: none;
position: absolute;
top: 0px;
right: 0;
width: 11px;
height: 14px;
border: solid 4px #70B4BF;
border-top: none;
border-bottom: none; }
.orbit-container .orbit-timer.paused > span {
right: -4px;
top: 0px;
width: 11px;
height: 14px;
border: inset 8px;
border-left-style: solid;
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-ms-transform: rotate(180deg);
-o-transform: rotate(180deg);
transform: rotate(180deg);
border-color: transparent #70B4BF transparent transparent; }
.orbit-container .orbit-timer.paused > span.dark {
border-color: transparent #333333 transparent transparent; }
.orbit-container:hover .orbit-timer > span {
display: block; }
.orbit-container .orbit-prev,
.orbit-container .orbit-next {
position: absolute;
top: 45%;
margin-top: -25px;
width: 36px;
height: 60px;
line-height: 50px;
color: white;
background-color: transparent;
text-indent: -9999px !important;
z-index: 10; }
.orbit-container .orbit-prev:hover,
.orbit-container .orbit-next:hover {
background-color: rgba(0, 0, 0, 0.3); }
.orbit-container .orbit-prev > span,
.orbit-container .orbit-next > span {
position: absolute;
top: 50%;
margin-top: -10px;
display: block;
width: 0;
height: 0;
border: inset 10px; }
.orbit-container .orbit-prev {
left: 0; }
.orbit-container .orbit-prev > span {
border-right-style: solid;
border-color: transparent;
border-right-color: #7FA7B2; }
.orbit-container .orbit-prev:hover > span {
border-right-color: white; }
.orbit-container .orbit-next {
right: 0; }
.orbit-container .orbit-next > span {
border-color: transparent;
border-left-style: solid;
border-left-color: #7FA7B2;
left: 50%;
margin-left: -4px; }
.orbit-container .orbit-next:hover > span {
border-left-color: white; }
.orbit-container .orbit-bullets-container {
text-align: center; }
.orbit-container .orbit-bullets {
margin: 0 auto 30px auto;
overflow: hidden;
margin-left: -70px;
position: relative;
top: ;
float: none;
text-align: center;
display: block; }
.orbit-container .orbit-bullets li {
display: inline-block;
width: 0.5625rem;
height: 0.5625rem;
background: #cccccc;
float: none;
margin-right: 6px;
border-radius: 1000px; }
.orbit-container .orbit-bullets li.active {
background: #CE3F3A; }
.orbit-container .orbit-bullets li:last-child {
margin-right: 0; }
.touch .orbit-container .orbit-prev,
.touch .orbit-container .orbit-next {
display: none; }
.touch .orbit-bullets {
display: none; }
#media only screen and (min-width: 40.063em) {
.touch .orbit-container .orbit-prev,
.touch .orbit-container .orbit-next {
display: inherit; }
.touch .orbit-bullets {
display: block; } }
#media only screen and (max-width: 40em) {
.orbit-stack-on-small .orbit-slides-container {
height: auto !important; }
.orbit-stack-on-small .orbit-slides-container > * {
position: relative;
margin-left: 0% !important;
opacity: 1 !important;
-webkit-transform: none !important;
-moz-transform: none !important;
-ms-transform: none !important;
-o-transform: none !important;
transform: none !important;
transition: none !important; }
.orbit-stack-on-small .orbit-timer {
display: none; }
.orbit-stack-on-small .orbit-next, .orbit-stack-on-small .orbit-prev {
display: none; }
.orbit-stack-on-small .orbit-bullets {
display: none; } }
[data-magellan-expedition], [data-magellan-expedition-clone] {
background: white;
z-index: 50;
min-width: 100%;
padding: 10px; }
[data-magellan-expedition] .sub-nav, [data-magellan-expedition-clone] .sub-nav {
margin-bottom: 0; }
[data-magellan-expedition] .sub-nav dd, [data-magellan-expedition-clone] .sub-nav dd {
margin-bottom: 0; }
[data-magellan-expedition] .sub-nav a, [data-magellan-expedition-clone] .sub-nav a {
line-height: 1.8em; }
}
thanks!
in your case I think it would be enough to add this bit of code to your css file:
.orbit-slides-container{
height: auto !important;
}
.orbit-container .orbit-slides-container li.active{
position:static;
}
I hope it helps
I've found a solution to fix the auto-height issue with the Orbit Slider.
.orbit-slides-container{
height: 100% !important;
}
.orbit-container .orbit-slides-container li.active{
position:relative;
}
I hope it helps