【发布时间】:2017-09-03 23:44:35
【问题描述】:
一切正常,除了两个问题:
第二个 div 会根据需要增长和缩小,但当内容变得太大时,第二个 div 会稍微向左移动。
我不明白如何在 div 2 下方放置第 4 个 div(它也应该像 div 2 一样增长和缩小),同时将所有四个 div 保持在同一行,因为这是我第一次使用 flexbox 实现。例如:
第4个div应该在黑标的位置,文字和黑标都应该垂直居中。
html,
body {
background-image: url("../images/theme1.png");
background-repeat: repeat;
}
.conversationHeader {
background-color: rgba(255, 255, 255, 0);
border: none;
min-height: 60px;
display: block;
}
.headerOnScroll {
background-color: rgba(255, 255, 255, 1);
box-shadow: 0 4px 6px -3px rgba(0, 0, 0, 0.2);
}
.horizontalLayout {
width: 100%;
margin: 0!important;
padding: 0 9px!important;
height: 68px;
display: inline-flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
}
.conversationBackButton {
font-size: 24px;
width: 40px;
height: 40px;
padding: 8px!important;
margin-right: 16px;
color: #1D333E!important;
display: inline-flex;
}
.conversationDetails {
background-color: #cccccc;
font-family: robotoregular, 'sans-serif'!important;
font-size: 18px!important;
color: #546770;
flex-wrap: nowrap;
flex-grow: 1;
flex-shrink: 1;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
display: block;
}
.avatar {
min-width: 40px;
width: 40px;
height: 40px;
}
.composeMessageContainer {
background-color: white;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet"/>
<nav class="navbar navbar-fixed-top conversationHeader headerOnScroll">
<div class="container-fluid">
<div class="navbar-header horizontalLayout">
<a class="navbar-brand text-center conversationBackButton">
<span class="ionicons ion-android-arrow-back"></span>
</a>
<div class="conversationDetails">John Doe</div>
<img class="img-circle img-responsive avatar" src="images/dp.png">
</div>
</div>
</nav>
<div class="container-fluid navbar-fixed-bottom composeMessageContainer">
Text
</div>
【问题讨论】:
-
我看不到第 1 点。剩下什么变化?我用文本填充了第二个 div,但没有任何改变。 jsfiddle.net/r2df3jmj
-
对于第 2 点,您可以从顶行重复相同的布局。除了,在第二行,将
visibility: hidden添加到第一个和第三个 div。 -
否则,请考虑使用 CSS Grid 布局解决方案。
-
如果你真的填写了 looooooooooooooong 文本,那么它就会发生。
-
查看我发布的演示。我确实发布了长文本。没有任何改变。
标签: html css twitter-bootstrap-3 flexbox