简体   繁体   English

使用CSS将文本左右对齐在同一行

[英]Align text to the left and right on the same line with CSS

I am working on my about page and having trouble with this. 我正在处理我的页面并遇到问题。 Trying to align the (years or pending) to the right side of the column. 尝试将(年份或待定)对齐到列的右侧。 See image for example. 例如,见图像。

Top is how it looks now. 顶部是它现在的样子。 Bottom image is how I want it to look. 底部图像是我想要的样子。

在此输入图像描述

Site is located at http://www.eatlovepray.me/portfolio/about-me/ 网站位于http://www.eatlovepray.me/portfolio/about-me/

尝试使用span然后设置样式等于'float:right'

<span style="float:right">pending </span>

Demo 演示

css CSS

ul {
    list-style: none;
}
#about ul li span {
    float: right;
}

html HTML

<div id="about">
     <h3><strong>Education</strong></h3>

    <ul>
        <li><strong>Golden West College – Huntington Beach, CA <span>2012-2014</span></strong>

        </li>
        <li>– Associate in Arts Degree – Digital Arts Major <span>(pending)</span>
        </li><br/>
        <li>Certificate of Achievement</li>
        <li>– Graphic Design and Production Option <span>(pending)</span>
        </li><br/>
        <li>Certificate of Specialization</li>
        <li>– Graphic Design Foundation <span>6/2014</span>
        </li>
        <li>– Graphic Design Advanced Production <span>(pending)</span>
        </li>
    </ul>
</div>

Here you go 干得好

<ul>
    &nbsp;&nbsp;<strong>Golden West College – Huntington Beach, CA <span style="float:right">2012-2014</span></strong><br>
&nbsp; &nbsp; – Associate in Arts Degree – Digital Arts Major <span style="float:right">(pending)</span><br>
<br>&nbsp; Certificate of Achievement<br>
&nbsp; &nbsp; – Graphic Design and Production Option <span style="float:right">(pending)</span><br>
<br>&nbsp; Certificate of Specialization<br>
&nbsp; &nbsp; – Graphic Design Foundation <span style="float:right">6/2014</span><br>
&nbsp; &nbsp; – Graphic Design Advanced Production <span style="float:right">(pending)</span><br>
</ul>

Here's a JSFiddle Click here 这是一个JSFiddle 点击这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM