例如,我想要以下格式
Nov/1 2013
This is a sunny day
Nov/12 2013
A friend visits my home
...
日期行right
对齐,而内容行left
对齐。
我试过<div>
了,它在两行之间增加了额外的空间。
看到这个JSFIDDLE
那是你要找的吗?
HTML
<p class="paragraph">
<span class="right-aligned">Nov 13</span>
This is a sunny day
</p>
CSS
.paragraph {
display: inline-block;
}
.right-aligned {
display: block;
text-align: right;
width: 100%;
}
在此解决方案中定义段落的宽度是可选的。
这
<div id="box">
<p class="text-right">Nov/1 2013</p>
<p class="text-left">This is a sunny day</p>
<div style="clear: both"></div>
</div>
和
#box{
width: 150px;
border: 1px solid;
}
.text-left{
float: left;
}
.text-right{
float: right;
}
p{
margin:0;
padding:0;
}
应该做的伎俩!
试试这个,
jsfiddle:http: //jsfiddle.net/RaLwc/1/
<div class="cont">
<span class="right">Nov/1 2013</span>
<span class="left">This is a sunny day</span>
<span class="right">Nov/12 2013</span>
<span class="left">A friend visits my home</span>
</div>
.cont
{
width:145px;
height:auto;
float:left;
}
.cont span
{
width:100%;
height:auto;
float:left;
}
.right{
text-align:right;
}
.left{
text-align:left;
}
<div align="right">Nov/1 2013<br/>
This is a sunny day
</div>
产生:
2013 年 11 月 1 日