根据其中一个对象的内容控制容器宽度

时间:2015-06-18 23:15:34

标签: html css

我认为侥幸,这适用于Chrome。如何在所有浏览器中获得Chrome外观?理想情况下,容器宽度由中文文本和可能的拼音设置,但rubydef包裹。 JSFiddle:http://jsfiddle.net/tofutim/a10xm9s5/

enter image description here

<style>
#container {
    border: 1px solid #f00;
    margin: 0px;
    display:inline-block;
    display: table;
}
.text {
    margin: 0px;
    display: table-row;
    width:auto;
    font-size:36pt;
    line-height:115%;
    background: #ffcccc;
}
.pinyin {
    margin: 0px;
    display: table-cell;
    width: 1px;
    text-align: center;
    background: #ccccff;
}
.rubydef {
    margin: 0px;
    display: table-cell;
    width: 1px;
    text-align: center;
    font-style: italic;
    background: #ccffcc;
}

</style>
<p>
<div id='container'>
    <div class='pinyin'>tái bāo</div>
    <div class='text'>台胞</div>
    <div class='rubydef'>tomato is a good fruit i wish i could eat it this week</div>
</div>

1 个答案:

答案 0 :(得分:0)

我认为您遗失的唯一内容是white-space: nowrap;中的text

Fiddle