对象已移动

可在此处找到该文档 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

Further Tab Button work and Chromium 140 – Vivaldi Browser snapshot 3787.3
Softwares

Further Tab Button work and Chromium 140 – Vivaldi Browser snapshot 3787.3

by admin
August 23, 2025
Xero Salesforce Integration – The Definitive Guide
Softwares

Xero Salesforce Integration – The Definitive Guide

by admin
August 20, 2025
BrowserStack launches Chrome extension that bundles 10+ manual web testing tools
Softwares

BrowserStack launches Chrome extension that bundles 10+ manual web testing tools

by admin
August 18, 2025
20+ Best Titles Templates for DaVinci Resolve in 2025 — Speckyboy
Softwares

20+ Best Titles Templates for DaVinci Resolve in 2025 — Speckyboy

by admin
August 22, 2025
Apple launches iOS 26 beta 3, faces Fortnite developer win in court
Softwares

Apple launches iOS 26 beta 3, faces Fortnite developer win in court

by admin
August 17, 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
I Only Have More Questions After Another Bizarre Outing With The Harrigans

I Only Have More Questions After Another Bizarre Outing With The Harrigans

April 20, 2025
10 Best Netflix Original Thriller Shows, Ranked

10 Best Netflix Original Thriller Shows, Ranked

June 22, 2025
‘Rust’ armorer’s involuntary manslaughter conviction upheld in fatal shooting – National

‘Rust’ armorer’s involuntary manslaughter conviction upheld in fatal shooting – National

October 1, 2024
Lil Nas X hospitalized in Los Angeles for ‘possible overdose,’ say reports – National

Lil Nas X hospitalized in Los Angeles for ‘possible overdose,’ say reports – National

August 22, 2025
Harvey Weinstein case judge declares mistrial on remaining rape charge – National

Harvey Weinstein case judge declares mistrial on remaining rape charge – National

June 13, 2025
BrowserStack launches Chrome extension that bundles 10+ manual web testing tools

BrowserStack launches Chrome extension that bundles 10+ manual web testing tools

August 18, 2025
Kid Cudi says he ‘hated every minute’ of testifying in Diddy trial – National

Kid Cudi says he ‘hated every minute’ of testifying in Diddy trial – National

August 17, 2025
Best AI Webcams For Video Calls In 2025

Best AI Webcams For Video Calls In 2025

August 21, 2025
Visions’ Season 3 Puts a Stormtrooper on Death’s Door

Visions’ Season 3 Puts a Stormtrooper on Death’s Door

August 23, 2025
‘Wind Talk To Me’ Wins Best Feature At Sarajevo Film Festival

‘Wind Talk To Me’ Wins Best Feature At Sarajevo Film Festival

August 23, 2025
10 Most Iconic Animated Movie Characters Everyone Knows

10 Most Iconic Animated Movie Characters Everyone Knows

August 23, 2025
Offset Blames Cooking and More for Failed Marriage to Cardi B

Offset Blames Cooking and More for Failed Marriage to Cardi B

August 23, 2025
Bass Canyon 2025: Excision’s Festival Evolves With Stunning Crater Stage and Rising Stars

Bass Canyon 2025: Excision’s Festival Evolves With Stunning Crater Stage and Rising Stars

August 22, 2025
iPhone 17 release date, iOS 26 features and everything else to know about Apple’s upcoming lineup

iPhone 17 release date, iOS 26 features and everything else to know about Apple’s upcoming lineup

August 22, 2025
Lost’s Daniel Dae Kim On Ethnic-Specific Casting

Lost’s Daniel Dae Kim On Ethnic-Specific Casting

August 22, 2025
Further Tab Button work and Chromium 140 – Vivaldi Browser snapshot 3787.3

Further Tab Button work and Chromium 140 – Vivaldi Browser snapshot 3787.3

August 23, 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

  • Visions’ Season 3 Puts a Stormtrooper on Death’s Door
  • ‘Wind Talk To Me’ Wins Best Feature At Sarajevo Film Festival
  • 10 Most Iconic Animated Movie Characters Everyone Knows
  • 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