IE8 CSS 問題..............

html : <fieldset><legend align="center">~XXX~</legend>

置中失效

html / CSS 要點改先正常番 ?

原帖由 sckds 於 2009-3-28 10:54 發表
html : ~XXX~

置中失效

html / CSS 要點改先正常番 ?


IE 7 得, 唔知IE8得唔得

legend {
        display: block;
        text-align: center;
}

TOP

http://xhtml.com/en/xhtml/reference/legend/#legend-attributes

個legend tag好似無align呢個Attribute woh...

可以試下用class attribute去套用CSS rule。

http://www.w3schools.com/css/pr_text_text-align.asp

TOP

原帖由 thinkpanda 於 2009-3-28 01:06 PM 發表


IE 7 得, 唔知IE8得唔得

legend {
        display: block;
        text-align: center;
}


本身係IE6/7冇問題 ,係用 IE8 就失效

TOP

回覆 4# 的帖子

The "align" attribute has been deprecated and it has 4 valid values only according to the HTML 4.01 REC:

http://www.w3.org/TR/html4/interact/forms.html#edef-LEGEND

"center" is not a valid value and that's possibly the reason why the standard mode of IE 8 does not support it.

Adding the following script block in <head> should workaround the issue:

<script type="text/javascript">
function alignLegendsToCenter() {
        var legendElements=document.querySelectorAll("legend[align='center']");
        for(var i=0;i<legendElements.length;i++) {
                var currLegend=legendElements;
                if(currLegend.getAttribute("align")==="center") {
                        var currLegendParent=currLegend.parentNode;
                        var currLegendParentStyle=currLegendParent.style;
                        currLegendParentStyle.paddingLeft=currLegendParentStyle.paddingRight=0;
                        currLegendParentStyle.minWidth=currLegend.offsetWidth+"px";
                        currLegend.style.marginLeft=currLegend.style.marginRight=((currLegendParent.clientWidth-currLegend.clientWidth)/2)+"px";
                }
        }
}
if(document.documentMode===8) {
        window.onload=alignLegendsToCenter;
        window.onresize=alignLegendsToCenter;
}
</script>

Updated at 2009-03-28 18:05: Modified the script to set the mid-width and padding of the fieldset containing the legend.

Updated at 2009-03-28 20:54: Modified the script to use the Selective API to improve performance.

[ 本帖最後由 commander 於 2009-3-28 20:55 編輯 ]

TOP

firefox 冇問題

究竟係邊個唔跟 standard

TOP