Bootstrap容器背景只能是白色或其他颜色/图像但不透明

时间:2016-02-11 05:49:44

标签: css twitter-bootstrap containers transparency

我的html文件中的每个文本元素在bootstrap的容器中或另一个div中都不会透露我的尝试:background:transparent!important,background-color with rgba opacity,以及添加不透明度本身。

这是HTML + CSS:

html { 
    background: url(background.jpg) no-repeat center center fixed; 
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

@font-face {
  font-family: "elephant";
  src: url("elephnt.ttf");
}

#frontpage{
  background: transparent; 
}

@media(max-width: 480px) {
  h1 {
    font-size: 12pt;
  }
}
#title
{
color: rgb(255, 255, 255);
font-size: 50px;
text-shadow: rgb(3, 3, 3) -1px 4px 9px;
}
</style>
</head>

<body>
<div class="container-fluid" style="background:transparent;" >


 <h1 id="title">Butt</h1>


</div>
</body>

2 个答案:

答案 0 :(得分:0)

参见示例:fiddle

CSS

 body{background:#666;}
 #title{
  color: rgba(255, 255, 255, 0.5);
  font-size: 50px;
 }

HTML

 <div class="container-fluid" style="background:transparent;" >
 <h1 id="title">Butt</h1>
 </div>

答案 1 :(得分:0)

Bootstrap的默认背景颜色为白色特定

body {
    font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
    font-size: 14px;
    line-height: 1.42857143;
    color: #333;
    background-color: #fff; /* here */
}

您需要覆盖它。

&#13;
&#13;
html {
  background: url(http://lorempixel.com/image_output/fashion-q-c-640-480-8.jpg) no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}
@font-face {
  font-family: "elephant";
  src: url("elephnt.ttf");
}
@media(max-width: 480px) {
  h1 {
    font-size: 12pt;
  }
}
#title {
  color: rgb(255, 255, 255);
  font-size: 50px;
  text-shadow: rgb(3, 3, 3) -1px 4px 9px;
}
body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.42857143;
  color: #333;
  background-color: transparent !important;
  /* important used here for demo */
}
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid">


  <h1 id="title">Butt</h1>


</div>
&#13;
&#13;
&#13;