Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                .box
	input(type="radio", name="fab", value="1", checked="checked")
	span 1
	br
	input(type="radio", name="fab", value="2")
	span 2
	br
	input(type="radio", name="fab", value="3")
	span 3
	br
	input(type="radio", name="fab", value="4")
	span 4
	br
	input(type="radio", name="fab", value="5")
	span 5


.fab
	a.fab-btn.js-btn-trigger(href="javascript:void(0)")
	ul.fab-child.js-btn-wrap
		//- li.fab-child-item.js-btn-item
		//- 	a.fab-child-btn(href="#")
		//- 		span aa
		//- li.fab-child-item.js-btn-item
		//- 	a.fab-child-btn(href="#")
		//- 		span bb
		//- li.fab-child-item.js-btn-item
		//- 	a.fab-child-btn(href="#")
		//- 		span cc
		//- li.fab-child-item.js-btn-item
		//- 	a.fab-child-btn(href="#")
		//- 		span dd
		//- li.fab-child-item.js-btn-item
		//- 	a.fab-child-btn(href="#")
		//- 		span ee

              
            
!

CSS

              
                * {
	box-sizing: border-box;
}

body {
	margin: 0;
}

.fab {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 100;
	&-btn {
		display: flex;
		justify-content: center;
		align-items: center;
		overflow: hidden;
		position: relative;
		width: 60px;
		height: 60px;
		z-index: 10;
		border-radius: 50%;
		background: #fa3;
		color: #fff;
		font-size: 20px;
		text-decoration: none;
		transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
		&:before {
			content: '+';
			display: block;
		}
		&:hover {
			background: #c93;
		}
	}
	
	&-child {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		z-index: 5;
		margin: 0;
		padding: 0;
		list-style: none;
		
		&-item {
			position: absolute;
			top: 50%;
			left: 50%;
			margin: -18px 0 0 -18px;
		}
		
		&-btn {
			display: flex;
			justify-content: center;
			align-items: center;
			width: 36px;
			height: 36px;
			border-radius: 50%;
			background: #33f;
			color: #fff;
			font-size: 14px;
			text-decoration: none;
			transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
		}
	}
	
	&.is-active {
		.fab-btn {
			&:before {
				content: '-';
			}
		}
		.fab-child-btn {
			transform: translateY(-100px);
			transition: all 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
		}
	}
}

              
            
!

JS

              
                /* global Device */
(function (window, $) {
	'use strict';

	// Set Namespace
	var APP = window.APP = window.APP || {};
	
	// Fab設定
	APP.SetFab = function($elm) {
		var that = this;
		that.$elm = $elm;
		that.rad = 90;
		that.deg = 0;
		that.delay = 0.1;
		that.defNum = 1;
		that.ACTIVE = 'is-active';
		
		that.init(that.defNum);
    console.log('例えば、2÷0 を計算させると、答えは・・・'+(2/0));
	};
	APP.SetFab.prototype = {
		init: function(num) {
			var that = this;
			var d = new $.Deferred();
			
			$('.js-btn-trigger').off();
			that.$elm.removeClass(that.ACTIVE);

			d.promise()
				.then(function () {
					setTimeout(function () {
						that.setItem(num);
					}, 0);
				})
				.then(function () {
					setTimeout(function () {
						that.calc();
					}, 0);
				})
				.then(function () {
					setTimeout(function () {
						that.setDeg();
					}, 0);
			});
			d.resolve();

		},
		setItem: function(num) {
			var that = this;
			var $btnWrap = $('.js-btn-wrap');

			$btnWrap.empty();
			for (var i = 0; i < num; i++) {
				$('<li class="fab-child-item js-btn-item"><a href="#" class="fab-child-btn"><span>'+ (i+1) +'</span></a>').appendTo($btnWrap);
			}
		},
		calc: function() {
			var that = this;
			
			that.numItem = $('.js-btn-item').length;
			
			if (that.numItem === 1) {
				that.deg = 0;
			} else {
				that.deg = Math.floor(that.rad / (that.numItem - 1));
			}
      console.log('1つ当たりの角度は'+that.deg+'度');
		},
		setDeg: function() {
			var that = this;

			$('.js-btn-trigger').on('click', function() {
				that.$elm.toggleClass(that.ACTIVE);
			});

			$('.js-btn-item').find('a').each(function(index) {
				$(this).parent().css({
					transform: 'rotateZ(' + index * that.deg * -1 + 'deg)',
				});
				$(this).find('span').css({
					transform: 'rotateZ(' + index * that.deg + 'deg)'			
				});
			});
		},
	};
	
	$(function () {
		var setFab = new APP.SetFab($('.fab'));

		
		$('.box input').on('change', function() {
			setFab.init(parseInt($(this).val()));
		});
	});
})(window, jQuery);

              
            
!
999px

Console