- IE6 does not support min-height, the solution is to use css hack:
.target {
min-height: 100px;
height: auto !important;
height: 100px; // IE6下内容高度超过会自动扩展高度
}
-
ol
The serial numbers insideli
are all 1 and do not increment. Workaround: style the lidisplay: list-item;
-
The parent element is not positioned
overflow: auto;
, containsposition: relative;
child elements, and overflows when the child element is higher than the parent element. Solution: 1) The child element is removedposition: relative;
; 2) When the positioning cannot be removed for the child element, the parent elementposition: relative;
<style type="text/css">
.outer {
width: 215px;
height: 100px;
border: 1px solid red;
overflow: auto;
position: relative; /* 修复bug */
}
.inner {
width: 100px;
height: 200px;
background-color: purple;
position: relative;
}
</style>
<div class="outer">
<div class="inner"></div>
</div>
- IE6 only supports pseudo-classes of
a
labels. The:hover
solution: use js to monitor mouseenter and mouseleave events for elements, and add classes to achieve the effect:
<style type="text/css">
.p:hover,
.hover {
background: purple;
}
</style>
<p class="p" id="target">aaaa bbbbb<span>DDDDDDDDDDDd</span> aaaa lkjlkjdf j</p>
<script type="text/javascript">
function addClass(elem, cls) {
if (elem.className) {
elem.className += ' ' + cls;
} else {
elem.className = cls;
}
}
function removeClass(elem, cls) {
var className = ' ' + elem.className + ' ';
var reg = new RegExp(' +' + cls + ' +', 'g');
elem.className = className.replace(reg, ' ').replace(/^ +| +$/, '');
}
var target = document.getElementById('target');
if (target.attachEvent) {
target.attachEvent('onmouseenter', function () {
addClass(target, 'hover');
});
target.attachEvent('onmouseleave', function () {
removeClass(target, 'hover');
})
}
</script>
- IE5-8 does not support
opacity
, the solution:
.opacity {
opacity: 0.4
filter: alpha(opacity=60); /* for IE5-7 */
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=60)"; /* for IE 8*/
}
- When IE6 is set to
height
less thanfont-size
the height valuefont-size
, the solution:font-size: 0;
- IE6 does not support PNG transparent background, solution: use gif image under IE6
- IE6-7 does not support
display: inline-block
the solution: set inline and trigger hasLayout
display: inline-block;
*display: inline;
*zoom: 1;
- Under IE6, the margin of a floating element in the floating direction that touches the border of the parent element doubles. Solution: 1) Use padding to control the spacing. 2) Floating elements
display: inline;
solve the problem in this way without any side effects: the CSS standard stipulates that the display:inline of floating elements will be automatically adjusted to block - By setting the width of the block-level element and the left and right margins to auto, IE6 cannot achieve horizontal centering. The solution: set it for the parent element
text-align: center;