如何在样式表中使用其他默认样式为IE编写CSS [英] How to write CSS for IE at stylesheet with other default styles
问题描述
我正在使用自适应网站。我已经使用媒体查询来做出负责任的事情。基本上,我没有使用任何固定宽度。我用百分比作为每个div的宽度。
I'm working with responsive website. I've used media queries for making that responsible. Basically, I haven't used any fixed width. I've used percentage as a width of every div.
因此,根据浏览器的大小调整,可以按比例缩放网站。对于使用宽度的百分比可能会导致老年人的问题。因为ie即9之前不支持媒体查询,所以,我想为那些构建不可扩展的版本即。由于我只提供了几个用于实现可伸缩性的代码,所以如果我使用我的默认CSS在我的主样式表下/在任何地方编写CSS代码也可以吗?
So that the website can be scaled proportionally according to resizing of browser. For using percentage of wide may be caused problem for older ie. As ie prior to ie 9 don't support media query, so, I want to build the non-scalable version for those ie. As I gave only few code for bringing scalability, so is it okay if I write the CSS code at my main stylesheet under/at anywhere with my default CSS?
喜欢在 style.css
:
#info {
width: 13.672%;
/*if ie9 and lower
width: 175px;*/
height: 830px;
/*if ie9 and lower
margin-right: 40px;*/
margin-right: 3.125%;
float: left;
}
img {
margin: 0px;
padding: 0px;
border: 0px;
max-width: 100%;
/*if ie9 and lower
max-width: inherit*/
height: auto;
/*if ie9 and lower
height: inherit*/
}
我想写那种格式。但是,我不知道正确的格式。请告诉我正确的格式。
I want to write that format. But, I don't know the correct format. Please, tell me the correct format.
另一个问题。由于那些版本的ie不支持媒体查询,因此元标记
Another question to you. As those version of ie don't support the media-query, so the meta tag
<meta name="viewport" content="width=device-width, maximum-scale=1.0, minimum-scale=1.0, initial-scale=1.0" />
<link href="KT2012.css" rel="stylesheet" type="text/css" />
<link href="kt_large.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" media="only screen and (min-width:50px) and (max-width:500px)" href="kt_small.css" />
<link rel="stylesheet" type="text/css" media="only screen and (min-width:501px) and (max-width:800px)" href="kt_tablet.css" />
<link rel="stylesheet" type="text/css" media="only screen and (min-width:801px) and (max-width:1024px)" href="kt_medium.css" />
tablet.css
, mobile.css
不要为那些旧版本创造任何问题,即不是吗?我的意思是我只想在我的主样式表( KT2012.css
)中编写IE特殊css。我应该在每个样式表上编写每个IE特殊的CSS,例如 mobile.css
, tablet.css
等?如果设计的基于css文件不支持较旧的ie,那么,如果我为ie制作不可扩展的版本,我不会对基于设备/视口的样式表做任何事情,不是吗?
with tablet.css
, mobile.css
don't create any problems for those older version ie, isn't it? I mean I want to write IE special css only at my main stylesheet (KT2012.css
). Should I write every IE special css at every stylesheet like at mobile.css
, tablet.css
etc? If that devised based css file don't support at older ie, so, I don't do any things with that device/viewport based stylesheet if I make non-scalable version for ie, isn't it?
推荐答案
I'd recommend the approach taken by the HTML5 boilerplate, outlined here by Paul Irish. Basically, set up your document like this:
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
现在您已准备好类,以准确定位某些版本的IE。你的css将如下所示:
You now have classes in place to accurately target only certain versions of IE. Your css will look like this:
.element { margin-bottom: 20px; }
.lt-ie9 .element { margin-bottom: 10px; }
然后你可以避免CSS攻击,并且可以将所有内容保存在一个样式表中。
You then avoid CSS hacks, and can keep everything in a single stylesheet.
这篇关于如何在样式表中使用其他默认样式为IE编写CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!