从Bootstrap 3中的缩略图中删除恼人的白色背景

时间:2017-02-14 06:27:57

标签: css twitter-bootstrap thumbnails

我创建了一小段代码,它在一行中显示了相等网格宽度的4个缩略图。

.row-content-3 {
    background-color: rgba(0,0,0,0.8) !important;
    color: #fff;
    margin:0px auto;
    padding: 50px 0px 50px 0px;
    min-height:200px;
}
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row row-content-3">
        <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
            <div class="thumbnail">
               <a href="#">
                 <img src="http://www.theo-android.co.uk/github-images/fair1.png" class="img-circle" alt="Larissa's fair"> 
               </a>
            </div>
        </div>
        <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
            <div class="thumbnail">
               <a href="#">
                 <img src="http://www.theo-android.co.uk/github-images/fair2.png" class="img-circle" alt="Larissa's fair"> 
               </a>
            </div>
        </div>
        <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
            <div class="thumbnail">
               <a href="#">
                 <img src="http://www.theo-android.co.uk/github-images/fair3.png" class="img-circle" alt="Larissa's fair"> 
               </a>
            </div>
        </div>
        <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
            <div class="thumbnail">
               <a href="#">
                 <img src="http://www.theo-android.co.uk/github-images/fair4.png" class="img-circle" alt="Larissa's fair"> 
               </a>
            </div>
        </div>   
 </div>

如果您运行代码,您会注意到需要删除白色背景。我把这个css简单的代码,但它不起作用:(。

.thumbnail {
  border: 0;
}

我也在给你jsfiddle

任何想法,

谢谢Theo。

5 个答案:

答案 0 :(得分:3)

transparent

提供thumbnail的背景颜色
.thumbnail {
  border: 0;
  background-color:transparent;
}

更新了小提琴:https://jsfiddle.net/affaz/udgw71no/8/

答案 1 :(得分:3)

如果我没错,那么你只想从圆形图像中删除白色背景。

我添加了这个

.thumbnail {
  border: 0;
  background: transparent;
}

你也可以看到有盒子阴影。您可以使用

删除它
box-shadow: none;

更新了小提琴:https://jsfiddle.net/udgw71no/6/

答案 2 :(得分:2)

寻找这个?

.thumbnail {
    border: 0;
    background: transparent;
    -webkit-box-shadow: none;
    box-shadow: none;
}

Demo

答案 3 :(得分:2)

删除缩略图的背景,但要使其正常工作。

.row-content-3 {
    background-color: rgba(0,0,0,0.8) !important;
    color: #fff;
    margin:0px auto;
    padding: 50px 0px 50px 0px;
    min-height:200px;
}

.thumbnail {
  background: none !important;
  border: 0 !important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row row-content-3">
        <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
            <div class="thumbnail">
               <a href="#">
                 <img src="http://www.theo-android.co.uk/github-images/fair1.png" class="img-circle" alt="Larissa's fair"> 
               </a>
            </div>
        </div>
        <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
            <div class="thumbnail">
               <a href="#">
                 <img src="http://www.theo-android.co.uk/github-images/fair2.png" class="img-circle" alt="Larissa's fair"> 
               </a>
            </div>
        </div>
        <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
            <div class="thumbnail">
               <a href="#">
                 <img src="http://www.theo-android.co.uk/github-images/fair3.png" class="img-circle" alt="Larissa's fair"> 
               </a>
            </div>
        </div>
        <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
            <div class="thumbnail">
               <a href="#">
                 <img src="http://www.theo-android.co.uk/github-images/fair4.png" class="img-circle" alt="Larissa's fair"> 
               </a>
            </div>
        </div>   
 </div>

答案 4 :(得分:1)

设置以下样式应该这样做:

.thumbnail {
    background-color: transparent;
    border: none;
}