基于this example,我尝试使用flex CSS将内容水平居中,通常情况下它是正确的。但是,当内容很大时,左侧部分将隐藏起来。它发生在Chrome中,而水平滚动条则无济于事。如您在代码段中所见。我必须做些什么才能使其正确?
.flex-container {
padding: 0;
margin: 0;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
align-items: center;
justify-content: center;
}
.row {
width: auto;
border: 1px solid blue;
}
.flex-item {
background-color: tomato;
padding: 0px;
white-space: nowrap; /* added to simulate large content */
margin: 0px;
color: white;
font-weight: bold;
font-size: 2em;
text-align: left;
}
<div class="flex-container">
<div class="row">
<div class="flex-item">hidden.............................somewhere.....................................................................................................end</div>
<div class="flex-item">where</div>
<div class="flex-item">I</div>
<div class="flex-item">am?</div>
</div>
</div>
如您所见,这是使用flexbox解决此问题的另一种方式:here
答案 0 :(得分:0)
请尝试以下代码。
ConcurrentBag<T> list = new ConcurrentBag<T>();
Parallel.ForEach(listSource, entity =>
{
T entityCloned = GetEntityClone(entity); //Taking 800ms totally
if (entityCloned != null)
list.Add(entityCloned);
});
var listVersion = list.ToList();
html, body {
height: 100%;
}
body {
margin: 0;
}
.flex-container {
width: 100%;
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
}
.row {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
margin-right: -15px;
margin-left: -15px;
}
.flex-item {
background-color: tomato;
margin: 0px;
color: white;
font-weight: bold;
font-size: 2em;
text-align: left;
max-width: 100%;
flex-grow: 1;
padding-right: 15px;
padding-left: 15px;
}
答案 1 :(得分:0)
class Model extends Resource {
public async static get(): Promise<Model[]> {
return super.fetch({ url: 'custom-url?query=params' }) as Promise<Model[]>;
}
}
.flex-container {
padding: 0;
margin: 0;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
flex-direction:column;
align-items: center;
justify-content: center;
}
.flex-item {
background-color: tomato;
padding: 0px;
white-space: nowrap; /* added to simulate large content */
margin: 0px;
color: white;
font-weight: bold;
font-size: 2em;
text-align: left;
}