html - 内嵌 block css

标签 html css

我希望多行文本像单个文本 block 一样环绕,例如下面的“Source”和“DEC”字段,而不使用表格。

enter image description here 我想我应该能够使用 inline-block 来让它工作,但我没有成功。

下面是我正在使用的简单 html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head id="head">
    <title></title>
    <style type="text/css">
       .tt { color: #7777cc; width:85px; }
       .cc { display: inline-block; }
</style>
</head>
<body>
    <div class="g1">
        <div class="expandable">
            <span class="tt">Source </span><span class="cc">Neutron energy was varied by changing the
                emission angle to the deuteron beam. The activities of the "2"3"7U and "2"3"1Th
                residual nuclei were measured by a Ge(Li) and a HP Ge gamma-spectrometer, respectively.</span>
        </div>
    </div>
</body>
</html>

最佳答案

你应该只使用 float 。

.expandable { overflow:hidden; } /* Clears floats */
.tt { float:left; width:85px; }
.cc { float:left; }

关于html - 内嵌 block css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5857124/

相关文章:

javascript - 在网页中保持相同图像大小的问题

javascript - 当用户在页面 javascript 或 php 中不活动 3 分钟时自动注销

图像的 Css UL LI 对齐

javascript - 如何在 JSFiddle 上创建具有可调整大小的行和列(如 HTML、CSS、JS 框)的表格?

javascript - 如何在谷歌地图中使用地址而不是经度和纬度?

css - 单击链接后我的悬停已停用

css - 悬停时 bootstrap .btn-default 的背景色是什么

javascript - 如何使用函数返回的对象?

css - ie7 条件覆盖不起作用

javascript - 什么是“menu2”的实现