Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                .wrapper
	.poll-box
		.poll-container
			.poll-question Will Poland win the footboal match?
			.poll-panel.row.mt-30
				.btn.poll-panel-btn(aria-role='button' data-result=0 data-vote=0) 
					span Yes
				.btn.poll-panel-btn(aria-role='button' data-result=0 data-vote=1) 
					span No
              
            
!

CSS

              
                *
	box-sizing: border-box

$font-headline: 'Poppins', sans-serif
$font-context: 'Roboto', sans-serif

body
	background: #1b1b1b
	margin: 0

.wrapper
	position: absolute
	top: 50%
	left: 50%
	transform: translate(-50%, -50%)

.mt-30
	margin: 30px 0 0 0
.row, .column
	display: flex
.row
	flex-direction: row
.column
	flex-direction: column
.btn:not([disabled])
	cursor: pointer

.poll
	&-box
		background: linear-gradient(#803af7, #500cc4)
		border-radius: 3px
		box-shadow: 0px 5px 11px -7px #000
		text-align: center
	&-container
		padding: 25px 30px
		position: relative
	&-question
		width: max-content 
		max-width: 700px
		color: #FFF
		font-family: $font-headline
	&-panel.poll-voted
		overflow: hidden
		border-radius: 50px
		.poll-panel-btn
			&.--user-choice
				background: #FFF
				color: #000
				&:hover
					color: #000
					background: #FFF
			&
				background: #676464
				color: #FFF
				border-radius: 0
				margin: 0
				border: 0
				position: relative
				&:hover
					color: #FFF
					background: #676464
				&:after
					content: attr(data-result)
					font-size: 9px
					display: block
					opacity: 0.5
					animation: slideWithFade .2s ease
				&:active
					transform: inherit
				span
					display: block
		
	&-panel
		width: 100%
		&-btn
			padding: 7px 10px
			font-family: $font-context
			font-size: .7rem
			width: 100%
			border-radius: 50px
			border: 1px solid #FFF
			margin: 0 20px
			color: #FFF
			transition: .15s cubic-bezier(.17,.67,.79,1.24)
			&:hover
				background: #FFF
				color: #000
			&:active
				transform: scale(.95)
		
@keyframes slideWithFade
	0%
		opacity: 0
		transform: translateY(10px)
	100%
		opacity: 1
              
            
!

JS

              
                // Plugin: https://codepen.io/badurski/pen/RJvJQZ

const q1 = new poll("Will Poland win the footboal match?", {
	0: { title: "Yes" },
	1: { title: "No" }
});

// Add some randome votes
for(let i = 0; i<20; i++) {
	q1.vote(Math.floor(Math.random() * (1 - 0 + 1)) + 0);
}

// Poll interface script
let pollButtons = document.querySelectorAll('.poll-panel-btn'),
		pollPanel = document.querySelector('.poll-panel');
pollButtons.forEach(button => {
	button.onclick = () => {
		if (button.getAttribute('disabled') != 'disabled') {
			q1.vote(button.dataset.vote);
			pollPanel.classList.add('poll-voted');
			button.classList.add('--user-choice');
			pollButtons.forEach(b => {
				b.setAttribute('disabled', 'disabled');
				let percent = q1.results[b.dataset.vote].percent + '%';
				b.style.width = percent;
				b.dataset.result = percent;
			});
		}
	};
});
              
            
!
999px

Console