我是引导程序的新手,并尝试在悬停时实施背景颜色更改。 好吧,这正在发生,但不是完美的。需要以这种方式实现。
轮播容器后有这种全高悬停效果。
我尝试过填充和最小高度,但仍然无法实现。
我的代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cnetric | Home</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"
crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/"
crossorigin="anonymous">
<link rel="stylesheet" href="./css/styles.css">
</head>
<body>
<div class="navbar-wrapper">
<div class="container">
<div class="row">
<div class="col-lg-8 offset-sm-5">
<ul class="list-inline">
<li class="list-inline-item">Agile</li>
<li class="list-inline-item">Open Source</li>
<li class="list-inline-item">Digitalization</li>
<li class="list-inline-item">Enterprise</li>
<li class="list-inline-item">Knowledge Base</li>
<li class="list-inline-item">english</li>
</ul>
</div>
</div>
</div>
<div class="container">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#"><img src="./images/Cnetric_High-Res_Logo.png" width="160px" height="65px"
alt="Cnetric Company Logo"></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Capabilities</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Solutions</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Our Team</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Our Clients</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Blog</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"><i class="fas fa-search"></i></a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ul class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ul>
<!-- The slideshow -->
<div class="carousel-inner">
<div class="carousel-item active">
<img class="img-fluid" src="./images/new-york-city-3.jpg" alt="New York">
<div class="carousel-caption d-block h-50 text-left">
<h1>LEADERS IN</h1>
<h2>DIGITAL TRANSFORMATION</h2>
<p>Delivering and supporting business-critical commerce solutions that power your growth</p>
<button class="btn btn-warning">Read More</button>
</div>
</div>
<div class="carousel-item">
<img class="img-fluid" src="./images/new-york-city-3.jpg" alt="Chicago">
</div>
<div class="carousel-item">
<img class="img-fluid" src="./images/new-york-city-3.jpg" alt="New York">
</div>
</div>
<!-- Left and right controls -->
<a class="carousel-control-prev" href="#myCarousel" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#myCarousel" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>
<div class="container application-container">
<div class="row mb-5">
<div class="col-lg-2 text-center image-container">
<img src="./images/aoe_icons_services_order_management.svg" width="60" height="67" alt="New York">
</div>
<div class="col-lg-2 text-center image-container">
<img src="./images/aoe_icons_webportal.svg" width="60" height="67" alt="New York">
</div>
<div class="col-lg-2 text-center image-container">
<img src="./images/aoe_icons_technologies-13.svg" width="60" height="67" alt="New York">
</div>
<div class="col-lg-2 text-center image-container">
<img src="./images/aoe_icons_web_and_mobile_applications.svg" width="60" height="67" alt="New York">
</div>
<div class="col-lg-2 text-center image-container">
<img src="./images/aoe_icons_web_content_management.svg" width="60" height="67" alt="New York">
</div>
<div class="col-lg-1 text-center image-container">
<img src="./images/Search2.svg" width="60" height="67" alt="New York">
</div>
<div class="col text-center mt-3">
<p>View All</p>
</div>
</div>
</div>
</body>
</html>
Styles.css
.application-container .image-container:hover{
background-color: #EFF3F6;
}
.application-container .image-container {
position: relative;
}
.application-container .image-container:hover:after {
content: "";
display: block;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #EFF3F6;
position: absolute;
left: 45%;
bottom: 66px;
}
实现上面的代码后,我得到的就是这样。 悬停效果应在轮播和应用容器之间 我尝试使用line-height属性,但是不起作用。 有人可以帮忙/指导我吗。
答案 0 :(得分:0)
在display: inline-block; padding: 20px;
中添加.application-container .image-container
将完成您的工作,
希望这会有所帮助
答案 1 :(得分:0)
在.py-*
上添加类py-1
(即.image-container
)以增加间距。
参考:https://getbootstrap.com/docs/4.1/utilities/spacing/#notation
答案 2 :(得分:0)
据我了解,更改了样式并获得以下输出:
对于此更改,请更新以下样式:
.application-container .image-container {
position: relative;
display: inline-block;
padding: 20px;
cursor: pointer;
}
.application-container .image-container:hover:after {
content: "";
display: block;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #EFF3F6;
position: absolute;
left: 45%;
top: -10px;
}
答案 3 :(得分:0)
我认为它应该对您有用:https://jsfiddle.net/abhineetV/gf4qhswc/26/ 我已经改变了一些结构。
<div class="container application-container">
<ul class="banner-nav list-unstyled d-flex justify-content-center">
<li>
<a href="javascript:void(0);" class="d-flex flex-column"><span class="oi oi-account-login"></span><div>
account login
</div></a>
</li>
<li>
<a href="javascript:void(0);" class="d-flex flex-column"><span class="oi oi-pencil"></span><div>
pencil
</div></a>
</li>
<li>
<a href="javascript:void(0);" class="d-flex flex-column"><span class="oi oi-shield"></span><div>
shield
</div></a>
</li>
<li>
<a href="javascript:void(0);" class="d-flex flex-column"><span class="oi oi-arrow-right"></span> <div>
View All
</div></a>
</li>
</ul>
</div>
CSS:
.banner-nav>li {
width: 120px;
}
.banner-nav>li>a {
height: 100%;
padding: 15px;
text-align: center;
transition: all 0.2s ease;
}
.banner-nav>li>a:hover {
background-color: #EFF3F6;
}