Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Internet explorer 围绕内联块跨度和Internet Explorer的链接_Internet Explorer_Html_Css - Fatal编程技术网

Internet explorer 围绕内联块跨度和Internet Explorer的链接

Internet explorer 围绕内联块跨度和Internet Explorer的链接,internet-explorer,html,css,Internet Explorer,Html,Css,以下内容在Chrome和Firefox中运行良好,并使容器可点击。在Internet Explorer中,它也可以单击,但只会更改光标以指示内部div,而不是span 我可以用光标:指针解决这个问题,但更重要的是,它不允许右键单击在新选项卡中打开 这个问题有解决办法吗?谢谢 <html> <head> <style type="text/css"> span{display:inline-block;width:100px}

以下内容在Chrome和Firefox中运行良好,并使容器可点击。在Internet Explorer中,它也可以单击,但只会更改光标以指示内部
div
,而不是
span

我可以用光标:指针解决这个问题,但更重要的是,它不允许右键单击在新选项卡中打开

这个问题有解决办法吗?谢谢

<html>
  <head>
    <style type="text/css">
       span{display:inline-block;width:100px}
    </style>
  </head>
  <body>
    <a href="/">
      <div>
        <div>title</div>
        <span>text</span><span>text</span>
      </div>
    </a>
  </body>
</html>

span{显示:内联块;宽度:100px}
IE(至少6个,我不确定更新版本)不支持原始内联元素(如
span
)上的
内联块。尝试在那里使用块元素

顺便说一句,除非您正在创建HTML5,否则块元素不允许出现在
a
元素中。这可能会导致不支持它的浏览器出现问题。

IE(至少6个,我不确定更新版本)不支持原始内联元素(如
span
)上的
inline block
。尝试在那里使用块元素


顺便说一句,除非您正在创建HTML5,否则块元素不允许出现在
a
元素中。这可能会导致尚不支持它的浏览器出现问题。

在内联级元素中包含块级元素是无效的

但是,至少在IE8中,您可以通过为页面提供doctype来解决问题。我已经使用了html5 doctype,但也许它也适用于其他人:

<!doctype html>
<html>
  <head>
    <style type="text/css">
       span{display:inline-block;width:100px}
    </style>
  </head>
  <body>
    <a href="/">
      <div>
        <div>title</div>
        <span>text</span><span>text</span>
      </div>
    </a>
  </body>
</html>

span{显示:内联块;宽度:100px}

顺便说一句,在html5中,像您一样使用
a
标记是有效的。

在内联级元素中包含块级元素是无效的

但是,至少在IE8中,您可以通过为页面提供doctype来解决问题。我已经使用了html5 doctype,但也许它也适用于其他人:

<!doctype html>
<html>
  <head>
    <style type="text/css">
       span{display:inline-block;width:100px}
    </style>
  </head>
  <body>
    <a href="/">
      <div>
        <div>title</div>
        <span>text</span><span>text</span>
      </div>
    </a>
  </body>
</html>

span{显示:内联块;宽度:100px}

顺便说一句,在html5中,像您一样使用
a
标记是有效的。

您的HTML是无效的,尽管浏览器按照您的预期操作,但这永远不会验证

对于可单击的div,您可以使用jQuery执行您想要的操作:

$(function (){
    $("#clickme").click(function(event) {
        event.preventDefault();
        window.open('http://www.whatever.com');
    });
});

您的HTML无效,尽管浏览器按照您的预期操作,但这将永远无法验证

对于可单击的div,您可以使用jQuery执行您想要的操作:

$(function (){
    $("#clickme").click(function(event) {
        event.preventDefault();
        window.open('http://www.whatever.com');
    });
});

下面是我如何实现标题的可点击横幅。如果背景图像大于h1链接,下面的段落将显示在横幅上。我想这就是你想要实现的

<!DOCTYPE html>
<html>
  <head>
    <title>Banner Example</title>
    <style type="text/css">
      #header {
        background-image: url('header_banner.jpg');
      }

      h1 a {
        display: block;
        height: 120px;
        width: 500px;
        text-indent: -9999; /* to hide the text that would show */
                            /* over the banner */
      }
    </style>
  </head>
  <body>
    <div id='header'>
      <h1><a href="/">This is a header link.</a></h1>
      <p>Here is some text.</p><p>Here is some more text.</p>
    </div>
  </body>
</html>

横幅示例
#标题{
背景图片:url('header_banner.jpg');
}
H1A{
显示:块;
高度:120px;
宽度:500px;
文本缩进:-9999;/*隐藏将显示的文本*/
/*横幅上方*/
}
这里有一些文字。

这里还有一些文字


这验证为html5,并为您提供了更多的灵活性。你可以有一个仍然链接的标题横幅,并且在标题区域中有任意数量的其他元素,甚至是其他链接。

以下是我如何实现标题的可点击横幅。如果背景图像大于h1链接,下面的段落将显示在横幅上。我想这就是你想要实现的

<!DOCTYPE html>
<html>
  <head>
    <title>Banner Example</title>
    <style type="text/css">
      #header {
        background-image: url('header_banner.jpg');
      }

      h1 a {
        display: block;
        height: 120px;
        width: 500px;
        text-indent: -9999; /* to hide the text that would show */
                            /* over the banner */
      }
    </style>
  </head>
  <body>
    <div id='header'>
      <h1><a href="/">This is a header link.</a></h1>
      <p>Here is some text.</p><p>Here is some more text.</p>
    </div>
  </body>
</html>

横幅示例
#标题{
背景图片:url('header_banner.jpg');
}
H1A{
显示:块;
高度:120px;
宽度:500px;
文本缩进:-9999;/*隐藏将显示的文本*/
/*横幅上方*/
}
这里有一些文字。

这里还有一些文字


这验证为html5,并为您提供了更多的灵活性。您可以有一个标题横幅,它仍然链接,并且标题区域中有任意数量的其他元素,甚至其他链接。

这是无效的HTML,不能在标题中包含div,这在语义上是错误的。你必须先改变这一点,有一些方法可以让div可以点击。凯尔:这的确是错误的,但IE对此没有问题。在其他情况下进行了测试。@Kyle:对于HTML5,现在在锚标记中包装块级元素(如div)在语义上没有错误。这是无效的HTML,不能在锚标记中包含div,这在语义上是错误的。你必须先改变这一点,有一些方法可以让div可以点击。凯尔:这的确是错误的,但IE对此没有问题。在其他情况下进行过测试。@Kyle:在HTML5中,在锚定标记中包装块级元素(如div)在语义上并没有错误。这或多或少有效,但仍然不支持右键单击。@pdknsk当html无效时,结果在不同的浏览器中往往是不可预测的……这或多或少有效,但它仍然不支持右键单击。@pdknsk当html无效时,不同浏览器之间的结果往往是不可预测的。。。