如何使该悬停显示响应?

时间:2019-03-20 23:47:56

标签: html5 css3 bootstrap-4

我正在使用Bootstrap框架创建3-col网格。我想创建一个似乎运行良好的简单悬停,但是当我最小化窗口时,悬停的高度会有点混乱。帮助!

我认为我无法弄清的主要问题是它是3列网格...当调整宽度和高度时,这似乎可以在2列网格上工作。我尝试插入的图像也有正方形(400x400),其中的大小是矩形,我似乎也无法弄清楚该如何调整。

/* Image zoom on hover + Overlay colour */
.parent {
    width: 100%;
    margin: 20px;
    height: 330px;
    border: 1px solid blue;
    overflow: hidden;
    position: relative;
    float: left;
    display: inline-block;
	cursor: pointer;
}
.child {
    height: 100%;
    width: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    -webkit-transition: all .5s;
    -moz-transition: all .5s;
    -o-transition: all .5s;
    transition: all .5s;
}
a.hover {
    display: none;
    font-size: 25px;
    color: #ffffff !important;
    font-family: 'Open Sans', Arial, Helvetica, sans-serif;
    text-align: center;
    margin: auto;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    height: 50px;
    cursor: pointer;
    /*text-decoration: none;*/
}

.bg-one {background-image: url("col-01.jpg");}
.bg-two {background-image: url(http://s1.it.atcdn.net/wp-content/uploads/2015/08/2-London.jpg);}
.bg-three {background-image: url(https://media.timeout.com/images/101484105/image.jpg);}
.bg-four {background-image: url(https://upload.wikimedia.org/wikipedia/commons/thumb/0/00/Hollywood_Sign.jpg/1280px-Hollywood_Sign.jpg);}
.bg-five {background-image: url(http://www.travelandleisure.com/sites/default/files/styles/tnl_redesign_article_landing_page/public/1453920892/DUBAI-554088081-ABOVE0116.jpg?itok=dcoZnCrc);}
.bg-six {background-image: url(http://blog.whitepages.com/wp-content/uploads/2015/04/san-franc.jpg);}

.parent:hover .child, .parent:focus .child {
    -ms-transform: scale(1.1);
    -moz-transform: scale(1.1);
    -webkit-transform: scale(1.1);
    -o-transform: scale(1.1);
    transform: scale(1.1);
}

.parent:hover .child:before, .parent:focus .child:before {
    display: block;
}

.parent:hover a, .parent:focus a {
    display: block;
}

.child:before {
    content: "";
    display: none;
    height: 100%;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background-color: #1e1e1e;
	opacity: 0.7;
}

/* Media Queries */
@media screen and (max-width: 960px) {
    .parent {width: 100%; margin: 20px 0px}
	.wrapper {padding: 20px 20px;}
}
 <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>

  <div class="row pb20">
    <div class="col-xs-12 col-sm-6 col-md-4 pb20">
 	<div class="parent" onclick="">
		<div class="child bg-one">
			<a class="hover" href="#">London</a>
		</div>
	</div>
		
    </div>
    <div class="col-xs-12 col-sm-6 col-md-4 pb20">
       	<div class="parent" onclick="">
		<div class="child bg-one">
			<a class="hover" href="#">London</a>
		</div>
	</div>
    </div>
    <div class="col-xs-12 col-sm-6 col-md-4 pb20">

   	<div class="parent" onclick="">
		<div class="child bg-one">
			<a class="hover" href="#">London</a>
		</div>
	</div>
    </div>

		
    <div class="col-xs-12 col-sm-6 col-md-4 pb20">
         	<div class="parent" onclick="">
		<div class="child bg-one">
			<a class="hover" href="#">London</a>
		</div>
	</div>
		
    </div>
    <div class="col-xs-12 col-sm-6 col-md-4 pb20">
       	<div class="parent" onclick="">
		<div class="child bg-one">
			<a class="hover" href="#">London</a>
		</div>
	</div>

    </div>
    <div class="col-xs-12 col-sm-6 col-md-4 pb20">
 	<div class="parent" onclick="">
		<div class="child bg-one">
			<a class="hover" href="#">London</a>
		</div>
	</div>
    </div>
    </div>

0 个答案:

没有答案