Codepen -> https://codepen.io/SubSul/pen/LgWzVw。
我修改了bootstrap 4导航栏组件,在右上角添加了用于登录的固定按钮下拉菜单。我现在正在尝试将导航项对准登录按钮上的操纵杆,但是justify-content: flex-end
似乎并没有将其推向右侧。
我尝试在导航项中添加左边距,但无济于事。
我正在尝试在桌面上实现这一目标-
在移动设备上,我试图将徽标中心对齐,并将登录按钮固定在右侧。我可以使用margin-right
将徽标移到中心,但是点击汉堡包时的过渡会将徽标向左移一点,如何将其固定在中心-
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body>
<div class="main">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">Navbar Logo</a>
<div class="collapse navbar-collapse justify-content-end" id="navbarText">
<ul class="navbar-nav">
<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="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
</ul>
</div>
</nav>
<div class="login-widget">
<button class="btn btn-secondary btn-lg dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Log In
</button>
<div class="dropdown-menu dropdown-menu-right">
<form class="px-4 py-3">
<div class="form-group">
<label for="exampleDropdownFormEmail1">Email address</label>
<input type="email" class="form-control" id="exampleDropdownFormEmail1" placeholder="email@example.com">
</div>
<div class="form-group">
<label for="exampleDropdownFormPassword1">Password</label>
<input type="password" class="form-control" id="exampleDropdownFormPassword1" placeholder="Password">
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="dropdownCheck">
<label class="form-check-label" for="dropdownCheck">
Remember me
</label>
</div>
<button type="submit" class="btn btn-primary">Sign in</button>
</form>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">New around here? Sign up</a>
<a class="dropdown-item" href="#">Forgot password?</a>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin="anonymous"></script>
</body>
</html>
样式
.main {
display: flex;
justify-content: space-between;
}
.dropdown-menu {
margin-top: 15px;
}
.navbar-collapse {
/* margin-left: 100%; */
}
.login-widget {
/* margin-left: 320px; */
}
答案 0 :(得分:1)
我想出了一个解决方案,虽然它不是我做的最干净的,但也许对您有用,我没有使用flexbox这样做,因此您可以删除.main css,首先需要在nav标签内移动.login-widget div,这样做将使其与您在台式机上一样。
>library(raster)
>setwd("D:/mtech project/data/DEC 16/RH/1-DEC-16/extracted/")
>inFiles1 <- list.files(pattern="*.tif")
> nFiles1 <- length(inFiles1)
> setwd("D:/mtech project/data/extracted/")
> inFiles2 <- raster("3DIMG_01DEC2016_0000_L2C_FOG_FOG.tif")
> for (i in 1:nFiles1) {
+ r1<-raster(inFiles1[[i]])
+ r2<-inFiles2
+ rs<-resample(r1,r2,method="bilinear")
+ write.Raster(rs, paste0('D:/mtech project/data/DEC 16/RH/RESAMPLED/rs_',i,'.img'), overwrite=T)
+ }
Error in .local(.Object, ...) :
Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer", : Cannot create a RasterLayer object from this file. (file does not exist)
但是我们在移动设备上会遇到问题,当您点击汉堡包菜单.login-widget div时,它将与菜单中的其他导航项保持一致, 破坏您的布局,所以我要解决此问题,它使.login-widget的位置绝对不变
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">Navbar Logo</a>
<div class="collapse navbar-collapse justify-content-end" id="navbarText">
<ul class="navbar-nav">
<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="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
</ul>
</div>
<div class="login-widget">
<button class="btn btn-secondary btn-lg dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Log In
</button>
<div class="dropdown-menu dropdown-menu-right">
<form class="px-4 py-3">
<div class="form-group">
<label for="exampleDropdownFormEmail1">Email address</label>
<input type="email" class="form-control" id="exampleDropdownFormEmail1" placeholder="email@example.com">
</div>
<div class="form-group">
<label for="exampleDropdownFormPassword1">Password</label>
<input type="password" class="form-control" id="exampleDropdownFormPassword1" placeholder="Password">
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="dropdownCheck">
<label class="form-check-label" for="dropdownCheck">
Remember me
</label>
</div>
<button type="submit" class="btn btn-primary">Sign in</button>
</form>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">New around here? Sign up</a>
<a class="dropdown-item" href="#">Forgot password?</a>
</div>
</div>
</nav>
这将解决.login-widget的问题,但现在我们又遇到了一个问题。.navbar-brand没有居中,因此我要解决的问题再次使用绝对位置
.login-widget{
position: absolute;
right: 16px;
top: 4px;
}
最后,您必须将此类包装在媒体查询中,以重置桌面的值。
.navbar-brand{
position: absolute;
top: 8px;
right: calc(109px + 16px);
left: calc(56px + 16px);
text-align: center;
}
Here如果您想测试一个码本,请告诉我,这是否是您想要的解决方案!