📅  最后修改于: 2023-12-03 14:47:23.207000             🧑  作者: Mango
手风琴是一种常用的折叠式UI元素,可以使用户通过单击这些元素来显示或隐藏其相关内容。Semantic-UI是一种流行的CSS框架,提供了许多现成的手风琴样式供程序员使用。
Accordion是Semantic-UI提供的一种基本手风琴样式。使用方式如下:
<div class="ui accordion">
<div class="title">
<i class="dropdown icon"></i>
What is a dog?
</div>
<div class="content">
<p>A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.</p>
</div>
<div class="title">
<i class="dropdown icon"></i>
What kinds of dogs are there?
</div>
<div class="content">
<p>There are many breeds of dogs. Each breed varies in size and temperament. Owners often select a breed of dog that they find to be compatible with their own lifestyle and desires from a companion.</p>
</div>
<div class="title">
<i class="dropdown icon"></i>
How do you acquire a dog?
</div>
<div class="content">
<p>Three common ways for a prospective owner to acquire a dog is from pet shops, private owners, or shelters.</p>
<p>A pet shop may be the most convenient way to buy a dog. Buying a dog from a private owner allows you to assess the pedigree and upbringing of the dog before choosing to take it home. Lastly, finding your dog from a shelter, helps give a good home to a dog who may not find one so readily.</p>
</div>
</div>
该示例演示了如何创建一个手风琴,其中包含三个可展开的部分,每个部分由标题和内容组成。手风琴的整个容器有一个“ui accordion”类,并且每个部分都有一个“title”类和一个“content”类。
Fluid是一种自适应大小的手风琴类型,可以自动根据父容器的大小调整自身大小。使用方式如下:
<div class="ui fluid accordion">
<div class="title">
<i class="dropdown icon"></i>
What is a dog?
</div>
<div class="content">
<p>A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.</p>
</div>
<div class="title">
<i class="dropdown icon"></i>
What kinds of dogs are there?
</div>
<div class="content">
<p>There are many breeds of dogs. Each breed varies in size and temperament. Owners often select a breed of dog that they find to be compatible with their own lifestyle and desires from a companion.</p>
</div>
<div class="title">
<i class="dropdown icon"></i>
How do you acquire a dog?
</div>
<div class="content">
<p>Three common ways for a prospective owner to acquire a dog is from pet shops, private owners, or shelters.</p>
<p>A pet shop may be the most convenient way to buy a dog. Buying a dog from a private owner allows you to assess the pedigree and upbringing of the dog before choosing to take it home. Lastly, finding your dog from a shelter, helps give a good home to a dog who may not find one so readily.</p>
</div>
</div>
该示例中的手风琴与前一个示例相同,只是添加了一个“fluid”类,使得手风琴可以自动适应父容器的大小。
Styled是一种针对具体设计风格的手风琴类型,用于在保持一致性的前提下为应用程序提供独特的外观和感觉。使用方式如下:
<div class="ui styled accordion">
<div class="title">
<i class="dropdown icon"></i>
What is a dog?
</div>
<div class="content">
<p>A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.</p>
</div>
<div class="title">
<i class="dropdown icon"></i>
What kinds of dogs are there?
</div>
<div class="content">
<p>There are many breeds of dogs. Each breed varies in size and temperament. Owners often select a breed of dog that they find to be compatible with their own lifestyle and desires from a companion.</p>
</div>
<div class="title">
<i class="dropdown icon"></i>
How do you acquire a dog?
</div>
<div class="content">
<p>Three common ways for a prospective owner to acquire a dog is from pet shops, private owners, or shelters.</p>
<p>A pet shop may be the most convenient way to buy a dog. Buying a dog from a private owner allows you to assess the pedigree and upbringing of the dog before choosing to take it home. Lastly, finding your dog from a shelter, helps give a good home to a dog who may not find one so readily.</p>
</div>
</div>
该示例中的手风琴与前一个示例相同,只是添加了一个“styled”类,应用特定风格的视觉效果。
通过使用Semantic-UI提供的手风琴类型,可以轻松地在Web应用程序中包含折叠和展开式的UI元素,从而提高了用户交互性和普及性。程序员可以按照自己的喜好选择基本手风琴、流体手风琴或特定风格的手风琴,从而实现Web应用程序的设计要求。