【问题标题】:Cover page height set to 100% has it halfway封面页高度设置为 100% 有一半
【发布时间】:2018-07-04 17:12:06
【问题描述】:

我一直在尝试实现一个引导封面页模板,但我很难设置它。我确实能够从 bootstraps 网站将代码复制到我的,这导致封面页占据了一半的高度。在样式中,它显然有 height: 100%,但是如果我将高度更改为不同的百分比,它根本不会影响它。但是,如果我将高度更改为 740 像素,它最终会成为我屏幕的相对高度,但这会在未来出现问题。为什么高度百分比不会影响呢?

a,
a:focus,
a:hover {
  color: #fff;
}

/* Custom default button */
.btn-secondary,
.btn-secondary:hover,
.btn-secondary:focus {
  color: #333;
  text-shadow: none; /* Prevent inheritance from `body` */
  background-color: #fff;
  border: .05rem solid #fff;
}


/*
 * Base structure
 */

html,
body {
  height: 740px;
  background-color: #aaa;
}

body {
  display: -ms-flexbox;
  display: -webkit-box;
  display: flex;
  -ms-flex-pack: center;
  -webkit-box-pack: center;
  justify-content: center;
  color: #fff;
  text-shadow: 0 .05rem .1rem rgba(0, 0, 0, .5);
  box-shadow: inset 0 0 5rem rgba(0, 0, 0, .5);
}

.cover-container {
  max-width: 42em;
}


/*
 * Header
 */
.masthead {
  margin-bottom: 2rem;
}

.masthead-brand {
  margin-bottom: 0;
}

.nav-masthead .nav-link {
  padding: .25rem 0;
  font-weight: 700;
  color: rgba(255, 255, 255, .5);
  background-color: transparent;
  border-bottom: .25rem solid transparent;
}

.nav-masthead .nav-link:hover,
.nav-masthead .nav-link:focus {
  border-bottom-color: rgba(255, 255, 255, .25);
}

.nav-masthead .nav-link + .nav-link {
  margin-left: 1rem;
}

.nav-masthead .active {
  color: #fff;
  border-bottom-color: #fff;
}

@media (min-width: 48em) {
  .masthead-brand {
    float: left;
  }
  .nav-masthead {
    float: right;
  }
}


/*
 * Cover
 */
.cover {
  padding: 0 1.5rem;
}
.cover .btn-lg {
  padding: .75rem 1.25rem;
  font-weight: 700;
}


/*
 * Footer
 */
.mastfoot {
  color: rgba(255, 255, 255, .5);
} 

【问题讨论】:

  • 您应该始终发布所有相关代码以获得良好的解决方案,请将您正在使用的 html 代码添加到问题中,和/或制作一个显示您的问题的小提琴
  • 你认为body { height: 740px; } 会做什么,Betzel?

标签: html css angular bootstrap-4


【解决方案1】:

你可以试试这个

html, body {
    height: 100vh;
    min-height: 100vh;
    background-color: #aaa; 
}

【讨论】:

  • 谢谢!这解决了我的问题。我想知道为什么 100% 不起作用..
猜你喜欢
  • 2014-01-24
  • 2021-07-13
  • 1970-01-01
  • 1970-01-01
  • 2013-03-28
  • 1970-01-01
  • 2013-07-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多