0

如何在具有动态宽度的内联元素旁边设置浮动元素

演示:http: //jsfiddle.net/J2Df8/

html

<div>
<span>Lorem ipsum dolor</span>
<span class="floater"></span>
</div>

css

DIV{
    width: 100px;
}


SPAN.floater{
    height:4px;
    width:4px;
    margin-top:3px;
    float:left;
    background-color: #FF0000;
}

在此处输入图像描述

4

2 回答 2

1

看看这个http://jsfiddle.net/J2Df8/12/

HTML

<div>
    <span>Lorem ipsum dolor<span class="floater"></span></span>    
    <span>Lorem ipsum dolor<span class="floater"></span></span> 
</div>

CSS

div {
    width: 100px;
}

div span {
    display:inline-block;
    position:relative;
    padding-right:10px;
}


span.floater{
    display:block;
    padding:0;
    height:4px;
    width:4px;
    top:8px;
    right:0;
    position:absolute;
    background-color: #FF0000;
}
于 2012-10-26T11:13:46.200 回答
0

HI 现在习惯了:after在你的跨度

像这样

span{
    width: 100px;
    display:block;
}


span:after{
    content:'';
    height:4px;
    display:inline-block;
    width:4px;
    background-color: #FF0000;
}

现场演示

于 2012-10-26T11:07:42.130 回答