html - css:在 td 顶部对齐跨度

标签 html css

我有一段代码,如下所示,

.RegCurrImage {
    background-color: rgba(0, 51, 102, 0.4) !important;
    line-height: 80px;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    border: solid 1px #003366;
    text-align: center !important;
}

.RegCurrImage span {
    position: relative;
    color: #003366;
    /*line-height:48px;*/
    font-size: 45px;
}
<table>
    <tbody>
        <tr>
            <td><div class="RegCurrImage"><span>1</span></div></td>
            <td><span>testing</span><span>testing</span></td>
        </tr>
    </tbody>
</table>

我的文字 (testing) 出现在中间我无法顶部对齐,

我想在不更改 RegCurrImage

的 css 的情况下从我的 RegCurrImage div 开始的位置对齐此跨度

喜欢下图THIS

我尝试了 verticle-align:top; 但这也没有帮助

我怎样才能做到这一点?

最佳答案

td 上添加 vertical-align:top;

td{vertical-align:top;}
.RegCurrImage {
    background-color: rgba(0, 51, 102, 0.4) !important;
    line-height: 80px;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    border: solid 1px #003366;
    text-align: center !important;
}

.RegCurrImage span {
    position: relative;
    color: #003366;
    /*line-height:48px;*/
    font-size: 45px;
    
}
<table>
    <tbody>
        <tr>
            <td><div class="RegCurrImage"><span>1</span></div></td>
            <td><span>testing</span><span>testing</span></td>
        </tr>
    </tbody>
</table>

关于html - css:在 td 顶部对齐跨度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53940782/

相关文章:

css - Bootstrap 3 : how do I change the width of 'a' tag exactly like the width of image it contains?

javascript - Jquery click 函数只被调用一次

javascript - 如何编写下拉选项来加载 JSON 文件?

html - float 到两侧的 CSS 标注流动不正确

html - CSS 网格中的元素拉伸(stretch)

javascript - CSS3/Jquery 泡泡动画

php - 如何在同一个表中使用php比较两列的值,如果值相同则为它们着色

javascript - 在提交表单之前在客户端散列密码的简单方法

html - 如何创建嵌套的CSS水平菜单?

html - CSS将文本移动到水平菜单上的新行