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. 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

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

              
                <main class="container">
	<figure>
		<img src="https://firebasestorage.googleapis.com/v0/b/fire-fotos-8e3f9.appspot.com/o/img%2Fmap.png?alt=media&token=82f7ebdc-7dad-43fb-ae79-da6d3a5285a4" class="map" alt="Map" title="Map">
		
		<figcaption>
			<i id="icon-map" class="fa fa-map-marker icon-map"></i>
			
			<div id="tooltip" class="tooltip">
				<div class="thumb">
					<img src="https://firebasestorage.googleapis.com/v0/b/fire-fotos-8e3f9.appspot.com/o/img%2Feiffel.png?alt=media&token=b7f8fce3-5199-431a-9740-efd27619e612" alt="Eiffel" title="Eiffel">
				</div>
				
				<div class="info-tooltip">
					<h3 class="title-tooltip">
						Torre Eiffel
					</h3>
					
					<p class="address-tooltip">
						Champ de Mars, 5 Avenue Anatole France, 75007 Paris, Francia
					<p>
					
					<p class="content-tooltip">
						La Torre Eiffel es el monumento más famoso de Paris y símbolo de la capital francesa.
					</p>
					
					<div class="ctn-btn-tooltip">
						<button type="button" class="btn-tooltip">
							Comprar Boletos	
						</button>
					</div>
				</div>
			</div>
		</figcaption>
	</figure>
</main>
              
            
!

CSS

              
                * {
	box-sizing: border-box;
  margin: 0;
  padding: 0;
}

*:focus {
  outline: 0;
}

html {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

body {
	background-color: #efefef;
	font: normal 1rem 'Open Sans', sans-serif;
}

.container {
	align-items: center;
	display: flex;
	justify-content: center;
	margin: auto;
	max-width: 1000px;
	min-height: 100vh;
	width: 90%;
}

figure {
	position: relative;
	width: 100%;
}

figure .map {
	border-radius: 10px;
	box-shadow: 5px 5px 50px rgba(0, 0, 0, 0.2);
	vertical-align: top;
	width: 100%;
}

figure figcaption .icon-map {
	color: #ea4635;
	cursor: pointer;
	font-size: 40px;
	left: 55.3%;
	position: absolute;
	top: 32%;
}

figure figcaption .tooltip:before {
	border-left: 15px solid rgba(0, 0, 0, 0);
	border-right: 15px solid rgba(0, 0, 0, 0);
	border-top: 15px solid #ffffff;
	content: '';
	display: inline-block;
	left: calc(50% - 15px);
	position: absolute;
	top: 100%;
}

figure figcaption .tooltip {
	background-color: #ffffff;
	border-radius: 10px;
	box-shadow: 5px 5px 50px rgba(0, 0, 0, 0.2);
	display: flex;
	left: 0;
	opacity: 0;
	position: absolute;
	top: 0;
	transform: translate3d(0, 10px, 0);
	transition: opacity 0.3s ease,
							transform 0.3s ease;
	width: 31.25rem;
	z-index: 1;
}

figure figcaption .tooltip.active-tooltip {
	opacity: 1;
	transform: translate3d(0, 0, 0);
}

figure figcaption .tooltip .thumb {
	width: 40%;
}

figure figcaption .tooltip .thumb img {
	border-radius: 10px 0 0 10px;
	height: 100%;
	object-fit: cover;
	vertical-align: top;
	width: 100%;
}

figure figcaption .tooltip .info-tooltip {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	padding: 20px;
	width: 60%;
}

figure figcaption .tooltip .info-tooltip .title-tooltip {
	color: #3c48e5;
	font-weight: 600;
	margin-bottom: 10px;
}

figure figcaption .tooltip .info-tooltip .address-tooltip {
	color: #707070;
	font-size: 12px;
	margin-bottom: 20px;
}

figure figcaption .tooltip .info-tooltip .content-tooltip {
	margin-bottom: 20px;
}

figure figcaption .tooltip .info-tooltip .ctn-btn-tooltip {
	display: flex;
	justify-content: center;
}

figure figcaption .tooltip .info-tooltip .ctn-btn-tooltip .btn-tooltip {
	background-color: #75ac35;
	border-radius: 100px;
	border-style: none;
	color: #ffffff;
	cursor: pointer;
	font: 600 'Open Sans', sans-serif;
	padding: 10px 20px;
	transition: background-color 0.3s ease;
	width: 80%;
}

figure figcaption .tooltip .info-tooltip .ctn-btn-tooltip .btn-tooltip:hover,
figure figcaption .tooltip .info-tooltip .ctn-btn-tooltip .btn-tooltip:focus,
figure figcaption .tooltip .info-tooltip .ctn-btn-tooltip .btn-tooltip:active {
	background-color: rgba(117, 172, 53, 0.9);
}

/* Mediaqueries */
@media screen and (max-width: 768px) {
	figcaption .tooltip {
		font-size: 12px;
	}
	
	figure figcaption .tooltip .info-tooltip .ctn-btn-tooltip .btn-tooltip {
		width: 100%;
	}
	
}

@media screen and (max-width: 550px) {
	figure .map {
		margin-bottom: 40px;
	}
	
	figure figcaption .icon-tooltip {
		top: 0;
	}
	
	figure figcaption .tooltip:before {
		display: none;
	} 
	
	figure figcaption .tooltip {
		opacity: 1;
		position: static;
		transform: translate3d(0);
		width: 100%;
	}
	
}
              
            
!

JS

              
                const iconMap = document.getElementById('icon-map');
const tooltip = document.getElementById('tooltip');

const calculatePosTooltip = () => {
	// Calculamos las coordenadas del icono
	const iconMapX = iconMap.offsetLeft;
	const iconMapY = iconMap.offsetTop;
	
	// Calculamos el tamaño del tooltip
	const widthTooltip = tooltip.clientWidth;
	const heightTooltip = tooltip.clientHeight;

	// Calculamos donde posicionamos el tooltip
	const positionX = iconMapX - (widthTooltip / 2) + 15;
	const positionY = iconMapY - heightTooltip - 20;

	tooltip.style.left = `${positionX}px`;
	tooltip.style.top = `${positionY}px`;
};

window.addEventListener('load', () => calculatePosTooltip() );
window.addEventListener('resize', () => calculatePosTooltip() );

iconMap.addEventListener('mouseenter', () => {
	tooltip.classList.add('active-tooltip');
	calculatePosTooltip();
});

let timer;
iconMap.addEventListener('mouseleave', () => {
	timer = setTimeout( () => {
		tooltip.classList.remove('active-tooltip');
	}, 500);
});

tooltip.addEventListener('mouseenter', () => clearTimeout(timer) );

tooltip.addEventListener('mouseleave', () => tooltip.classList.remove('active-tooltip') );
              
            
!
999px

Console