内联元素的边框

时间:2015-10-01 05:56:23

标签: javascript jquery html css css3

我必须为div元素应用边框。由于div元素是内联的,因此边框重叠。

Example fiddle link.

预期产出:

<span class="label_no" title="Label Editing not allowed">1.</span>
<div class="Heading">Heading Text Goes Here.....Heading Text Goes Here.....Heading Text Goes Here.....</div>

需要标签&amp;标题应该在同一行,而标题应该单独标题。

3 个答案:

答案 0 :(得分:4)

你可以尝试这个:

      .Heading{
    font-family: Georgia,"New Century Schoolbook",serif;
    font-size: 1.4em;
    letter-spacing: 0.02em;
    line-height: 1em;
    display:inline;
    border:1px solid green;
    margin: 0;
    padding: 5px;
    position:fixed;
    top:0px;
}
.label_no{
    font-size: 1.5em;
    color:red;
}
}

DEMO

又一个例子:

DEMO

答案 1 :(得分:1)

使用此方法为display:table添加display:table,为文本添加.Heading { font-family: Georgia, "New Century Schoolbook", serif; font-size: 1.4em; letter-spacing: 0.02em; line-height: 1em; display: table; border: 1px solid green; margin: 0.5em 0; padding-top: 5px; } .label_no { font-size: 1.5em; color: red; float: left; }   - 通过设置<span class="label_no" title="Label Editing not allowed">1.</span> <div class="Heading">Heading Text Goes Here.....Heading Text Goes Here.....Heading Text Goes Here.....</div> <span class="label_no" title="Label Editing not allowed">1.</span> <div class="Heading">Heading Text Goes Here.....Heading Text Goes Here.....Heading Text Goes Here.....</div> <span class="label_no" title="Label Editing not allowed">1.</span> <div class="Heading">Heading Text Goes Here.....Heading Text Goes Here.....Heading Text Goes Here.....</div>,它需要可用空间

&#13;
&#13;
File &File::operator << ( const char *pszData )
{
    if( m_bBinary )
        do m_pkStream->write( pszData, 1 ); while( *pszData++ );
    else
        *m_pkStream << pszData;

    return( *this );
}
&#13;
"Content Type multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:901bc2e6-6d57-4363-9f99-41ca4884ce16+id=1";start-info="text/xml" was not supported by service https://URL_OF_Service/.  The client and service bindings may be mismatched."
&#13;
&#13;
&#13;

答案 2 :(得分:0)

您需要在span元素上使用浮动,例如

.label_no{
    font-size: 1.5em;
    color:red;
    float:left;    
} 

.Heading{
    font-family: Georgia,"New Century Schoolbook",serif;
    font-size: 1.4em;
    letter-spacing: 0.02em;
    line-height: 1em;
    display:inline;
    border:1px solid green;
    margin: 0.5em 0;
    padding-top: 5px;
}
.label_no{
    font-size: 1.5em;
    color:red;
    float:left;    
}
<span class="label_no" title="Label Editing not allowed">1.</span>
<div class="Heading">Heading Text Goes Here.....Heading Text Goes Here.....Heading Text Goes Here.....</div>