【问题标题】:React JS collapsable elements Pure CSSReact JS 可折叠元素 纯 CSS
【发布时间】:2022-01-25 23:20:36
【问题描述】:

我怎样才能让 Netflix 像 Collapsable QNA sectionImage 1 click here image 2

【问题讨论】:

    标签: css reactjs user-interface


    【解决方案1】:

    这个任务你不需要 JS

    body {
      margin: 0;
      background-color: #000;
      font-family: sans-serif;
    }
    
    .faq_block {
      margin: 30px 0 85px
    }
    
    .faq_item {
      border-radius: 20px;
      padding: 0;
      margin-bottom: 10px
    }
    
    .faq_item:focus .faq_question,
    .faq_item:hover .faq_question {
      color: #d5f867
    }
    
    .faq_item:focus .faq_question:after,
    .faq_item:focus .faq_question:before,
    .faq_item:hover .faq_question:after,
    .faq_item:hover .faq_question:before {
      background: #d5f867
    }
    
    .faq_item:before {
      display: none
    }
    
    .faq_question {
      font-weight: 700;
      position: relative;
      display: block;
      font-size: 16px;
      color: #fff;
      border-radius: 20px;
      cursor: pointer
    }
    
    .faq_question:after,
    .faq_question:before {
      content: "";
      position: absolute;
      background-color: #fff;
      z-index: 2
    }
    
    .faq_question:after {
      right: 17px;
      top: 24px;
      width: 14px;
      height: 2px
    }
    
    .faq_question:before {
      height: 14px;
      width: 2px;
      right: 23px;
      top: 18px
    }
    
    .faq_item[open] .faq_question {
      background: #d5f867;
      color: #000
    }
    
    .bl_ceo .faq_answer ul li:before,
    .faq_item[open] .faq_question:after {
      background-color: #000
    }
    
    .faq_item[open] .faq_question:before {
      opacity: 0
    }
    
    .faq_item[open] {
      background-color: #fff
    }
    
    .faq_answer,
    .faq_question {
      padding: 16px 24px
    }
    
    .faq_item[open] .faq_answer,
    .faq_item[open] .faq_answer li,
    .faq_item[open] .faq_answer p {
      color: #000
    }
    <div class="faq_block">
      <details class="faq_item" open="">
        <summary class="faq_question">Ask something smart!</summary>
        <div class="faq_answer">Answer</div>
      </details>
    
      <details class="faq_item">
        <summary class="faq_question">Ask something smart!</summary>
        <div class="faq_answer">Answer</div>
      </details>
    </div>

    【讨论】:

      猜你喜欢
      • 2012-12-28
      • 2015-02-09
      • 2016-11-14
      • 2013-02-12
      • 1970-01-01
      • 2020-05-10
      • 1970-01-01
      • 1970-01-01
      • 2015-04-19
      相关资源
      最近更新 更多