我需要创建一个高度为120px的div。我只能使用 access_token;
getSubject(){
this.userService.access_token.subscribe(
token => {
this.access_token = token
});
return this.access_token;
}
setLogin(): Observable<any[]> {
this.getSubject();
const url = 'http://url';
const httpHeaders = new HttpHeaders()
.set('Authorization', 'Bearer ' + this.access_token);
return this.httpClient.post<any[]>(url, { headers: httpHeaders });
}
。我不能使用浮动。我只能使用div。
我有代码,但我不知道该怎么做:
display: flex
&#13;
.flex-container {
display: flex;
flex-wrap: wrap;
background-color: DodgerBlue;
width: 240px;
}
.flex-container>div {
background-color: #f1f1f1;
width: 60px;
height: 60px;
text-align: center;
line-height: 75px;
font-size: 30px;
}
&#13;
最终效果必须是:
答案 0 :(得分:-2)
使用CSS网格更容易做到这一点。试试这个:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="css/style.css">
<style>
.grid-container{
display: grid;
grid-template-columns: 50px 50px 50px 50px;
grid-template-rows: repeat(3, 50px);
}
.grid-item{
border: 1px solid black;
text-align: center;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
}
.bigger-cell{
grid-row-start: 1;
grid-row-end: span 2;
grid-column-start: 4;
}
</style>
</head>
<body>
<div class="grid-container">
<div class="grid-item">1</div>
<div class="grid-item">2</div>
<div class="grid-item">3</div>
<div class="grid-item bigger-cell">4</div>
<div class="grid-item">5</div>
<div class="grid-item">6</div>
<div class="grid-item">7</div>
<div class="grid-item">9</div>
<div class="grid-item">10</div>
<div class="grid-item">11</div>
<div class="grid-item">12</div>
</div>
</body>
</html>