对象已移动

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

Laravel ONDC Connector – Webkul Blog
Softwares

Laravel ONDC Connector – Webkul Blog

by admin
August 2, 2025
The hidden crisis behind AI’s promise: Why data quality became an afterthought
Softwares

The hidden crisis behind AI’s promise: Why data quality became an afterthought

by admin
July 31, 2025
Lazarus Group hackers increase open-source weaponisation
Softwares

Lazarus Group hackers increase open-source weaponisation

by admin
July 30, 2025
The Worst Career Advice Right Now: “Don’t Learn to Code” [Article]
Softwares

The Worst Career Advice Right Now: “Don’t Learn to Code” [Article]

by admin
August 1, 2025
Best AI Agents Development Companies in 2025
Softwares

Best AI Agents Development Companies in 2025

by admin
July 28, 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
Critics And Fans Disagree On Netflix’s Controversial Fantasy Show With Near-Perfect RT Score

Critics And Fans Disagree On Netflix’s Controversial Fantasy Show With Near-Perfect RT Score

July 5, 2025
Instagram Adds New Teleprompter Tool To Edits

Instagram Adds New Teleprompter Tool To Edits

June 11, 2025
How well did you know Ozzy? Take this quiz – National

How well did you know Ozzy? Take this quiz – National

July 28, 2025
I Tried Calocurb For 90 Days. Here’s My Review.

I Tried Calocurb For 90 Days. Here’s My Review.

January 8, 2025
The hidden crisis behind AI’s promise: Why data quality became an afterthought

The hidden crisis behind AI’s promise: Why data quality became an afterthought

July 31, 2025
Abbotsford, B.C., denies permit for MAGA singer

Abbotsford, B.C., denies permit for MAGA singer

August 2, 2025
How a Soundtrack Reunited Fleetwood Mac for ‘Tango in the Night’

How a Soundtrack Reunited Fleetwood Mac for ‘Tango in the Night’

July 28, 2025
Family, Friends & Fans Gather for Ozzy Osbourne’s Cortege Travels

Family, Friends & Fans Gather for Ozzy Osbourne’s Cortege Travels

July 30, 2025
Chris Meloni Teases Law & Order: SVU Appearance: ‘Hangin With Friends’

Chris Meloni Teases Law & Order: SVU Appearance: ‘Hangin With Friends’

August 3, 2025
Awesome JAWS Poster Art From Artist Tyler Stout Pays Tribute To Quint — GeekTyrant

Awesome JAWS Poster Art From Artist Tyler Stout Pays Tribute To Quint — GeekTyrant

August 3, 2025
Donald Trump Responds to Question About Pardoning Diddy

Donald Trump Responds to Question About Pardoning Diddy

August 2, 2025
A Timeline of the Sex and the City Feud Between Kim Cattrall and Sarah Jessica Parker

A Timeline of the Sex and the City Feud Between Kim Cattrall and Sarah Jessica Parker

August 3, 2025
‘M3GAN 2.0’ Will Not Slay in Japan

‘M3GAN 2.0’ Will Not Slay in Japan

August 2, 2025
Lindsay Lohan’s iconic red hair is making a 2000s-style comeback

Lindsay Lohan’s iconic red hair is making a 2000s-style comeback

August 2, 2025
First Steps’ Deleted Scenes and Cameos

First Steps’ Deleted Scenes and Cameos

August 2, 2025
Itch.io starts reindexing free NSFW content

Itch.io starts reindexing free NSFW content

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

  • Chris Meloni Teases Law & Order: SVU Appearance: ‘Hangin With Friends’
  • Awesome JAWS Poster Art From Artist Tyler Stout Pays Tribute To Quint — GeekTyrant
  • Donald Trump Responds to Question About Pardoning Diddy
  • 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