使链接文本与链接背景的高度相同

时间:2016-05-29 14:43:21

标签: html css

似乎很简单,但我似乎无法做到这一点,我想让我的链接文本与链接背景的高度相同。

func main() {
    ts := &Timespan{ID: 102, StartDate: time.Now().AddDate(6, 0, 0), EndDate: time.Now().AddDate(8, 0, 0)}
    m := map[string]interface{}{
        "key": ts,
    }
    switch v := m["key"].(type) {
    case Timespaner:
        fmt.Println(v.Value())
    default:
        fmt.Println("wtfmate?")
    }
}

func (ts *Timespan) Value() (id uint8, start, end time.Time) {
    return ts.ID, ts.StartDate, ts.EndDate
}

type Timespaner interface {
    Value() (id uint8, start, end time.Time)
}

问题是文本周围总是存在边距

2 个答案:

答案 0 :(得分:0)

我认为这是因为您使用的是text-decoration: underline。 如果删除height: 30px,则该块将重新设置为字体大小。

以下是示例:emulatesWidth static height

或者您可以设置text-decoration: none然后它将适合该块。

这是你想要的吗?如果没有,请提供一些说明截图。

答案 1 :(得分:0)

font-size不反映文本占用的物理高度,您还必须考虑下降。您可以设置line-height

{{1}}

(你应该使用样式表而不是内联样式,虽然这可能只是为了证明这个问题?)

设置行高确实会使这个小例子的高度设置变得多余,并且通常行高大于字体大小,默认大约为1.2。

相关问题