Tooltip/Accordion

Size
3,467 Kb
Views
26,312

How do I make an tooltip/accordion?

What is a tooltip/accordion? How do you make a tooltip/accordion? This script and codes were developed by Alex Rodrigues on 13 August 2022, Saturday.

Tooltip/Accordion Previews

Tooltip/Accordion - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Tooltip/Accordion</title> <script src="http://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script>
<meta name="viewport" content="width=device-width"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="wrap"> <p class="heading">Easy tooltip that changes to an accordion on touch devices</p> <ul class="info"> <li class="info-item">I'm a list Item 1 <div class="tooltip"> <p></p> </div> </li> <li class="info-item">I'm a list Item 2 <div class="tooltip"> <p></p> </div> </li> <li class="info-item">I'm a list Item 3 <div class="tooltip"> <p></p> </div> </li> <li class="info-item">I'm a list Item 4 <div class="tooltip"> <p></p> </div> </li> </ul>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Tooltip/Accordion - Script Codes CSS Codes

@import url(http://fonts.googleapis.com/css?family=Droid+Serif:400,400italic|Montserrat:400,700);
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video { margin: 0; padding: 0; border: 0; font: inherit; font-size: 100%; vertical-align: baseline;
}
html { line-height: 1;
}
ol, ul { list-style: none;
}
table { border-collapse: collapse; border-spacing: 0;
}
caption, th, td { text-align: left; font-weight: normal; vertical-align: middle;
}
q, blockquote { quotes: none;
}
q:before, q:after, blockquote:before, blockquote:after { content: ""; content: none;
}
a img { border: none;
}
article, aside, details, figcaption, figure, footer, header, hgroup, main, menu, nav, section, summary { display: block;
}
* { box-sizing: border-box;
}
/* VARIABLES & MIXINS */
body { font-family: "Droid Serif", serif; line-height: 1.5;
}
.wrap { width: 100%; margin: 5% auto; text-align: right; max-width: 400px;
}
.heading { padding: 1em; text-align: center; font-size: 1.25em;
}
.info-item { padding: 1em; position: relative;
}
.info-item:before { content: "?"; float: right; margin-left: .5em; border: 1px solid; font-size: 85%; border-radius: 1em; padding: 0 0.25em; font-weight: bold;
}
.tooltip { background: #fff; border: 2px solid blue; padding: 1em; top: 0; right: 2em; display: none;
}
.active-tooltip .tooltip { position: absolute; display: block; top: 0; right: 2em;
}
.active-accordion .tooltip { display: block;
}
.tooltip p:before { font-family: "Montserrat", sans-serif; content: "I'm A tooltip"; display: block;
}
@media screen and (max-width: 600px) { .tooltip p:before { content: "I'm An Accordion"; }
}

Tooltip/Accordion - Script Codes JS Codes

if(!Modernizr.touch) {	$('.info-item').hover(function() { $(this).toggleClass('active-tooltip'); });
}
else{ $('.info-item').click(function() { $(this).toggleClass('active-accordion'); });
}
Tooltip/Accordion - Script Codes
Tooltip/Accordion - Script Codes
Home Page Home
Developer Alex Rodrigues
Username alex_rodrigues
Uploaded August 13, 2022
Rating 3
Size 3,467 Kb
Views 26,312
Do you need developer help for Tooltip/Accordion?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Alex Rodrigues (alex_rodrigues) Script Codes
Create amazing video scripts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!