Mar*_*c M 24 css twitter-bootstrap
我想开发一个自助服务终端应用程序,可以将自己扩展到完整触摸屏的100%.
当我为每个应用程序视图/模板嵌套行和列时,定义每一行和每一列以将高度设置为100%或更小(取决于嵌套元素)变得非常复杂.
这种情况是否有浮动布局?
下面是一些代码:
<div id="mmenu_screen" class="container-fluid main_container">
<div class="row">
<div class="col-sm-6">
<div class="row">
<div class="col-sm-12" id="mmenu_screen--book">
<!-- Button for booking -->
</div>
</div>
<div class="row">
<div class="col-sm-12" id="mmenu_screen--information">
<!-- Button for information -->
</div>
</div>
</div>
<div class="col-sm-6 mmenu_screen--direktaction">
<!-- Button for direktaction -->
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
继承人我想要制作的东西:
+------------------------------+small screen
|-------------+ +------------+ |
|| | | | |
|| | | | |
|| | | | |
|| | | | |
|-------------+ | | |
|-------------+ | | |
|| | | | |
|| | | | |
|| | | | |
|| | | | |
|-------------+ +------------+ |
+------------------------------+
+----------------------------------------+
|----------------------------------------|huge screen
|| || ||
|| || ||
|| || ||
|| || ||
|| || ||
|| || ||
|| || ||
|--------------------| ||
|--------------------| ||
|| || ||
|| || ||
|| || ||
|| || ||
|| || ||
|| || ||
|----------------------------------------|
+----------------------------------------+
Run Code Online (Sandbox Code Playgroud)
不是这样的(在小屏幕上看起来很好的布局现在看起来很短)
+----------------------------------+
| |
| +------------------------------+ |
| |--------------| | |
| +--------------| | |
| | || | |
| +------------------------------+ |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
+----------------------------------+
Run Code Online (Sandbox Code Playgroud)
zsa*_*waf 32
您所要做的就是在主容器/包装器上的高度为100vh,然后为子元素设置高度100%或50%..这取决于您要实现的目标.我尝试从基本的意义上复制你的模拟.
如果您想将内容集中在内,请查看flexbox.我为你举了一个例子.
您可以在全屏幕上查看它,并调整浏览器的大小并查看其工作原理.布局保持不变.
.left {
background: grey;
}
.right {
background: black;
}
.main-wrapper {
height: 100vh;
}
.section {
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.half {
background: #f9f9f9;
height: 50%;
width: 100%;
margin: 15px 0;
}
h4 {
color: white;
}Run Code Online (Sandbox Code Playgroud)
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="main-wrapper">
<div class="section left col-xs-3">
<div class="half"><h4>Top left</h4></div>
<div class="half"><h4>Bottom left</h4></div>
</div>
<div class="section right col-xs-9">
<h4>Extra step: center stuff here</h4>
</div>
</div>Run Code Online (Sandbox Code Playgroud)
Zim*_*Zim 12
以下是使用最新Bootstrap 4.0.0的答案.这种布局是使用更容易实现Flexbox和施胶工具类是在引导4.所有提供的这种布局是可能的非常一点额外的CSS.
#mmenu_screen > .row {
min-height: 100vh;
}
.flex-fill {
flex:1 1 auto;
}
<div id="mmenu_screen" class="container-fluid main_container d-flex">
<div class="row flex-fill">
<div class="col-sm-6 h-100">
<div class="row h-50">
<div class="col-sm-12" id="mmenu_screen--book">
<!-- Button for booking -->
Booking
</div>
</div>
<div class="row h-50">
<div class="col-sm-12" id="mmenu_screen--information">
<!-- Button for information -->
Info
</div>
</div>
</div>
<div class="col-sm-6 mmenu_screen--direktaction flex-fill">
<!-- Button for direktaction -->
Action
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
该flex-fill课程将在Bootstrap 4.1中提供
2021 Sep 您可以将根div设置为视口适合 100% 以及将其子级设置为预定义: 10,25,50,75%
<div class="vh-100">
<div class="h-50" >
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
谈论Bootstrap 4,5
| 归档时间: |
|
| 查看次数: |
57145 次 |
| 最近记录: |