css - 具有 2 个跨度的 Div,居中 1,右对齐其他,但保持第一个居中

标签 css html

我有一个包含 2 个 span 的 div。我想让第一个跨度相对于 div 居中,并使第二个跨度右对齐(我正在使用 Bootstrap 中的右拉)。

在下面的 JSBin 中,您将看到我所追求的。我希望 Div1 中的“Hello”跨度与 Div2 中的位置相同。换句话说,我想将第一个跨度相对于父跨度居中,并且不受 div 中任何其他跨度的影响...

这是我的 jsbin:http://jsbin.com/cixun/1/

最佳答案

一个选择是相对于 div 绝对定位正确的 span:

http://jsbin.com/wuged/1/edit

.row{
  position: relative;
}

.right{
  position: absolute;
  right: 0;
}
<div class="row black center" >
   <span class="first">Hello</span>

   <span class="right">more text on the right</span>
</div>

关于css - 具有 2 个跨度的 Div,居中 1,右对齐其他,但保持第一个居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21791218/

相关文章:

java - 如何在生成的 Cell 的 UiBinder 中使用 CssResources?

javascript - 在网页上写乐谱

html - 如何让 body 取 100% min height 和 height as auto

html - 如何将图标与其标题或文字描述对齐?

html - 悬停图像 C 时更改图像 A 和 B

jquery - Ctrl+ 或 Ctrl- 时字体大小调整

CSS 媒体查询在移动设备上无法正常工作

html - 如何用颜色填充 100% 的网页

html - 内容出现在全宽视频背景的顶部而不是下方

css - HTML/CSS : Layout Issues