-1

我需要更新一些预先存在的代码。

css => array(
    'body' => 'overflow-x:hidden;',
    '#wrapper' => 'width:500px;'
)

我假设=>建议它以 PHP 格式完成。

我需要做的是添加一个 IE8 css hack,我试过这个但无济于事:

css => array(
    'body' => 'overflow-x:hidden;',
    '#wrapper' => 'width:500px;',
    '<!--[if IE 8]>#rightcol' => 'width:200px;<![endif]-->'
)

有人可以帮我解决这个问题吗?

4

2 回答 2

1

在您的 HTML 中,将您的开始正文标记从<body>, 更改为:

<!--[if IE 8]><body class="ie8"><![endif]-->
<!--[if ! IE 8]<!--><body><!--<![endif]-->

然后你可以.ie8在任何 css 选择器之前放置以使其仅在 ie8 中工作:

css => array(
    'body' => 'overflow-x:hidden;',
    '#wrapper' => 'width:500px;',
    '.ie8 #rightcol' => 'width:200px;'
)
于 2012-05-30T01:54:57.990 回答
0

这个数组很可能被注入(从某种意义上说)到你的 css 代码中。如果您知道(通过查看加载的php 页面的源代码)是这种情况,那么那里的 HTML 注释对您不起作用,因为它会尝试在 css 部分中编写这些注释,这是无效的。

你需要让它为那个 IE8 条件重写一个重复的 css。所以你将拥有:

<style type="text/css">
/* this part is filled by your array values */
</style>

<!--[if IE 8]-->
<style type="text/css">
/* this part is the IE8 hack */
</style>
<!--[endif]-->

这将需要并包含另一个样式标签。

于 2012-05-30T01:57:15.597 回答