Mic*_*ait 22 html css semantic-ui
我似乎无法在文档中的任何地方找到它.
有没有办法使用Semantic-UI语义垂直居中页面上的div :)
这是我正在尝试做的事情:
<div class="ui centered grid">
<div class="eight column wide">
<div>I want to be centered vertically on a page</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
Uda*_*ale 41
http://semantic-ui.com/examples/grid.html
使用middle aligned课程grid
我刚刚通过使用middle和设置高度来实现这一点:
.holder {
height: 400px
}
.holder .middle {
height: 100%
}Run Code Online (Sandbox Code Playgroud)
<link href="https://raw.githubusercontent.com/Semantic-Org/Semantic-UI/master/dist/semantic.css" rel="stylesheet" />
<div class="holder">
<div class="ui middle aligned grid">
<div class="eight column wide">
<div>I want to be centered vertically on a page</div>
</div>
</div>
</div>Run Code Online (Sandbox Code Playgroud)
小智 5
这个问题被报道HERE 2018年初但收盘。
但是,您可以尝试以下操作:
<div id="my-container" class="ui grid middle aligned">
<div class="row">
<div class="column">
<div class="ui text container segment inverted">
<h1>My DIV</h1>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
确保您的容器足够高
#my-container {
background: #000;
height: 100vh;
width: 100%;
}
Run Code Online (Sandbox Code Playgroud)
在JSFiddle上尝试一下:https ://jsfiddle.net/Peyothe/6rjmdu1x/