gpt4 book ai didi

html - Bootstrap 4 导航侧不平滑/生涩/毛刺

转载 作者:行者123 更新时间:2023-12-03 17:20:13 25 4
gpt4 key购买 nike

我正在尝试使用 Bootstrap 4 从我的导航中获得一个很好的幻灯片,但它真的很生涩。这是我的代码:

var videoWidth = 1280;
var video = $(".video-container video").attr("srcdesk");
if($(window).width() < 721) {
videoWidth = 720;
video = $(".video-container video").attr("srcmob");
}
$(".video-container video").attr("width", videoWidth).append('<source src="' + video + '" type="video/mp4" >');
a:link {
color: #ffffff;
opacity: 60%;
}
a:visited {
color: #ffffff;
opacity: 60%;
}
a:hover {
color: #ffffff;
opacity: 30%;
}
a:active {
color: #ffffff;
opacity: 30%;
}

.video-container {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
overflow: hidden;
}

.video-container video {
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: -2;
}

.logo {
fill: #ffffff;
opacity: 60%;
}

.navbar-toggler {
font-size: 2rem !important;
color: #ffffff !important;
opacity: 60% !important;
border-width: 0px !important;
}

.footer {
position: absolute;
bottom: 0;
width: 98%;
font-size: 13px;
height: 25px;
line-height: 25px;
/*background-color: #f5f5f5;*/
margin-left: 1%;
margin-right: 1%;
color: #ffffff;
opacity: 60%;
text-align: center;
}

.powered{
float: left;
}
.copy{
float: center;
}
.reg{
float: right;
}

@media (max-width: 576px) {
.navbar-collapse {
position: absolute;
top: 0px;
right: 100%;
padding-top: 54px;
padding-left: 15px;
padding-right: 15px;
padding-bottom: 0px;
width: 100%;
transition: all 0.4s ease;
display: block;
height: 100vh;
width: 20%;
z-index: -2;
}
.navbar-collapse.collapsing {
height: auto !important;
margin-left: 0%;
right: -20%;
transition: all 0.2s ease;
}
.navbar-collapse.show {
right: 0px;
}

.bg-light-sm {
background-color: #ffffff !important;
opacity: 90%;
}

.navbar-light-sm .navbar-brand {
color: rgba(0, 0, 0, 0.9);
}

.navbar-light-sm .navbar-brand:hover, .navbar-light-sm .navbar-brand:focus {
color: rgba(0, 0, 0, 0.9);
}

.navbar-light-sm .navbar-nav .nav-link {
color: rgba(0, 0, 0, 0.5);
}

.navbar-light-sm .navbar-nav .nav-link:hover, .navbar-light-sm .navbar-nav .nav-link:focus {
color: rgba(0, 0, 0, 0.7);
}

.navbar-light-sm .navbar-nav .nav-link.disabled {
color: rgba(0, 0, 0, 0.3);
}

.navbar-light-sm .navbar-nav .show > .nav-link,
.navbar-light-sm .navbar-nav .active > .nav-link,
.navbar-light-sm .navbar-nav .nav-link.show,
.navbar-light-sm .navbar-nav .nav-link.active {
color: rgba(0, 0, 0, 0.9);
}

.navbar-light-sm .navbar-toggler {
color: rgba(0, 0, 0, 0.5);
border-color: rgba(0, 0, 0, 0.1);
}

.navbar-light-sm .navbar-toggler-icon {
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%280, 0, 0, 0.5%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.navbar-light-sm .navbar-text {
color: rgba(0, 0, 0, 0.5);
}

.navbar-light-sm .navbar-text a {
color: rgba(0, 0, 0, 0.9);
}

.navbar-light-sm .navbar-text a:hover, .navbar-light-sm .navbar-text a:focus {
color: rgba(0, 0, 0, 0.9);
}

.footer {
font-size: 10px;
}


}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>

<div class="video-container">
<video autoplay loop="true" width="1280" height="720" muted playsinline srcdesk="https://www.corseestrada.com/site/templates/video/video.mp4" srcmob="https://www.corseestrada.com/site/templates/video/video-mobile.mp4"></video>
</div>

<nav class="navbar navbar-expand-sm">
<a class="navbar-brand" href="#">logo</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#menu" aria-controls="menu" aria-expanded="false" aria-label="Toggle navigation">
<i class="fa fa-bars"></i>
</button>

<div class="collapse navbar-collapse justify-content-end navbar-light-sm bg-light-sm" id="menu">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Menu</a>
</li>
<li class="nav-item">
<a class="nav-link">Delivery</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>



</div>
</nav>

<footer class="footer">

</footer>


我很确定它与这里的代码有关:
.navbar-collapse.collapsing {
height: auto !important;
margin-left: 0%;
right: -20%;
transition: all 0.2s ease;
}

要复制该问题,请单击“运行代码片段”,然后将窗口大小调整为宽度 < 567 像素。

编辑:我遇到的另一个问题是,当导航在我的 iPhone 上(但未在 macOS Safari 或 Chrome 中进行测试)时,存在大量悬空。我需要减少 height: 100vh;到 87 以免搞砸。任何解决方案?

谢谢!

最佳答案

您需要 position: fixed;height: 100% !important;.collapsing :

@media (max-width: 576px)
.navbar-collapse.collapsing {
margin-left: 0%;
right: -20%;
transition: all 0.2s ease;
position: fixed;
height: 100% !important;
}

你需要删除 position: absolute;来自 video-container因为它似乎没有做任何事情。

对于您的 IOS 问题,您可以将 css 指定给设备(归功于 https://stackoverflow.com/a/47818418/4101210 )。
@supports (-webkit-touch-callout: none) {
/* CSS specific to iOS devices */
}

@supports not (-webkit-touch-callout: none) {
/* CSS for other than iOS devices */
}



var videoWidth = 1280;
var video = $(".video-container video").attr("srcdesk");
if($(window).width() < 721) {
videoWidth = 720;
video = $(".video-container video").attr("srcmob");
}
$(".video-container video").attr("width", videoWidth).append('<source src="' + video + '" type="video/mp4" >');
a:link {
color: #ffffff;
opacity: 60%;
}
a:visited {
color: #ffffff;
opacity: 60%;
}
a:hover {
color: #ffffff;
opacity: 30%;
}
a:active {
color: #ffffff;
opacity: 30%;
}

.video-container {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
overflow: hidden;
}

.video-container video {
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: -2;
}

.logo {
fill: #ffffff;
opacity: 60%;
}

.navbar-toggler {
font-size: 2rem !important;
color: #ffffff !important;
opacity: 60% !important;
border-width: 0px !important;
}

.footer {
position: absolute;
bottom: 0;
width: 98%;
font-size: 13px;
height: 25px;
line-height: 25px;
/*background-color: #f5f5f5;*/
margin-left: 1%;
margin-right: 1%;
color: #ffffff;
opacity: 60%;
text-align: center;
}

.powered{
float: left;
}
.copy{
float: center;
}
.reg{
float: right;
}

@media (max-width: 576px) {
.navbar-collapse {
position: absolute;
top: 0px;
right: 100%;
padding-top: 54px;
padding-left: 15px;
padding-right: 15px;
padding-bottom: 0px;
width: 100%;
transition: all 0.4s ease;
display: block;
height: 100vh;
width: 20%;
z-index: -2;
}
.navbar-collapse.collapsing {
position: fixed;
height: 100% !important;
margin-left: 0%;
right: -20%;
transition: all 0.2s ease;
}
.navbar-collapse.show {
right: 0px;
}

.bg-light-sm {
background-color: #ffffff !important;
opacity: 90%;
}

.navbar-light-sm .navbar-brand {
color: rgba(0, 0, 0, 0.9);
}

.navbar-light-sm .navbar-brand:hover, .navbar-light-sm .navbar-brand:focus {
color: rgba(0, 0, 0, 0.9);
}

.navbar-light-sm .navbar-nav .nav-link {
color: rgba(0, 0, 0, 0.5);
}

.navbar-light-sm .navbar-nav .nav-link:hover, .navbar-light-sm .navbar-nav .nav-link:focus {
color: rgba(0, 0, 0, 0.7);
}

.navbar-light-sm .navbar-nav .nav-link.disabled {
color: rgba(0, 0, 0, 0.3);
}

.navbar-light-sm .navbar-nav .show > .nav-link,
.navbar-light-sm .navbar-nav .active > .nav-link,
.navbar-light-sm .navbar-nav .nav-link.show,
.navbar-light-sm .navbar-nav .nav-link.active {
color: rgba(0, 0, 0, 0.9);
}

.navbar-light-sm .navbar-toggler {
color: rgba(0, 0, 0, 0.5);
border-color: rgba(0, 0, 0, 0.1);
}

.navbar-light-sm .navbar-toggler-icon {
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%280, 0, 0, 0.5%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.navbar-light-sm .navbar-text {
color: rgba(0, 0, 0, 0.5);
}

.navbar-light-sm .navbar-text a {
color: rgba(0, 0, 0, 0.9);
}

.navbar-light-sm .navbar-text a:hover, .navbar-light-sm .navbar-text a:focus {
color: rgba(0, 0, 0, 0.9);
}

.footer {
font-size: 10px;
}


}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>

<div class="video-container">
<video autoplay loop="true" width="1280" height="720" muted playsinline srcdesk="https://www.corseestrada.com/site/templates/video/video.mp4" srcmob="https://www.corseestrada.com/site/templates/video/video-mobile.mp4"></video>
</div>

<nav class="navbar navbar-expand-sm">
<a class="navbar-brand" href="#">logo</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#menu" aria-controls="menu" aria-expanded="false" aria-label="Toggle navigation">
<i class="fa fa-bars"></i>
</button>

<div class="collapse navbar-collapse justify-content-end navbar-light-sm bg-light-sm" id="menu">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Menu</a>
</li>
<li class="nav-item">
<a class="nav-link">Delivery</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>



</div>
</nav>

<footer class="footer">

</footer>

关于html - Bootstrap 4 导航侧不平滑/生涩/毛刺,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62296191/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com