用背景色填充屏幕并设置文字大小
问题描述:
我有两个问题。用背景色填充屏幕并设置文字大小
背景颜色#eee不会延伸到屏幕的底部。我试过修改大量的容器,但它不会让步。我试过把HTML扩展到100%的高度。没有。
虽然我引用的是正确的类,但字形图标的大小不会达到100像素。
完整的HTML,从CSS的有关部分。
html {
font-family: sans-serif;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
height: 100%;
}
body {
margin: 0;
height: 100%;
background-color: #eee;
}
.call-to-action {
\t text-align: center;
color: #9D343D;
text-shadow: 1px 1px #fff;
}
.call-to-action p {
\t margin-bottom: 30px;
\t font-family: sans-serif;
color: #000;
}
.glyphicon-large {
\t font-size: 100px;
color: #9D343D;
text-shadow: 1px 1px #fff;
}
#wrapper {
background: #eee;
}
#body {
background: #eee;
}
#page-content-wrapper {
background: #eee;
}
}
<!DOCTYPE html>
<html lang="en">
<link href="https://fonts.googleapis.com/css?family=Kalam" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Indie+Flower" rel="stylesheet">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, shrink-to-fit=no, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Swindon Mela Home Page</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/simple-sidebar.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div id="wrapper">
<!-- Page Content -->
<div id="page-content-wrapper">
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div class="jumbotron container-fluid">
<h1>Swindon Mela</h1>
<p>Swindon Mela is a one day event to celebrate Indian culture in Swindon.</p>
<p>
<a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a></p>
</div>
<div class="container">
<section class="call-to-action">
\t <div class="row">
\t \t <div class="col-md-4">
\t \t \t <span class="glyphicon glyphicon-heart-empty" aria-hidden="true"></span>
\t \t \t <h3>Vibrant community</h3>
\t \t \t <p>Swindon Mela hosts a vibrant community.</p>
\t \t </div>
\t \t <div class="col-md-4">
\t \t \t <span class="glyphicon glyphicon-tree-deciduous glpyhicon-large" aria-hidden="true"></span>
\t \t \t <h3>Outdoors</h3>
\t \t \t <p>Swindon Mela is held outdoors with plenty of community offerings for the whole family.</p>
\t \t </div>
\t \t <div class="col-md-4">
\t \t \t <span class="glyphicon glyphicon-gbp glpyhicon-large" aria-hidden="true"></span>
\t \t \t <h3>Donate</h3>
\t \t \t <p>If you would like to become an official sponsor, please get in touch through our donation page!</p>
\t \t </div>
\t </div>
</section>
</div>
</div>
</div>
</div>
<div id="filler" class="fill">
<div class="section">
<div class="container">
<!-- This is filler -->
</div>
</div>
</div>
</div>
<!-- /#page-content-wrapper -->
</div>
<!-- /#wrapper -->
<!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.js"></script>
</body>
</html>
答
尝试:
#wrapper {
background: #eee;
min-height:100%;
}
编辑:
<html>
<body>
<div class='your_container'>
<div class='your_second_container'>
</div>
</div>
</body>
</html>
当您设置height:100%
HTML和正文,那么你可以设置min-height:100%
为第一个div(这里是your_container
)和它将填写至少100%的身高。当然你也可以设置min-height:100%;
身体当HTML有height:100%;
编辑图标:
<span class='glyphicon glyphicon-console my_icon'></span>
CSS:
.my_icon{
font-size:100px;
}
是否行得通?
PS。您在html中输入错误 - glpyhicon-large,但是您在CSS中使用.glyphicon-large ;-)
优秀!我摆脱了第一个包装,因为它没有做任何事情,而是将其添加到page-content-wrapper中。你能否解释一下CSS中的#是什么以及为什么这会起作用? – Aaraeus
它的工作原理是因为你为body和html设置了高度:100%,这意味着body和html应该有100%的文档高度,但是当它是空的或者没有完全填充时,它将只覆盖填充的空间。当您为第一个元素设置min-height:100%(并将html和body设置为height:100%)时,您的第一个div将至少覆盖文档高度的100%。 – Wordica