在居中元素(div)之前插入元素(div)

时间:2019-01-18 00:00:19

标签: html html5

我有一个居中的固定宽度div

 --------Centered Text--------

我想在居中的div之前附加另一个具有右对齐文本的div。

 This is Centered Text------

编辑: 我更新了jsfiddle代码,因此它不会处于这种混乱的状态。

我尝试了许多不同的方法,最终发布了一个凌乱的示例。下面的代码显示了我正在尝试做的事情。

<div class="text-entry" style="
                          display:flex;
                          justify-content: center;
                          background-color:grey;
                          ">
                           
<div style="display:inline-block; width:100px; text-align:right; background-color:red;">My-</div>
   <div style="background-color:white; ">Text</div>
   <div style="display:inline-block; width:100px;"></div>
   
</div>

<!--- ------------------- -->

<div class="text-entry" style="background-color:grey;text-align:center;">

   <div style="display:inline-block; background-color:white; ">
 Text
  </div>
</div>

我的问题是代替两个固定宽度的内联块来实现此目的的正确方法是什么?

*对不起,我缺乏技能。我这样做是出于业余爱好,而不是专业。感谢您的帮助。我来这里之前已经在Google上搜索过。

0 个答案:

没有答案
相关问题