两个CSS的问题

28

Tags:, ,     No Comments »
第一个,让IE6支持min-width和max-width

#
// 说明:让 IE6 及其以下版本支持 CSS 中 min/max-width/height 属性
#
// minmax.js: make IE5+/Win support CSS min/max-width/height
#

#
/*@cc_on
#
@if (@_win32 && @_jscript_version>4)
#
#
var minmax_elements;
#
#
minmax_props= new Array(
#
new Array(’min-width’, ‘minWidth’),
#
new Array(’max-width’, ‘maxWidth’),
#
new Array(’min-height’,’minHeight’),
#
new Array(’max-height’,’maxHeight’)
#
);
#
#
// Binding. Called on all new elements. If , initialise; check all
#
// elements for minmax properties
#
#
function minmax_bind(el) {
#
var i, em, ms;
#
var st= el.style, cs= el.currentStyle;
#
#
if (minmax_elements==window.undefined) {
#
// initialise when body element has turned up, but only on IE
#
if (!document.body || !document.body.currentStyle) return;
#
minmax_elements= new Array();
#
window.attachEvent(’onresize’, minmax_delayout);
#
// make font size listener
#
em= document.createElement(’div’);
#
em.setAttribute(’id’, ‘minmax_em’);
#
em.style.position= ‘absolute’; em.style.visibility= ‘hidden’;
#
em.style.fontSize= ‘xx-large’; em.style.height= ‘5em’;
#
em.style.top=’-5em’; em.style.left= ‘0′;
#
if (em.style.setExpression) {
#
em.style.setExpression(’width’, ‘minmax_checkFont()’);
#
document.body.insertBefore(em, document.body.firstChild);
#
}
#
}
#
#
// transform hyphenated properties the browser has not caught to camelCase
#
for (i= minmax_props.length; i–>0;)
#
if (cs[minmax_props[i][0]])
#
st[minmax_props[i][1]]= cs[minmax_props[i][0]];
#
// add element with properties to list, store optimal size values
#
for (i= minmax_props.length; i–>0;) {
#
ms= cs[minmax_props[i][1]];
#
if (ms && ms!=’auto’ && ms!=’none’ && ms!=’0′ && ms!=”) {
#
st.minmaxWidth= cs.width; st.minmaxHeight= cs.height;
#
minmax_elements[minmax_elements.length]= el;
#
// will need a layout later
#
minmax_delayout();
#
break;
#
} }
#
}
#
#
// check for font size changes
#
#
var minmax_fontsize= 0;
#
function minmax_checkFont() {
#
var fs= document.getElementById(’minmax_em’).offsetHeight;
#
if (minmax_fontsize!=fs && minmax_fontsize!=0)
#
minmax_delayout();
#
minmax_fontsize= fs;
#
return ‘5em’;
#
}
#
#
// Layout. Called after window and font size-change. Go through elements we
#
// picked out earlier and set their size to the minimum, maximum and optimum,
#
// choosing whichever is appropriate
#
#
// Request re-layout at next available moment
#
var minmax_delaying= false;
#
function minmax_delayout() {
#
if (minmax_delaying) return;
#
minmax_delaying= true;
#
window.setTimeout(minmax_layout, 0);
#
}
#
#
function minmax_stopdelaying() {
#
minmax_delaying= false;
#
}
#
#
function minmax_layout() {
#
window.setTimeout(minmax_stopdelaying, 100);
#
var i, el, st, cs, optimal, inrange;
#
for (i= minmax_elements.length; i–>0;) {
#
el= minmax_elements[i]; st= el.style; cs= el.currentStyle;
#
#
// horizontal size bounding
#
st.width= st.minmaxWidth; optimal= el.offsetWidth;
#
inrange= true;
#
if (inrange && cs.minWidth && cs.minWidth!=’0′ && cs.minWidth!=’auto’ && cs.minWidth!=”) {
#
st.width= cs.minWidth;
#
inrange= (el.offsetWidth
#
}
#
if (inrange && cs.maxWidth && cs.maxWidth!=’none’ && cs.maxWidth!=’auto’ && cs.maxWidth!=”) {
#
st.width= cs.maxWidth;
#
inrange= (el.offsetWidth>optimal);
#
}
#
if (inrange) st.width= st.minmaxWidth;
#
#
// vertical size bounding
#
st.height= st.minmaxHeight; optimal= el.offsetHeight;
#
inrange= true;
#
if (inrange && cs.minHeight && cs.minHeight!=’0′ && cs.minHeight!=’auto’ && cs.minHeight!=”) {
#
st.height= cs.minHeight;
#
inrange= (el.offsetHeight
#
}
#
if (inrange && cs.maxHeight && cs.maxHeight!=’none’ && cs.maxHeight!=’auto’ && cs.maxHeight!=”) {
#
st.height= cs.maxHeight;
#
inrange= (el.offsetHeight>optimal);
#
}
#
if (inrange) st.height= st.minmaxHeight;
#
}
#
}
#
#
// Scanning. Check document every so often until it has finished loading. Do
#
// nothing until arrives, then call main init. Pass any new elements
#
// found on each scan to be bound
#
#
var minmax_SCANDELAY= 500;
#
#
function minmax_scan() {
#
var el;
#
for (var i= 0; i
#
el= document.all[i];
#
if (!el.minmax_bound) {
#
el.minmax_bound= true;
#
minmax_bind(el);
#
} }
#
}
#
#
var minmax_scanner;
#
function minmax_stop() {
#
window.clearInterval(minmax_scanner);
#
minmax_scan();
#
}
#
#
minmax_scan();
#
minmax_scanner= window.setInterval(minmax_scan, minmax_SCANDELAY);
#
window.attachEvent(’onload’, minmax_stop);
#
#
@end @*/

由于只有 IE6 及其以下版本不支持min/max-width/height 属性,因此,我们可以用下面的调用方式:

 

第二个是这样的。我来描述一下。一个DIV里左边是标题,比如叫做 title,右边是更多,比如用图片more表示。

+div:text-align:left;

-title

-more(img):float:right;

/div

一开始我偷懒的方式如下:DIV设置左对齐,然后more浮动向右。 结果,出现了一个问题:more被挤到下面一行了。在群里问了下,得知把titile 和 more 在源码里对调一下位置。也就是先写more再写title。如下:

+div:text-align:left;

-more(img):float:right;

-title

/div

之所以出现这样的问题,估计是titile文字被浏览器理解为inline效果了。

而后来又有了另外一个方法。给title 套一个 span。

+div:text-align:left;

-span title /span

-more(img):float:right;

/div

综合说来,第二个解决方法比较好,因为多了一个span就能更好的对 title 进行控制。

IE6的PNG BUG以及链接失效解决方法

28

Tags:, ,     No Comments »

先前的一个客户最近在套CMS标签了,需要我的配合。天啊,万恶的IE6开始作祟了。

我这边的电脑上只有IE7,没有IE6,没办法只好装了个绿色的。但是大家都知道,绿色的IE6在内核上依然是你机器上浏览器的内核(在我机器上就是IE7),也就是说绿色版的IE6其实是IE7和IE6的合体。而且在一些机器上绿色IE6经常不老实工作,比如,你打开6,输入一个地址,一回车,它就自动调用其他浏览器打开。

绿色IE6导致了我在制作的过程中,自己看着IE6没问题了,实际上用纯IE6去看的话,还是问题多多。询问了很多人,看有没有能完美解决IE6 IE7 共存的方法。但是好像除了虚拟机意外,没有其他的。 哎 真是万恶的IE6啊

附带一个IE6的PNG透明图的问题,网上找的JS方法和htc方法,我都实验了一下,不知道是方法的问题还是我愚笨,我都没搞出效果来。最后还是用了滤镜法。

教程的地址在这里

滤镜法的不爽之出还是挺多的,今天花了两个多小时来调试滤镜法所带来的链接失效问题。这里顺便总结下:
网上说在a标签里加一个postion:relative 就能解决,这个我实验了一下是可以的。但是,如果恰巧周围还有用定位法布局的地方,那就可能会互相影响,基本上只能用hack补救了。比如我遇到的这个

<div id=”nav(用了相对定位来确定位置的)”>

<li><a href=”#”>要处理的失效链接</a></li>

</div>

LOOK,是不是会比较麻烦。

哎,还是有时间研究下JS和HTC的方法吧。万恶的IE6!!!

绿色版IE6出现的一个问题

07

Tags:,     No Comments »

最近出现了这么一个问题。当我在页面里添加以<a href=“#”><img src=“…”/></a>的形式添加png图以后,在IE6加载这个页面时,图片是好好的。但是当加载完以后,图片就消失了,但是链接的区域还在,鼠标移上去依然显示链接状态。

在其他非绿色IE6上实验没有此问题。