如何使表内的div与文本里面的文本大小相同?

时间:2015-06-26 18:34:09

标签: html css styling

如何使内部表格与文本内部相同:

<table class="table-1">
        <tr>
            <td align="center">
                <div class="block" id="block-1" style="background: black">
                    <a style="color: black" href="myFunc()"><c:out
                            value="${item.title}" /></a>
                </div>
            </td>
        </tr>
</table>

的CSS:

table.table-1 {
    width: 100%;
}

如何使<div class="block" id="block-1" style="background: black">取大小

<a style="color: black" href="myFunc()"> <c:out value="${item.title}"/> </a>

enter image description here

1 个答案:

答案 0 :(得分:1)

display: inline-block;用于.block

table.table-1 {
    width: 100%;
}
.block{
    display: inline-block;    
}
<table class="table-1">
        <tr>
            <td align="center">
                <div class="block" id="block-1" style="background: black">
                    <a style="color: #fff" href="myFunc()">text text text</a>
                </div>
            </td>
        </tr>
</table>