首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >垂直对齐中间与全屏幕div

垂直对齐中间与全屏幕div
EN

Stack Overflow用户
提问于 2014-09-22 20:57:52
回答 2查看 1.7K关注 0票数 0

实际上,我想做一个div全屏,里面的文字将垂直中间。我尝试了很多css,但没有完全工作,我想。我知道如果我把div修好了,它就会正常工作,但是我也想向下滚动到另一个div。

我希望我的项目看起来像(最初的全屏部分):http://perfectpointdev.com/perfect-design/

我想让灰色背景的一部分,我的项目作为perfectpointdev.com网站的初始部分。请帮帮我..。

我在jsfiddle中的演示项目:http://jsfiddle.net/zinannadeem/08wve09t/

代码语言:javascript
复制
#home{
  height:100%;
  display:table;
  min-height:100%;
  vertical-align:milddle;
  width:100%;
  position:relative;
}
.welcome-text{
  display:table-cell;
  position:relative;
  vertical-align:middle;
  z-index:3;
  text-align:center;
  color:#000;
  font-size:16px;
  background:#eee;
  z-index:99;
}
.welcome-text .container{
  max-width:800px;margin:0 auto;
}
代码语言:javascript
复制
<section id="home">
  <div class="welcome-text">
    <div class="container">
      <h2>We Are Awesome</h2>
      <p>Collaboratively administrate empowered markets via plug-and-play networks. Dynamically procrastinate B2C users after installed base benefits. Dramatically visualize customer</p>
    </div>
  </div>
</section>

<section id="about">
  <div class="container">
    <div class="row">
      <div class="col-md-12 text-center">
        <h2 class="page-title">Perfect design build awesome templates for you!</h2>
        <p>Collaboratively administrate empowered markets via plug-and-play networks. Dynamically procrastinate B2C users after installed base benefits. Dramatically visualize customer directed convergence without revolutionary ROI. Efficiently unleash cross-media information without cross-media value. Quickly maximize timely deliverables for real-time schemas. Dramatically maintain clicks-and-mortar solutions without functional solutions.</p>

        <p>Completely synergize resource sucking relationships via premier niche markets. Professionally cultivate one-to-one customer service with robust ideas. Dynamically innovate resource-leveling customer service for state of the art customer service.</p>

        <p><a class="btn btn-primary" href="">Buy It Now</a> <a class="btn btn-primary" href="">See WP Version</a></p>
      </div>
    </div>
  </div>
</section>	
<section id="about">
  <div class="container">
    <div class="row">
      <div class="col-md-12 text-center">
        <h2 class="page-title">Perfect design build awesome templates for you!</h2>
        <p>Collaboratively administrate empowered markets via plug-and-play networks. Dynamically procrastinate B2C users after installed base benefits. Dramatically visualize customer directed convergence without revolutionary ROI. Efficiently unleash cross-media information without cross-media value. Quickly maximize timely deliverables for real-time schemas. Dramatically maintain clicks-and-mortar solutions without functional solutions.</p>

        <p>Completely synergize resource sucking relationships via premier niche markets. Professionally cultivate one-to-one customer service with robust ideas. Dynamically innovate resource-leveling customer service for state of the art customer service.</p>

        <p><a class="btn btn-primary" href="">Buy It Now</a> <a class="btn btn-primary" href="">See WP Version</a></p>
      </div>
    </div>
  </div>
</section>	
<section id="about">
  <div class="container">
    <div class="row">
      <div class="col-md-12 text-center">
        <h2 class="page-title">Perfect design build awesome templates for you!</h2>
        <p>Collaboratively administrate empowered markets via plug-and-play networks. Dynamically procrastinate B2C users after installed base benefits. Dramatically visualize customer directed convergence without revolutionary ROI. Efficiently unleash cross-media information without cross-media value. Quickly maximize timely deliverables for real-time schemas. Dramatically maintain clicks-and-mortar solutions without functional solutions.</p>

        <p>Completely synergize resource sucking relationships via premier niche markets. Professionally cultivate one-to-one customer service with robust ideas. Dynamically innovate resource-leveling customer service for state of the art customer service.</p>

        <p><a class="btn btn-primary" href="">Buy It Now</a> <a class="btn btn-primary" href="">See WP Version</a></p>
      </div>
    </div>
  </div>
</section>

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-09-22 21:22:20

一个纯css解决方案:)

HTML

代码语言:javascript
复制
<div class="table blue">
<div class="tcell">Middle COntent 1</div>
</div>
<div class="table green">
<div class="tcell">Middle COntent 2</div>
</div>
<div class="table red">
<div class="tcell">Middle COntent 3</div>
</div>

CSS

代码语言:javascript
复制
body, html {
height: 100%;
padding: 0px;
margin: 0px;
}
.table {
display: table;
width: 100%;
height: 100%;
color: #ffffff;
}
.tcell {
display: table-cell;
vertical-align: middle;
text-align: center;
}
.blue {
background: blue;
}
.red {
background: red;
}
.green {
background: green;
}

在这里试试吧,http://jsfiddle.net/js4630fd/1/

票数 1
EN

Stack Overflow用户

发布于 2014-09-22 21:09:11

代码语言:javascript
复制
.center {
  position: absolute;
  width: 100px;
  height: 50px;
  top: 50%;
  left: 50%;
  margin-left: -50px;
  margin-top: -25px; 
}
代码语言:javascript
复制
<div class='full-screen'>
  <div class="center">FULL SCREEN</div>
</div>

尝试:JSFiddle

编辑:JSFiddle

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25982997

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档