我正在一個個人設計項目中,我有5個圖像在他們的瓷磚,當你將鼠標放在任何一個他們顯示替代文字。我已經包含了我的源代碼,但我的問題似乎是當我通過在tile上懸停來測試這個問題時,我添加了W3代碼片段而沒有發生任何事情。如果我檢查代碼,然後在Chrome檢查工具中添加懸停屬性,它似乎工作得很好。我在這裏錯過了什麼?CSS:懸停在實踐中不工作
這裏是我的代碼My Code
.bottom p {
\t text-align: center;
}
.bottom {
\t margin-top: 200px;
\t width: 50%;
}
.top {
\t width: 33.33333333333%;
\t display: inline-block;
\t
}
.tile {
\t height: 200px;
\t justify-content: center;
align-items: center;
overflow: hidden;
padding-left: 0px;
padding-right: 0px;
border-style: solid;
border-width: 5px;
border-color: /*Navy Blue*/ #333333/* FetchMe Orange #FBAA1E*/; \t
\t text-align: center;
\t box-shadow: 5px 5px 10px #000000;
\t
}
.tile p {
\t z-index: 4;
\t font-size: 24px;
\t position: absolute;
\t bottom: 0;
\t margin-bottom: 10px;
\t font-weight: bold;
\t text-align: center;
\t margin-left: 35%;
\t margin-right: 35%;
\t
}
.img1 {
\t flex-shrink: 0;
min-width: 100%;
min-height: 100%
}
.top p {
\t text-align: center;
}
.fetch-form {
padding-top: 50px;
padding-bottom: 50px;
margin: 0 auto;
position: absolute;
z-index: 3;
margin-left: 110px;
margin-right: 110px;
left: 0;
right: 0;
}
.tiles {
\t margin-left: 0px;
\t margin-right: 0px;
\t z-index: 2;
\t position: absolute;
\t top: 150px;
\t left: 0px;
\t color: white;
\t display: inline-block;
\t padding-top: 10px;
}
.inner {
\t display: block;
margin-left: auto;
margin-right: auto;
\t
}
.slider {
\t z-index: -1;
\t position: absolute;
\t padding-right: 0;
\t padding-left: 0;
\t margin-right: 0;
\t margin-left: 0;
\t left: 0;
\t right: 0;
\t top: 0;
\t height: 600px;
\t min-width: 100%;
}
.item {
\t height: 600px;
}
.container {
position: relative;
}
.overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: #008CBA;
overflow: hidden;
width: 0%;
height: 100%;
transition: .5s ease;
z-index: 5;
}
.container:hover .overlay {
\t width: 100%;
}
.text {
white-space: nowrap;
color: white;
font-size: 20px;
position: absolute;
overflow: hidden;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
}
.image {
display: block;
width: 100%;
height: auto;
}
<div class="row">
<div class="col-xs-10 fetch-form">
<form action="order" method="POST" role="form" id="address_form">
<div class="col-xs-12 fetch-form">
<div class="row">
<div class="col-xs-8 input">
<div class="input">
<i class="icon-prepend fa fa-home"></i>
<input type="text" placeholder="Street Address (optional)" id="address" name="address" class="form-control input-lg" autocomplete="off">
</div>
</div>
<div class="col-xs-2">
<input type="hidden" name="zip_code"><input type="hidden" value="true" name="set_temp_address">
<button class="btn btn-primary btn-lg btn-block btn" type="submit">
<i class="fa fa-search"></i> Fetch Me Food!
</button>
</div>
</div>
</div>
<div class="row well well-sm" style="display: none;">
<div class="col-xs-4 text-center">
<div class="radio" >
<label><center><i class="fa fa-taxi fa-lg hidden-xs"> </i></center>
<input type="radio" id="type_delivery" name="order_type" value="DELIVERY" checked="checked">
<span class="radiosearch"> </span><span class="ordertype">Delivery</span>
</label>
</div>
</div>
<div class="col-xs-4 text-center border-left">
<div class="radio">
<label>
<center><i class="fa fa-cutlery fa-lg hidden-xs"> </i></center>
<input type="radio" id="type_takeout" name="order_type" value="TAKEOUT">
<span class="radiosearch"> </span>
<span class="ordertype"><nobr>Pick-up</nobr></span>
<nobr></nobr>
</label>
</div>
</div>
<div class="col-xs-4 text-center border-left" >
<div class="radio"><a href="/account/groups" style="color: #333333;">
<label>
<center><i class="fa fa-group fa-lg" style="margin-bottom: 6px;"> </i></center>
<span class="ordertype"><span style="margin-top:9px;" class="visible-xs">Group »</span></span> <span
class="ordertype"><span class="hidden-xs">Group Order »</span></span> </label></a></div>
</div>
</div>
</form>
</div>
<div class="col-xs-12 tiles">
\t <div class="inner">
\t \t <div class="col-xs-3 top tile container">
\t \t \t
\t \t \t <p>Restarunts and Catering</p>
\t \t \t \t \t <img src="https://s3.amazonaws.com/fetchme-prototype/images/fruits-grocery-bananas-market.jpg" class="img1 image" alt="">
\t \t \t \t \t <div class="overlay">
\t \t \t \t \t <div class="text">Hello World</div>
\t \t \t \t \t </div>
\t \t \t \t </div>
\t \t </div>
\t \t <div class="col-xs-3 top tile">
\t \t \t <img src="https://s3.amazonaws.com/fetchme-prototype/images/fruits-grocery-bananas-market.jpg" class="img1" alt="">
\t \t <p>Our Deals</p>
\t \t </div>
\t \t <div class="col-xs-3 top tile">
\t \t \t \t \t <img src="https://s3.amazonaws.com/fetchme-prototype/images/fruits-grocery-bananas-market.jpg" class="img1" alt="">
\t \t <p>Grocery Shopping</p>
\t \t </div>
\t </div>
</div>
<br>
<div class="col-xs-12 tiles">
\t <div class="inner">
\t <div class="col-xs-6 bottom tile">
\t \t <img src="https://s3.amazonaws.com/fetchme-prototype/images/fruits-grocery-bananas-market.jpg" alt="" class="img1" >
\t \t <p>Tailgates</p>
\t </div>
\t <div class="col-xs-6 bottom tile">
\t \t <img src="https://s3.amazonaws.com/fetchme-prototype/images/fruits-grocery-bananas-market.jpg" alt="" class="img1">
\t \t <p>Order Anything</p>
\t </div>
\t </div>
</div>
<div class="slider col-xs-12">
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<!-- Slide one -->
<div class="item active">
\t <img src="https://s3.amazonaws.com/fetchme-prototype/images/download.jpg" alt="">
</div>
<!-- Slide two -->
<div class="item">
\t <img src="https://s3.amazonaws.com/fetchme-prototype/images/download.jpg" alt="">
</div>
<!--Slide three -->
<div class="item">
\t <img src="https://s3.amazonaws.com/fetchme-prototype/images/download+(2).jpg" alt="">
</div>
<!--Slide four -->
<div class="item">
\t <img src="https://s3.amazonaws.com/fetchme-prototype/images/download+(2).jpg" alt="">
</div>
\t </div>
\t </div>
</div>
</div>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
請在這裏發表代碼,我甚至不能說出哪個元素懸停被認爲是對 – Huangism
你不是有一個叫'類隨時隨地overlay',更遑論'.container'的後代@ – TylerH
@TylerH疊加在那裏,它只是被其他元素所覆蓋。所以當你將鼠標懸停在第一塊瓷磚上並進行檢查時,你會落在其他元素上。問題與如何佈置頁面 – Huangism