Pen Settings

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              .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
            
          
!
            
              *
	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
            
          
!
            
              // 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
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console