简体   繁体   English

如何在 react-bootstrap 5 手风琴中更改背景颜色

[英]How to Change Background color in react-bootstrap 5 accordion

  1. Summarize the problem I read react-bootstrap 5 documentation but didn't see any problem with adding css and how to make it background-color总结一下我阅读 react-bootstrap 5 文档但没有看到添加 css 有什么问题以及如何使其成为背景色的问题
  2. Describe what you've tried i try is <Accordion.Header bsPrefix={{background: '#d0f1f7'}}>Accordion Item #1</Accordion.Header>描述你尝试过的我尝试的是<Accordion.Header bsPrefix={{background: '#d0f1f7'}}>Accordion Item #1</Accordion.Header>

Here it is:这里是:

HTML: HTML:

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">




<div class="accordion accordion-flush" id="accordionFlushExample">


  <div class="accordion-item">
    <h2 class="accordion-header" id="flush-headingOne">
      <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseOne" aria-expanded="false" aria-controls="flush-collapseOne">
      
        Accordion Item #1
      </button>
    </h2>
    <div id="flush-collapseOne" class="accordion-collapse collapse" aria-labelledby="flush-headingOne" data-bs-parent="#accordionFlushExample">
      <div class="accordion-body">Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. This is the first item's accordion body.</div>
    </div>
  </div>
  
      </div>
    
  <div class="accordion-item">
    <h2 class="accordion-header" id="flush-headingTwo">
      <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseTwo" aria-expanded="false" aria-controls="flush-collapseTwo">
        Accordion Item #2
      </button>
    </h2>
    <div id="flush-collapseTwo" class="accordion-collapse collapse" aria-labelledby="flush-headingTwo" data-bs-parent="#accordionFlushExample">
      <div class="accordion-body">Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. This is the second item's accordion body. Let's imagine this being filled with some actual content.</div>
    </div>
  </div>
  <div class="accordion-item">
    <h2 class="accordion-header" id="flush-headingThree">
      <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseThree" aria-expanded="false" aria-controls="flush-collapseThree">
        Accordion Item #3
      </button>
    </h2>
    <div id="flush-collapseThree" class="accordion-collapse collapse" aria-labelledby="flush-headingThree" data-bs-parent="#accordionFlushExample">
      <div style='background-color:"red" class="accordion-body">Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. This is the third item's accordion body. Nothing more exciting happening here in terms of content, but just filling up the space to make it look, at least at first glance, a bit more representative of how this would look in a real-world application.</div>
    </div>
  </div>
</div>
 <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>

CSS : CSS:

.accordion-item{background-color:#777777 !important;border:1px solid 
rgba(0,0,0,.125)!important}

https://jsfiddle.net/h27ck6rp/2/ https://jsfiddle.net/h27ck6rp/2/

insted of <Accordion.Header bsPrefix={{background: '#d0f1f7'}}>Accordion Item #1</Accordion.Header> <Accordion.Header bsPrefix={{background: '#d0f1f7'}}>Accordion Item #1</Accordion.Header>
Use this on CSS file在 CSS 文件上使用它

.accordion-button {
      background-color: #d0f1f7 !important;
 }


.accordion-button:focus {
  box-shadow: none;
}

.accordion-button:not(.collapsed) {
  color: #212529;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何更改 React-Bootstrap NavDropdown 菜单背景颜色? - How to change React-Bootstrap NavDropdown menu background color? 如何更改 react-bootstrap 中活动单选按钮的背景颜色? - How to change background color of active radio button in react-bootstrap? 在 react-bootstrap 中更改 NavDropdown 的颜色和背景颜色 - Change color & background-color of NavDropdown in react-bootstrap 如何更改选定的react-bootstrap ToggleButton的背景颜色? - How do I change the background color of a selected react-bootstrap ToggleButton? 如何使用 Emotion 更改 react-bootstrap 开关(Forms 组件的一部分)的背景颜色 - How to change the background color of react-bootstrap's switch (part of the Forms component) using Emotion 如何更改 react-bootstrap 中导航栏切换按钮中的线条颜色? - how to change the line color in the NavBar toggle button in react-bootstrap? 如何在 react-bootstrap 中更改我的 5 个选项卡之一的颜色? - How to change the color of one of my 5 tabs in react-bootstrap? 我怎样才能 react-bootstrap 更改选项卡的颜色 - how can I react-bootstrap change the color of the tabs React.js Bootstrap Accordion 在点击时改变背景颜色 - React.js Bootstrap Accordion change background color when clicked react-bootstrap 手风琴未加载 - react-bootstrap Accordion not loading
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM