我的div高於另一個,我用display:block
等等,但這是行不通的。我正在使用Vue js框架,我有一個鏈接到我的小提琴here如何讓兩個div低於彼此
我也在使用flex,但是也沒有解決它。我認爲flex 3會有所幫助,但事實並非如此。
代碼
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Countdown</title>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.1/vue.min.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="app">
<Countdown date="Februari 24, 2017 17:00"></Countdown>
</div>
<template id="countdown">
<div class="info">
<p class="title">KNHB</p>
<p class="description">Sprint 1</p>
</div>
<div class="timer">
<div class="block">
<p class="digit">{{ days | two_digits }}</p>
<p class="text">Days</p>
</div>
<div class="block">
<p class="digit">{{ hours | two_digits }}</p>
<p class="text">Hours</p>
</div>
<div class="block">
<p class="digit">{{ minutes | two_digits }}</p>
<p class="text">Minutes</p>
</div>
<div class="block">
<p class="digit">{{ seconds | two_digits }}</p>
<p class="text">Seconds</p>
</div>
</div>
</template>
</script>
<script src="vue.js"></script>
</body>
</html>
@import url(https://fonts.googleapis.com/css?family=Roboto+Condensed:400|Roboto:100);
#app {
align-items: center;
bottom: 0;
background-color: #34495e;
display: flex;
justify-content: center;
left: 0;
position: absolute;
right: 0;
top:0;
}
.info {
width: 50%;
height: 200px;
flex: 3;
}
.timer {
flex-direction: column;
}
.block {
display: flex;
flex-direction: column;
margin: 20px;
float:left;
}
.text {
color: #1abc9c;
font-size: 25px;
font-family: 'Roboto Condensed', serif;
font-weight: 400;
margin-top:10px;
margin-bottom: 10px;
text-align: center;
}
.digit {
color: #ecf0f1;
font-size: 130px;
font-weight: 100;
font-family: 'Roboto', serif;
margin: 10px;
text-align: center;
}
.title {
color: #ecf0f1;
font-size: 100px;
font-family: 'Roboto Condensed', serif;
font-weight: 400;
margin-top:10px;
margin-bottom: 10px;
text-align: center;
}
.description {
color: #ecf0f1;
font-size: 50px;
font-family: 'Roboto Condensed', serif;
font-weight: 40;
margin-top:10px;
margin-bottom: 10px;
text-align: center;
}
你想要什麼佈局?問題是「讓兩個div低於彼此」。這並不完全合理。一格必須在上面,一格必須在下面。而寬屏幕呢?如果屏幕夠寬,它們應該並排放置嗎?他們有不同的屏幕尺寸的最大寬度和/或最大高度?換句話說,您的要求有點含糊...... :-) – ADyson
請注意,不要將float:left;等浮標與flexbox混合使用。從'.block'中刪除'float:left;' –