对象已移动

可在此处找到该文档 HTML-Only Accordion [Article] | Treehouse Blog – New Self New Life
New Self New Life
No Result
View All Result
  • Home
  • Entertainment
  • Celebrity
  • Cinema
  • Music
  • Digital Lifestyle
  • Social Media
  • Softwares
  • Devices
  • Home
  • Entertainment
  • Celebrity
  • Cinema
  • Music
  • Digital Lifestyle
  • Social Media
  • Softwares
  • Devices
New Self New Life
No Result
View All Result
Home Softwares

HTML-Only Accordion [Article] | Treehouse Blog

by admin
3 years ago
in Softwares
HTML-Only Accordion [Article] | Treehouse Blog
Share on FacebookShare on Twitter


Accordions are everywhere in the net and cellular apps. They’re an effective way to indicate and conceal content material based mostly on person interplay and aren’t very onerous to construct however normally require a little bit of HTML, CSS and JavaScript. Do you know you can construct a easy accordion in simply seconds with solely HTML? Comply with alongside as I clarify how you can set this up!

The HTML accordion requires solely two HTML tags to get arrange. <particulars> and <abstract>. The essential code construction would appear to be this:

<particulars>
   <abstract></abstract>
<particulars>

The particulars HTML tag

The <particulars> tag acts as a wrapper for our accordion. All the content material on your accordion should go inside the <particulars> tag.

The abstract HTML tag

The <abstract> tag is normally used on your title. Earlier than the accordion is clicked, that is the content material that’s seen and can all the time stay seen.

Including content material to an accordion

So as to add content material to the accordion when the person clicks it’s fairly easy. Any content material beneath the <abstract> tags can be hidden by default. This content material may very well be something from some paragraph tags, an ordered record, pictures, hyperlinks, you title it. As soon as the person clicks the accordion, this content material can be seen.

Right here is a few fundamental content material:

<particulars>
   <abstract>
      <h1>Todo record:</h1>
   </abstract>
   <p>Examine</p>
   <p>Grocery Store</p>
   <p>Clear The Home</p>
</particulars>

Earlier than the person clicks, that is what the accordion will appear to be:

As soon as the person clicks:

Fairly cool, with just some strains of markup, we constructed a functioning accordion! As you’ll be able to see it’s not the very best wanting accordion on the market. No worries although, we will type it fairly simply!

The right way to Model an HTML Accordion

Styling your accordion may be very a lot as much as you and the way you’d like for it to look, however be happy to comply with alongside as I give just some fundamental stylings to the one we created above.

particulars {
    width: 250px;
    padding: 1rem;
    border-radius: 8px;
    background: white;
    box-shadow: 4px 4px 3px rgba(0,0,0,0.15);
}

To the particulars CSS rule, ive added a set width, some padding, a border-radius, background shade, and a few box-shadow. Subsequent we will type up our <abstract> tag.

abstract {
    cursor: pointer;
}
abstract h1 {
    show: inline;
    margin-left: 1rem;
    font-size: 1.25rem;
}

Very first thing you’ll discover is I gave our abstract a cursor: pointer. That is simply so the accordion seems that it may be clicked to the person.

I then give some fundamental stylings to the h1 component in order that it may well stay on the identical line as our caret that comes with the accordion menu by default. Some margin and a bigger font-size has been added as nicely.

Lastly, we will type the paragraph tags we added by writing the next:

particulars p {
    margin-left: 1.75rem;
    opacity: 0.7;
}

And that’s about it. We now have a a lot cooler wanting accordion!

I hope you loved establishing an accordion with simply HTML with me. Be happy to tell us should you’d prefer to see how you can construct a good nicer accordion with HTML, CSS, and JavaScript subsequent!

Till subsequent time, have enjoyable and glad coding!



Source link

Tags: AccordionArticleBlogHTMLOnlyTreehouse
Previous Post

Microsoft Dev Box preview allows developers to create on-demand workstations

Next Post

What Do Travelers Desire Out of Their Vacation?

Related Posts

Minor update(4) for Vivaldi Android Browser 7.4
Softwares

Minor update(4) for Vivaldi Android Browser 7.4

by admin
June 21, 2025
10+ Best Free Portfolio & Lookbook Templates for InDesign in 2025 — Speckyboy
Softwares

10+ Best Free Portfolio & Lookbook Templates for InDesign in 2025 — Speckyboy

by admin
June 20, 2025
User Guide For CS-Cart Product Search By Barcode
Softwares

User Guide For CS-Cart Product Search By Barcode

by admin
June 18, 2025
Open Talent platforms emerging to match skilled workers to needs, study finds
Softwares

Open Talent platforms emerging to match skilled workers to needs, study finds

by admin
June 16, 2025
New tool could help homeowners weather flood risks, lower insurance costs
Softwares

New tool could help homeowners weather flood risks, lower insurance costs

by admin
June 19, 2025
Next Post
What Do Travelers Desire Out of Their Vacation?

What Do Travelers Desire Out of Their Vacation?

Grim Reaper Vocalist Steve Grimmett Has Died at 62

Grim Reaper Vocalist Steve Grimmett Has Died at 62

  • Trending
  • Comments
  • Latest
8BitDo Retro Mechanical Keyboard C64 Review

8BitDo Retro Mechanical Keyboard C64 Review

March 24, 2025
SOG and Leatherman EDC, Dyson Lightcycle Morph lamp, COTRE 2-way radios, and more – Weekly roundup

SOG and Leatherman EDC, Dyson Lightcycle Morph lamp, COTRE 2-way radios, and more – Weekly roundup

May 16, 2021
Guide for Bagisto Quick Commerce

Guide for Bagisto Quick Commerce

October 16, 2024
The Best Madras Shirt Brands For Men: Summer 2021 Edition

The Best Madras Shirt Brands For Men: Summer 2021 Edition

July 20, 2021
Product Lifecycle Management: A Detailed Guide

Product Lifecycle Management: A Detailed Guide

September 6, 2021
7 Actors Who Played Different Characters Within The Same Series

7 Actors Who Played Different Characters Within The Same Series

July 19, 2022
Guide for Pathology Lab Management Extension

Guide for Pathology Lab Management Extension

May 16, 2023
20 Free Tailwind CSS Web Templates for Designers & Developers

20 Free Tailwind CSS Web Templates for Designers & Developers

April 1, 2024
What We Know So Far About the Supposed ‘Mother of All Data Breaches’

What We Know So Far About the Supposed ‘Mother of All Data Breaches’

June 21, 2025
Go Through Justin Timberlake and Jessica Biel’s Sweet Family Photos

Go Through Justin Timberlake and Jessica Biel’s Sweet Family Photos

June 21, 2025
Secret royal swimming pools – including Princess Kate and Prince William’s heatwave haven

Secret royal swimming pools – including Princess Kate and Prince William’s heatwave haven

June 21, 2025
Who Is Yvie Oddly’s Husband? Doug Illsley’s Relationship History

Who Is Yvie Oddly’s Husband? Doug Illsley’s Relationship History

June 21, 2025
Social Platforms Explore Age Verification Options to Comply With Teen Access Regulations

Social Platforms Explore Age Verification Options to Comply With Teen Access Regulations

June 21, 2025
From Rave To Rock, L’Eclair Conjure Magic On ‘Cloud Drifter’

From Rave To Rock, L’Eclair Conjure Magic On ‘Cloud Drifter’

June 21, 2025
Minor update(4) for Vivaldi Android Browser 7.4

Minor update(4) for Vivaldi Android Browser 7.4

June 21, 2025
Jim Jones Rejects Notion That His Career Is Comparable to Nas’

Jim Jones Rejects Notion That His Career Is Comparable to Nas’

June 20, 2025
New Self New Life

Your source for entertainment news, celebrities, celebrity news, and Music, Cinema, Digital Lifestyle and Social Media and More !

Categories

  • Celebrity
  • Cinema
  • Devices
  • Digital Lifestyle
  • Entertainment
  • Music
  • Social Media
  • Softwares
  • Uncategorized

Recent Posts

  • What We Know So Far About the Supposed ‘Mother of All Data Breaches’
  • Go Through Justin Timberlake and Jessica Biel’s Sweet Family Photos
  • Secret royal swimming pools – including Princess Kate and Prince William’s heatwave haven
  • Home
  • Disclaimer
  • DMCA
  • Privacy Policy
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact us

Copyright © 2021 New Self New Life.
New Self New Life is not responsible for the content of external sites. slotsfree  creator solana token

No Result
View All Result
  • Home
  • Entertainment
  • Celebrity
  • Cinema
  • Music
  • Digital Lifestyle
  • Social Media
  • Softwares
  • Devices

Copyright © 2021 New Self New Life.
New Self New Life is not responsible for the content of external sites.

New Self New Life