我目前正在建立一个示例站点,以遵循我在bootstrap中学到的知识(或者我认为我学到的东西)。在这个网站上,我想在某个位置对齐DIV。该网站不针对移动设备进行调整,因为我当时只是在计算机上进行测试。Div对齐最佳实践
就定位H1 & H2而言,以下代码是否是最佳实践?我已经尝试了大约3个小时,垂直定位div id="outer"
垂直&水平居中,无济于事。沮丧,我转向position: absolute
使用top
和left
规格。使用我提供的代码,这是最佳实践,AKA是对齐这些标题文本的最佳解决方案吗?非常感谢你提前(抱歉NOOBing):
https://jsfiddle.net/8kqxtvn8/
@import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
html,
body {
height: 100%;
}
.navbar {
background-color: transparent;
background: transparent;
border-color: transparent;
border-radius: 0;
display: flex;
margin: 0;
}
.nav {
display: inline-flex;
flex-wrap: wrap;
font-size: 28px;
}
.navbar-brand img {
height: auto;
margin-top: -15px;
width: 50px;
}
.nav-link {
margin-right: 2rem;
}
.maincontent {
background-color: grey;
background-image: url('img/bgcover.jpg');
background-position: center;
background-repeat: no-repeat;
background-size: cover;
height: 100%;
}
#vertical {
position: absolute;
top: 30%;
left: 15%;
}
#outer {
background-color: yellow;
}
<nav class="navbar navbar-inverse navbar-fixed-top fixed-top">
<div class="container-fluid">
<nav class="nav">
<a class="nav-link" href="#">Galaxies</a>
<a class="nav-link" href="#">Telescopes</a>
<div class="logo">
<a class="navbar-brand custom-logo" href="#"><img src="https://www.shareicon.net/download/2016/07/11/794282_education_512x512.png" /></a>
</div>
<a class="nav-link" href="#">Projects</a>
<a class="nav-link" href="#">Get involved</a>
</nav>
</div>
</nav>
<section class="maincontent">
<div class="container-fluid">
<div class="row" id="vertical">
<div id="outer">
<h1>Welcome to <span class="LogoTitle">TITLE!</span></h1>
<h2>Lorem ipsum bla bla bla i dont know bootstrap</h2>
</div>
</div>
</div>
</section>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
你能解释一下用import导入引导CSS的'link'替换吗?我从开发人员的网站获取 – Helle