2015-07-12 95 views
5

我遇到了CSS覆蓋問題。覆蓋圖案不會在圖像大小的整個寬度上延伸。左邊總是有一個小邊界。有任何想法嗎? http://www.bootply.com/FrnoIvUpxS引導程序覆蓋問題

.img-container { 
 
    position: relative; 
 
    cursor: pointer; 
 
    display: table; 
 
    overflow:hidden; 
 
text-align:center; 
 
width:100%; 
 
min-height: 360px; 
 
} 
 

 
.img-container img { 
 
opacity: 1; 
 
    position: absolute; 
 
    min-height:360px; 
 
    width: 500px; 
 
} 
 

 

 
.img-container .overlay { 
 

 
    position: relative; 
 

 
    height: 100%; 
 
    vertical-align:middle; 
 
    display: table-cell; 
 
    background-color:rgba(130,216,209,0.00); 
 
    opacity:0.0; 
 
} 
 

 

 
.img-container p{ 
 
    width:inherit; 
 
    margin-top:25px; 
 
    } 
 
.img-container h3 { 
 

 
    } 
 
.img-container:hover .overlay { 
 
background-color:rgba(130,216,209,0.9); 
 

 
     opacity:1; 
 
} 
 
.img-container:hover img{ 
 
     -moz-transform: scale(1.4); 
 
    -o-transform: scale(1.4); 
 
    -webkit-transform: scale(1.4); 
 
    transform: scale(1.4); 
 
    opacity:1;} 
 

 
    .img-container:hover p, .img-container:hover h3 { }
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/> 
 
<div class="container"> 
 
<div class="row"> 
 
<div class="col-md-4"> 
 

 
<div class="img-container"> 
 
    <img src="http://placehold.it/500x500" class="img-responsive" alt=""> 
 
    <div class="overlay"> 
 
    <h3>TIBET</h3> 
 
    <p>RISING IN THE NORTH</p> 
 
    </div> 
 
    </div> 
 

 
</div> 
 
<div class="col-md-4"> 
 
<div class="img-container"> 
 
    <img src="http://placehold.it/500x500" class="img-responsive" alt=""> 
 
    <div class="overlay"> 
 
    <h3>POKER</h3> 
 
    <p>PLAY YA CARDS RIGHT</p> 
 
    </div> 
 
    </div> 
 

 
</div> 
 
<div class="col-md-4"> 
 
<div class="img-container"> 
 
    <img src="http://placehold.it/500x500" class="img-responsive" alt=""> 
 
    <div class="overlay"> 
 
    <h3>INDUSTRY</h3> 
 
    <p>MACHINES THAT DO IT</p> 
 
    </div> 
 
    </div> 
 
</div> 
 
</div> 
 

 
</div>

回答

2

嘗試this

  1. table-layout: fixed.img-container;
  2. width: 100%.img-container .overlay

.img-container { 
 
    position: relative; 
 
    cursor: pointer; 
 
    display: table; 
 
    table-layout: fixed; 
 
    overflow: hidden; 
 
    text-align: center; 
 
    width: 100%; 
 
    min-height: 360px; 
 
} 
 

 
.img-container img { 
 
    opacity: 1; 
 
    position: absolute; 
 
    min-height: 360px; 
 
    width: 500px; 
 
} 
 

 
.img-container .overlay { 
 
    position: relative; 
 
    height: 100%; 
 
    vertical-align: middle; 
 
    display: table-cell; 
 
    width: 100%; 
 
    background-color: rgba(130, 216, 209, 0.00); 
 
    opacity: 0.0; 
 
} 
 

 
.img-container p { 
 
    width: inherit; 
 
    margin-top: 25px; 
 
} 
 

 
.img-container:hover .overlay { 
 
    background-color: rgba(130, 216, 209, 0.9); 
 
    opacity: 1; 
 
} 
 

 
.img-container:hover img { 
 
    -moz-transform: scale(1.4); 
 
    -o-transform: scale(1.4); 
 
    -webkit-transform: scale(1.4); 
 
    transform: scale(1.4); 
 
    opacity: 1; 
 
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/> 
 
<div class="container"> 
 
    <div class="row"> 
 
     <div class="col-md-4"> 
 
      <div class="img-container"> 
 
       <img src="http://placehold.it/500x500" class="img-responsive" alt=""> 
 
       <div class="overlay"> 
 
        <h3>TIBET</h3> 
 
        <p>RISING IN THE NORTH</p> 
 
       </div> 
 
      </div> 
 
     </div> 
 
     <div class="col-md-4"> 
 
      <div class="img-container"> 
 
       <img src="http://placehold.it/500x500" class="img-responsive" alt=""> 
 
       <div class="overlay"> 
 
        <h3>POKER</h3> 
 
        <p>PLAY YA CARDS RIGHT</p> 
 
       </div> 
 
      </div> 
 
     </div> 
 
     <div class="col-md-4"> 
 
      <div class="img-container"> 
 
       <img src="http://placehold.it/500x500" class="img-responsive" alt=""> 
 
       <div class="overlay"> 
 
        <h3>INDUSTRY</h3> 
 
        <p>MACHINES THAT DO IT</p> 
 
       </div> 
 
      </div> 
 
     </div> 
 
    </div> 
 
</div>

附:請在發佈或創建代碼片段之前設置您的代碼的格式。