html - 如何使 anchor 填充适合div

标签 html css

干杯,我正在制作一个水平链接菜单。 我将父 div 的高度设置为 46px,并希望实现总高度为 46px 的 anchor 填充。

我该怎么做?

<div class="outside">
    <a href="#">FCC</a>
</div>
I'd like the green rectangle to fit inside parent div :)

.outside{
    width:100%;
    height:46px;
    background-color:red;
}

.outside a{
    float:left;
    text-decoration:none;
    background-color:green;
    padding-top:15px;
    padding-bottom:15px;
    font-size:16px;
}

有一些类似的问题,但没有一个包含填充(计算起来可能非常复杂)。

http://jsfiddle.net/T2Nqd/

注意:我希望链接在 padding 内保持居中,并且也能够将他的宽度保持在 200px 左右

最佳答案

试试这个

.outside a {
    float: left;
    padding: 13px 0px;
    text-decoration: none;
    background-color: green;
    font-size: 16px;
}

关于html - 如何使 anchor 填充适合div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23434828/

相关文章:

html - 嵌套 NgFor 在对象数组上循环

html - 如何删除页面顶部的边距

php - NextGEN Gallery 模板加载页面两次。?

css - 清理和合并内联 CSS 样式

CSS 表格和最小宽度容器?

css - 第三级 CSS 下拉菜单未以双列格式显示

html - 如何为不同尺寸的设备使用不同的导航栏类?

javascript - 如何使输入值得到验证?

javascript - 如何动态显示div部分动态列的值?

html - 使父容器拉伸(stretch)到宽度绝对定位的子容器,反之亦然