简体   繁体   English

如何给DIV两个高度(一个用于IE,第二个用于其他浏览器)

[英]how to give two heights to DIV (one for IE and second for other browsers)

在CSS文件中,是否有一种方法可以为仅适用于Internet Explorer的DIV提供特定高度,同时为相同的DIV提供适用于除Internet Explorer之外的所有浏览器的另一个高度?

You can create an IE-specific stylesheet and use IE Conditional statements. 您可以创建特定IE的样式表并使用IE条件语句。

<!--[if IE]>
<link rel="stylesheet" type="text/css" href="iespecific.css" />
<![endif]-->

This way, you basically have two stylesheets; 这样,你基本上有两个样式表; one for IE and other for rest of the standard-compliant browsers. 一个用于IE,另一个用于其他符合标准的浏览器。

Hacks could have been used such as: 可以使用黑客 ,例如:

_height:500px;
*height:500px;

But that is not recommended. 但不建议这样做。

See Also: 也可以看看:

I have used the following and it worked in IE8. 我使用了以下内容,它在IE8中运行。 Put the following code within tag. 将以下代码放在标记中。

You can watch the online version from here, http://nazmulweb.com/site5/demo/iecss/ 您可以在此处观看在线版本, http://nazmulweb.com/site5/demo/iecss/

    <style type="text/css">
    #tgtDiv
    {
        height: 300px;
        width: 400px;
        border: 1px solid green;
    }
    </style>

     <!--[if IE]> 
         <style type="text/css">

     #tgtDiv
    {
        height: 300px;
        width: 400px;
        border: 5px solid red;
    }
    </style>
    <![endif]-->

try this 试试这个

<style>
    #mydiv { height:800px; }
</style>
<!--[if IE]>
<style>
    #mydiv { height:500px; }
</style>
<![endif]-->

Create 2 css files, one for IE and one for the other browsers 创建2个css文件,一个用于IE,另一个用于其他浏览器

Load the css file according to the browser like described here 根据此处描述的浏览器加载css文件

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何叠加两个宽度相同但高度不同的图像,一个固定,另一个滚动? - How to overlay two images of the same width but different heights, with one fixed and the other scrolling? 如何为IE和其他浏览器将此容器居中? - How to center this container for IE and other browsers? Div标签没有在IE中扩展..在所有其他浏览器中都可以 - Div tags not expanding in IE .. ok in all other browsers 如何正确编写媒体查询以在IE中使用一个样式表,在所有其他浏览器中使用另一个样式表? - How do I write the media query correctly to use one stylesheet in IE and another in all other browsers? 如果一个人的身高发生变化,如何改变所有div高度 - How to change all div heights if one's height changes 根据其他2个DIV高度设置DIV的高度 - Set the height of a DIV based on 2 other DIV heights 根据其他div高度增加div高度 - increase div heights based on the other div height 如何将两个div彼此分开放置? 第一div包含表单,第二div包含Google Map - How to place two divs besides each other? first div contain a form, second div contain google map IE6,7,8,9在另一个div下方加载div,而其他浏览器将其加载到右侧 - IE6,7,8,9 loading div underneath another div while other browsers load it to the right 如何一起给两个css类名,第二个css在页面渲染后删除? - How to give two css class name together ,second one is removed after page is rendered?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM