使span标签覆盖div的整个宽度 [英] making span tag cover entire width of div

查看:673
本文介绍了使span标签覆盖div的整个宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对html具有以下结构:-

I have the following structure for html:-

<div>
  <span>
    <a href="wherever">Wherever</a>
  </span>
</div>

如果我想让跨度覆盖div的整个宽度,我该如何在chrome中做到这一点?

If I want the span to cover the entire width of the div, how can I do that in chrome?

我在CSS中尝试过使用

I tried in css using

span{
  background:#FFF;
  width:100%;
}

它在Firefox中有效,但在chrome中不可用。

It works in firefox and ie but not in chrome.

推荐答案

span 元素是内联的。内联元素自动调整其宽度,并忽略您的 width:表达式。

span elements are inline. Inline elements adjust their width automatically and ignore your width: expressions.

将其设为块级:

span {
    display: block;
}

但是,基本上它只是< div>

这篇关于使span标签覆盖div的整个宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆