
Let’s say we have P, Q,R,S,T aligned in the center of a web page −
P Q R S T
我们希望上述内容保持不变,除了最右边的即T向右移动,像这样−
P Q R S T
现在让我们看一些例子来实现我们上面看到的。
Center one and right/ left align other flexbox element with auto margins
Example
的中文翻译为:示例
通过使用自动边距和一个新的、不可见的 flex 项,可以在网页上实现上述布局 −
立即学习“前端免费学习笔记(深入)”;
Example
- T
- P
- Q
- R
- S
- T
Center one and right/ left align other flexbox element with pseudo element
在这个例子中,我们将使用与 T 相同宽度的伪元素。使用 ::before 将其放置在容器的开头。
Example
的中文翻译为:示例
让我们现在来看一个例子−
Example
- P
- Q
- R
- S
- T
Center one and right/ left align other flexbox element with Grid Layout
In this example, create a grid with multiple columns. Then position your items in the middle and end columns.
Example
的中文翻译为:示例
让我们现在来看一个例子−
Example
- P
- Q
- R
- S
- T











