You will have to use Javascript to do this, although CSS would be sufficient, but would be limited to the alignment of the text.
Utilize Jquey to facilitate.
Alignment will always be relative to the first element, so you can align it wherever you want.
See an example working: http://jsfiddle.net/719xowwv/
With the above script, just enter new sentences that will automatically be aligned.
As the link may one day not work, I leave here the complete code:
HTML:
<div class="textos">
<p>olá <span>1</span> beijo</p>
<p>beijo olá <span>1</span></p>
<p><span>1</span> beijo olá</p>
</div>
CSS:
.textos {
display: block;
float: left;
width: auto;
height: auto;
}
.textos p {
display: block;
float:left;
position: relative;
clear: both;
}
Javascript: (you need to include the Jquery library on your page)
var nPos;
$(document).ready(function(){
$(".textos p").each(function( index ) {
if(nPos==undefined){
nPos = $(this).find('span').position().left;
}else{
nCurrentPos = $(this).find('span').position().left;
$(this).css({'margin-left':(nPos-nCurrentPos)+'px'});
}
});
});
I believe you can use
position:relative
in the div containing the "1", andposition:absolute
on the items that will be on the side, if it is on the right, aright:0
if leftleft:0
or a value you want.– Felipe Viero Goulart