透明的Bootstrap面板

时间:2014-07-20 22:16:37

标签: css twitter-bootstrap opacity transparent

我选择了this free bootstrap theme,我的问题是我想创建透明面板,但是当我设置opacity: 0.8;面板中的文本时,当然会变得透明,这不是我的事情想要发生。我尝试使用这个CSS代码,但看起来标题和正文后面还有一些东西,面板不透明。

.panel-transparent .panel-heading{
    background: rgba(122, 130, 136, 0.2)!important;
}

.panel-transparent .panel-body{
    background: rgba(46, 51, 56, 0.2)!important;
}


编辑 - 示例HTML:

<div class="panel panel-primary">
  <div class="panel-heading">
    <h3 class="panel-title">Panel primary</h3>
  </div>
  <div class="panel-body">
    Panel content
  </div>
</div>

3 个答案:

答案 0 :(得分:26)

<强> CSS

    body {
        background:#c33;
    }

    .panel-transparent {
        background: none;
    }

    .panel-transparent .panel-heading{
        background: rgba(122, 130, 136, 0.2)!important;
    }

    .panel-transparent .panel-body{
        background: rgba(46, 51, 56, 0.2)!important;
    }

<强> HTML

<div class="panel panel-primary panel-transparent">
  <div class="panel-heading">
    <h3 class="panel-title">Panel primary</h3>
  </div>
  <div class="panel-body">
    Panel content
  </div>
</div>

Example

答案 1 :(得分:1)

.transparent{    
    background-color: rgba(0,0,0,0.15);
}

.panel{
    background-color: transparent;
    border: 1px #222;
}
<div class="panel panel-default">
     <div class="panel-heading">Título</div>
     <div class="panel-body transparent">                  
     </div>
</div>  

答案 2 :(得分:0)

只需使用上面链接中提到的“ bg透明”即可; https://getbootstrap.com/docs/4.1/utilities/colors/

这样;

<div class="panel panel-primary">
  <div class="panel-heading">
    <h3 class="panel-title bg-transparent text-dark">Panel primary</h3>
  </div>
  <div class="panel-body bg-transparent text-white">
    Panel content
  </div>
</div>

并且绝对确保不要忘记添加引导程序。