我實際上在學習如何使用bootstrap進行編碼,而且發生了一些非常奇怪的事情。 我想建立一個標題行和中間行的基本模板。 中間的行在背景上必須是灰色的,而在中心(內容在哪裏)是白色的。 中間一行有一個flex-grow,這樣背景顏色無處不在,不僅取決於內容大小。 但是,當這個內容很大時,它會溢出行,我不知道爲什麼。塊滿溢父塊
這是我的代碼:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Potatoe Home</title>
<link rel="stylesheet" href="path/to/file/file.css" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body class = "container-fluid">
<div class = "row titleRow">
<div class = "col-sm-3">
</div>
<div class = "col-sm-6">
<div id="titleArea">
<h1 id="title">Potatoe</h1>
<p>blablabla</p>
</div>
</div>
<div class = "col-sm-3">
</div>
</div>
<div class = "row scndRow">
<div class = "col-sm-3">
</div>
<div class = "col-sm-6 middleColumn">
<div id="testBlock">
</div>
</div>
<div class = "col-sm-3">
</div>
</body>
</html>
我的CSS:
h1[id=title]
{
font-size: 200%;
}
.titleRow
{
background-color: red;
color: white;
font-size: 200%;
}
.scndRow
{
flex-grow: 1;
display: flex;
background-color: #D0D0D0;
}
.middleColumn
{
background-color: white;
}
#testBlock
{
width: 20%;
height: 900px;
background-color: blue;
}
html, body
{
height: 100%;
}
body
{
display: flex;
flex-direction: column;
}
感謝您的幫助
你能舉一個例子,在這種情況下,它溢出?所以我們現在正是你想要阻止的。 – ScientiaEtVeritas
當testBlock的高度太高而無法在屏幕上完全看到時。然後我使用滾動條,我們可以在屏幕截圖中看到溢出。實際上更明顯的是: .middleColumn { \t background-color:green; } - > http://imgur.com/a5oLMI8 其中一個問題是,這種溢出不會發生在每個瀏覽器上,實際上只是在我的Chrome上 – FTW