css FF與IE兼容性總結(jié)
發(fā)布時(shí)間:2009-09-03 18:29:40 作者:佚名
我要評(píng)論

css FF與IE兼容性總結(jié) ,在實(shí)際應(yīng)用中大家可以多測(cè)試。
1. 超鏈接訪問過后hover樣式就不出現(xiàn)的問題
被點(diǎn)擊訪問過的超鏈接樣式不在具有hover和active了,很多人應(yīng)該都遇到過這個(gè)問題,解決方法是改變CSS屬性的排列順序: L-V-H-A
Code:
<style type="text/css">
<!--
a:link {}
a:visited {}
a:hover {}
a:active {}
-->
</style>
2. FireFox下如何使連續(xù)長字段自動(dòng)換行
眾所周知IE中直接使用 word-wrap:break-word 就可以了, FF中我們使用JS插入的方法來解決
Code:
<style type="text/css">
<!--
div {
width:300px;
word-wrap:break-word;
border:1px solid red;
}
-->
</style>
<div id="ff">aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaa</div>
Js代碼
<scrīpt type="text/javascrīpt">
/* <![CDATA[ */
function toBreakWord(el, intLen){
var ōbj=document.getElementById(el);
var strContent=obj.innerHTML;
var strTemp="";
while(strContent.length>intLen){
strTemp+=strContent.substr(0,intLen)+"
";
strContent=strContent.substr(intLen,strContent.length);
}
strTemp+="
"+strContent;
obj.innerHTML=strTemp;
}
if(document.getElementById && !document.all) toBreakWord("ff", 37);
/* ]]> */
</script>
3.ff下為什么父容器的高度不能自適應(yīng)
在子容器加了浮動(dòng)屬性后,該容器將不能自動(dòng)撐開,解決方法是在標(biāo)簽結(jié)束后加上一個(gè)清除浮動(dòng)的元素。
Code:
clear:both;
4.IE6的雙倍邊距BUG
浮動(dòng)后本來外邊距10px,但I(xiàn)E解釋為20px,解決辦法是加上
Code:
display: inline
5. IE6下絕對(duì)定位的容器內(nèi)文本無法正常選擇
此問題在IE6、7中存在,解決問題的辦法是讓IE進(jìn)入到qurks mode。關(guān)于qurks mode的相關(guān)知識(shí),請(qǐng)參考:
http://www.microsoft.com/china/msdn/library/webservices/asp.net/ASPNETusStan.mspx?mfr=true
6. IE6下圖片下方有空隙產(chǎn)生
解決這個(gè)BUG的方法也有很多,可以是改變html的排版,或者設(shè)置img 為display:block
或者設(shè)置vertical-align 屬性為vertical-align:top | bottom |middle |text-bottom都可以解決.
7. IE6下兩個(gè)層中間有間隙
這個(gè)IE的3PX BUG也是經(jīng)常出現(xiàn)的,解決的辦法是給.right也同樣浮動(dòng) float:left 或者相對(duì)IE6定義.left margin-right:-3px;
8. list-style-image無法準(zhǔn)確定位
list-style-image的定位問題也是經(jīng)常有人問的,解決的辦法一般是用li的背景模擬,這里采用相對(duì)定位的方法也可以解決。
9. LI中內(nèi)容超過長度后以省略號(hào)顯示的方法
此方法適用與IE與OP瀏覽器
Code:
<style type="text/css">
<! --
li {
width: 200px;
white-space:nowrap;
text-overflow:ellipsis;
-o-text-overflow:ellipsis;
overflow: hidden;
}
-->
</style>
10.web標(biāo)準(zhǔn)中定義id與class有什么區(qū)別嗎
一.web標(biāo)準(zhǔn)中是不容許重復(fù)ID的,比如 div id="aa" 不容許重復(fù)2次,而class 定義的是類,理論上可以無限重復(fù), 這樣需要多次引用的定義便可以 使用他.
二.屬性的優(yōu)先級(jí)問題
ID 的優(yōu)先級(jí)要高于class,看上面的例子
三.方便JS等客戶端腳本,如果在頁面中要對(duì)某個(gè)對(duì)象進(jìn)行腳本操作,那么可以給他定義一個(gè)ID,否則只能利用遍歷頁面元素加上指定特定屬性來找到它,這是相對(duì)浪費(fèi)時(shí)間資源,遠(yuǎn)遠(yuǎn)不如一個(gè)ID來得簡(jiǎn)單.
11.如何垂直居中文本
將元素高度和行高設(shè)為一致。
Code:
<style type="text/css">
<!--
div{
height:30px;
line-height:30px;
border:1px solid red
}
-->
</style>
12.如何對(duì)齊文本與文本輸入框
加上 vertical-align:middle;
Code:
<style type="text/css">
<!--
input {
width:200px;
height:30px;
border:1px solid red;
vertical-align:middle;
}
-->
</style>
13.FF下面不能水平居中呢
FF下面設(shè)置容器的左右外補(bǔ)丁為auto就可以了
Code:
<style type="text/css">
<!--
div{
margin:0 auto;
}
-->
</style>
14.FF下文本無法撐開容器的高度
標(biāo)準(zhǔn)瀏覽器中固定高度值的容器是不會(huì)象IE6里那樣被撐開的,那我又想固定高度,又想能被撐開需要怎樣設(shè)置呢?辦法就是去掉height設(shè)置min-height:200px; 這里為了照顧不認(rèn)識(shí)min-height的IE6 可以這樣定義:
Code:
{
height:auto!important;
height:200px;
min-height:200px;
}
15.IE6下容器的寬度和FF解釋不同呢
Code:
<?xml version="1.0" encoding="gb2312"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
<!--
div{
cursor:pointer;
width:200px;
height:200px;
border:10px solid red
}
-->
</style>
<div ōnclick="alert(this.offsetWidth)">web標(biāo)準(zhǔn)常見問題大全</div>
問題的差別在于容器的整體寬度有沒有將邊框(border)的寬度算在其內(nèi),這里IE6解釋為200PX ,而FF則解釋為220PX,那究竟是怎么導(dǎo)致的問題呢?大家把容器頂部的xml去掉就會(huì)發(fā)現(xiàn)原來問題出在這,頂部的申明觸發(fā)了IE的qurks mode,關(guān)于qurks mode、standards mode的相關(guān)知識(shí),請(qǐng)參考:
[url]http://www.microsoft.com/china/msdn/library/webservices/asp.net/
ASPNETusStan.mspx?mfr=true[/url]
16. 為什么web標(biāo)準(zhǔn)中IE無法設(shè)置滾動(dòng)條顏色了
解決辦法是將body換成html
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
<!--
html {
scrollbar-face-color:#f6f6f6;
scrollbar-highlight-color:#fff;
scrollbar-shadow-color:#eeeeee;
scrollbar-3dlight-color:#eeeeee;
scrollbar-arrow-color:#000;
scrollbar-track-color:#fff;
scrollbar-darkshadow-color:#fff;
}
-->
</style>
17. 為什么我定義的樣式?jīng)]有作用呢
這里你無法用.aa定義到li 遇到這種情況怎么解決呢?答案是提高.aa 的優(yōu)先權(quán) 比如#aa ul li.aa
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
<!--
#aa ul li {
color:red
}
.aa {
color:blue
}
-->
</style>
<div id="aa">
<ul>
<li class="aa">
web標(biāo)準(zhǔn)常見問題大全
</li>
</ul>
</div>
18. IE6無法定義1px左右高度的容器
IE6下這個(gè)問題是因?yàn)槟J(rèn)的行高造成的,解決的方法也有很多,例如:overflow:hidden | zoom:0.08 | line-height:1px
19. 背景顏色無法顯示
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
<!--
ul {
background:red
}
li {
float:left;
width:180px;
}
-->
</style>
<!--[if lte IE 6]>
<style>
.gainlayout { height: 1px; }
</style>
<![endif]-->
<ul class="gainlayout">
<li>web標(biāo)準(zhǔn)常見問題大全</li>
<li>web標(biāo)準(zhǔn)常見問題大全</li>
<li>web標(biāo)準(zhǔn)常見問題大全</li>
<li>web標(biāo)準(zhǔn)常見問題大全</li>
<li>web標(biāo)準(zhǔn)常見問題大全</li>
<div style="clear:both"></div>
</ul>
IE中設(shè)置有背景色的ul并沒有顯示出來,這個(gè)屬于haslayout問題,解決的辦法也很多參考 http://www.satzansatz.de/cssd/onhavinglayout.htm
解決方法之一:
Code:
<!--[if lte IE 6]>
<style>
.gainlayout { height: 1px; }
</style>
<![endif]-->
<!--[if lte IE 6]>
<style>
.gainlayout { height: 1px; }
</style>
<![endif]-->
20. 怎么樣才能讓層顯示在FLASH之上呢
解決的辦法是給FLASH設(shè)置透明
Code:
<param name="wmode" value="transparent" />
21. 怎樣使一個(gè)層垂直居中于瀏覽器中
這里我們使用百分比絕對(duì)定位,與外補(bǔ)丁負(fù)值的方法,負(fù)值的大小為其自身寬度高度除以二
Code:
<style type="text/css">
<!--
div {
position:absolute;
top:50%;
left:50%;
margin:-100px 0 0 -100px;
width:200px;
height:200px;
border:1px solid red;
}
-->
</style>
22. 圖片垂直與容器內(nèi)
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<style type="text/css">
<!--
* {margin:0;padding:0}
div {
width:500px;
height:500px;
border:1px solid #ccc;
overflow:hidden;
position:relative;
display:table-cell;
text-align:center;
vertical-align:middle
}
div p {
position:static;
+position:absolute;
top:50%
}
img {
position:static;
+position:relative;
top:-50%;left:-50%;
width:276px;
height:110px
}
-->
</style>
<div><p><img src="logo.gif" /></p></div>
或者使用背景圖的辦法:
Code:
background:url("logo.gif") center no-repeat;
23. 如何讓div橫向排列
橫向排列DIV可以使用浮動(dòng)的方式比如float:left,或者設(shè)置對(duì)象為內(nèi)聯(lián),還可以絕對(duì)定位對(duì)象等等.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
<!--
div {
float:left;
width:200px;
height:200px;
border:1px solid red
}
-->
</style>
<div>web標(biāo)準(zhǔn)常見問題大全</div>
<div>web標(biāo)準(zhǔn)常見問題大全</div>
<div>web標(biāo)準(zhǔn)常見問題大全</div>
24 Firefox 關(guān)于DIV高度無法自適應(yīng)的兩種解決
如果設(shè)置了一個(gè)DIV的高度,當(dāng)DIV里實(shí)際內(nèi)容大于所設(shè)高度,ie會(huì)自動(dòng)拉伸以適應(yīng)DIV容器大小,ff會(huì)固定DIV的高度,超過部分超出DIV底線以外,
出現(xiàn)和下面的內(nèi)容重疊的現(xiàn)象。如果不給DIV設(shè)置高度,在Firefox中將不回因?yàn)槔锩娴膬?nèi)容而撐開,而IE中就會(huì)自動(dòng)根據(jù)內(nèi)容撐開
解決方案:
1、在DIV內(nèi)部的最后追加clear:both樣式
<div style="background-color:#FF0000;">
<div style="float:left; height:200px">Jmedia Design</div>
<div style="float:right; height:800px">www.jmedia.cn</div>
<div style="clear:both"></div>
</div>
2、對(duì)DIV使用overflow:auto;
<div style="overflow:auto;">
<div style="float:left; background-color:#000000;height:200px">1111111111</div>
<div style="float:right;background-color:#000000; height:300px"">2222222222</div>
</div>
被點(diǎn)擊訪問過的超鏈接樣式不在具有hover和active了,很多人應(yīng)該都遇到過這個(gè)問題,解決方法是改變CSS屬性的排列順序: L-V-H-A
Code:
<style type="text/css">
<!--
a:link {}
a:visited {}
a:hover {}
a:active {}
-->
</style>
2. FireFox下如何使連續(xù)長字段自動(dòng)換行
眾所周知IE中直接使用 word-wrap:break-word 就可以了, FF中我們使用JS插入的方法來解決
Code:
<style type="text/css">
<!--
div {
width:300px;
word-wrap:break-word;
border:1px solid red;
}
-->
</style>
<div id="ff">aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaa</div>
Js代碼
<scrīpt type="text/javascrīpt">
/* <![CDATA[ */
function toBreakWord(el, intLen){
var ōbj=document.getElementById(el);
var strContent=obj.innerHTML;
var strTemp="";
while(strContent.length>intLen){
strTemp+=strContent.substr(0,intLen)+"
";
strContent=strContent.substr(intLen,strContent.length);
}
strTemp+="
"+strContent;
obj.innerHTML=strTemp;
}
if(document.getElementById && !document.all) toBreakWord("ff", 37);
/* ]]> */
</script>
3.ff下為什么父容器的高度不能自適應(yīng)
在子容器加了浮動(dòng)屬性后,該容器將不能自動(dòng)撐開,解決方法是在標(biāo)簽結(jié)束后加上一個(gè)清除浮動(dòng)的元素。
Code:
clear:both;
4.IE6的雙倍邊距BUG
浮動(dòng)后本來外邊距10px,但I(xiàn)E解釋為20px,解決辦法是加上
Code:
display: inline
5. IE6下絕對(duì)定位的容器內(nèi)文本無法正常選擇
此問題在IE6、7中存在,解決問題的辦法是讓IE進(jìn)入到qurks mode。關(guān)于qurks mode的相關(guān)知識(shí),請(qǐng)參考:
http://www.microsoft.com/china/msdn/library/webservices/asp.net/ASPNETusStan.mspx?mfr=true
6. IE6下圖片下方有空隙產(chǎn)生
解決這個(gè)BUG的方法也有很多,可以是改變html的排版,或者設(shè)置img 為display:block
或者設(shè)置vertical-align 屬性為vertical-align:top | bottom |middle |text-bottom都可以解決.
7. IE6下兩個(gè)層中間有間隙
這個(gè)IE的3PX BUG也是經(jīng)常出現(xiàn)的,解決的辦法是給.right也同樣浮動(dòng) float:left 或者相對(duì)IE6定義.left margin-right:-3px;
8. list-style-image無法準(zhǔn)確定位
list-style-image的定位問題也是經(jīng)常有人問的,解決的辦法一般是用li的背景模擬,這里采用相對(duì)定位的方法也可以解決。
9. LI中內(nèi)容超過長度后以省略號(hào)顯示的方法
此方法適用與IE與OP瀏覽器
Code:
<style type="text/css">
<! --
li {
width: 200px;
white-space:nowrap;
text-overflow:ellipsis;
-o-text-overflow:ellipsis;
overflow: hidden;
}
-->
</style>
10.web標(biāo)準(zhǔn)中定義id與class有什么區(qū)別嗎
一.web標(biāo)準(zhǔn)中是不容許重復(fù)ID的,比如 div id="aa" 不容許重復(fù)2次,而class 定義的是類,理論上可以無限重復(fù), 這樣需要多次引用的定義便可以 使用他.
二.屬性的優(yōu)先級(jí)問題
ID 的優(yōu)先級(jí)要高于class,看上面的例子
三.方便JS等客戶端腳本,如果在頁面中要對(duì)某個(gè)對(duì)象進(jìn)行腳本操作,那么可以給他定義一個(gè)ID,否則只能利用遍歷頁面元素加上指定特定屬性來找到它,這是相對(duì)浪費(fèi)時(shí)間資源,遠(yuǎn)遠(yuǎn)不如一個(gè)ID來得簡(jiǎn)單.
11.如何垂直居中文本
將元素高度和行高設(shè)為一致。
Code:
<style type="text/css">
<!--
div{
height:30px;
line-height:30px;
border:1px solid red
}
-->
</style>
12.如何對(duì)齊文本與文本輸入框
加上 vertical-align:middle;
Code:
<style type="text/css">
<!--
input {
width:200px;
height:30px;
border:1px solid red;
vertical-align:middle;
}
-->
</style>
13.FF下面不能水平居中呢
FF下面設(shè)置容器的左右外補(bǔ)丁為auto就可以了
Code:
<style type="text/css">
<!--
div{
margin:0 auto;
}
-->
</style>
14.FF下文本無法撐開容器的高度
標(biāo)準(zhǔn)瀏覽器中固定高度值的容器是不會(huì)象IE6里那樣被撐開的,那我又想固定高度,又想能被撐開需要怎樣設(shè)置呢?辦法就是去掉height設(shè)置min-height:200px; 這里為了照顧不認(rèn)識(shí)min-height的IE6 可以這樣定義:
Code:
{
height:auto!important;
height:200px;
min-height:200px;
}
15.IE6下容器的寬度和FF解釋不同呢
Code:
<?xml version="1.0" encoding="gb2312"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
<!--
div{
cursor:pointer;
width:200px;
height:200px;
border:10px solid red
}
-->
</style>
<div ōnclick="alert(this.offsetWidth)">web標(biāo)準(zhǔn)常見問題大全</div>
問題的差別在于容器的整體寬度有沒有將邊框(border)的寬度算在其內(nèi),這里IE6解釋為200PX ,而FF則解釋為220PX,那究竟是怎么導(dǎo)致的問題呢?大家把容器頂部的xml去掉就會(huì)發(fā)現(xiàn)原來問題出在這,頂部的申明觸發(fā)了IE的qurks mode,關(guān)于qurks mode、standards mode的相關(guān)知識(shí),請(qǐng)參考:
[url]http://www.microsoft.com/china/msdn/library/webservices/asp.net/
ASPNETusStan.mspx?mfr=true[/url]
16. 為什么web標(biāo)準(zhǔn)中IE無法設(shè)置滾動(dòng)條顏色了
解決辦法是將body換成html
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
<!--
html {
scrollbar-face-color:#f6f6f6;
scrollbar-highlight-color:#fff;
scrollbar-shadow-color:#eeeeee;
scrollbar-3dlight-color:#eeeeee;
scrollbar-arrow-color:#000;
scrollbar-track-color:#fff;
scrollbar-darkshadow-color:#fff;
}
-->
</style>
17. 為什么我定義的樣式?jīng)]有作用呢
這里你無法用.aa定義到li 遇到這種情況怎么解決呢?答案是提高.aa 的優(yōu)先權(quán) 比如#aa ul li.aa
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
<!--
#aa ul li {
color:red
}
.aa {
color:blue
}
-->
</style>
<div id="aa">
<ul>
<li class="aa">
web標(biāo)準(zhǔn)常見問題大全
</li>
</ul>
</div>
18. IE6無法定義1px左右高度的容器
IE6下這個(gè)問題是因?yàn)槟J(rèn)的行高造成的,解決的方法也有很多,例如:overflow:hidden | zoom:0.08 | line-height:1px
19. 背景顏色無法顯示
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
<!--
ul {
background:red
}
li {
float:left;
width:180px;
}
-->
</style>
<!--[if lte IE 6]>
<style>
.gainlayout { height: 1px; }
</style>
<![endif]-->
<ul class="gainlayout">
<li>web標(biāo)準(zhǔn)常見問題大全</li>
<li>web標(biāo)準(zhǔn)常見問題大全</li>
<li>web標(biāo)準(zhǔn)常見問題大全</li>
<li>web標(biāo)準(zhǔn)常見問題大全</li>
<li>web標(biāo)準(zhǔn)常見問題大全</li>
<div style="clear:both"></div>
</ul>
IE中設(shè)置有背景色的ul并沒有顯示出來,這個(gè)屬于haslayout問題,解決的辦法也很多參考 http://www.satzansatz.de/cssd/onhavinglayout.htm
解決方法之一:
Code:
<!--[if lte IE 6]>
<style>
.gainlayout { height: 1px; }
</style>
<![endif]-->
<!--[if lte IE 6]>
<style>
.gainlayout { height: 1px; }
</style>
<![endif]-->
20. 怎么樣才能讓層顯示在FLASH之上呢
解決的辦法是給FLASH設(shè)置透明
Code:
<param name="wmode" value="transparent" />
21. 怎樣使一個(gè)層垂直居中于瀏覽器中
這里我們使用百分比絕對(duì)定位,與外補(bǔ)丁負(fù)值的方法,負(fù)值的大小為其自身寬度高度除以二
Code:
<style type="text/css">
<!--
div {
position:absolute;
top:50%;
left:50%;
margin:-100px 0 0 -100px;
width:200px;
height:200px;
border:1px solid red;
}
-->
</style>
22. 圖片垂直與容器內(nèi)
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<style type="text/css">
<!--
* {margin:0;padding:0}
div {
width:500px;
height:500px;
border:1px solid #ccc;
overflow:hidden;
position:relative;
display:table-cell;
text-align:center;
vertical-align:middle
}
div p {
position:static;
+position:absolute;
top:50%
}
img {
position:static;
+position:relative;
top:-50%;left:-50%;
width:276px;
height:110px
}
-->
</style>
<div><p><img src="logo.gif" /></p></div>
或者使用背景圖的辦法:
Code:
background:url("logo.gif") center no-repeat;
23. 如何讓div橫向排列
橫向排列DIV可以使用浮動(dòng)的方式比如float:left,或者設(shè)置對(duì)象為內(nèi)聯(lián),還可以絕對(duì)定位對(duì)象等等.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
<!--
div {
float:left;
width:200px;
height:200px;
border:1px solid red
}
-->
</style>
<div>web標(biāo)準(zhǔn)常見問題大全</div>
<div>web標(biāo)準(zhǔn)常見問題大全</div>
<div>web標(biāo)準(zhǔn)常見問題大全</div>
24 Firefox 關(guān)于DIV高度無法自適應(yīng)的兩種解決
如果設(shè)置了一個(gè)DIV的高度,當(dāng)DIV里實(shí)際內(nèi)容大于所設(shè)高度,ie會(huì)自動(dòng)拉伸以適應(yīng)DIV容器大小,ff會(huì)固定DIV的高度,超過部分超出DIV底線以外,
出現(xiàn)和下面的內(nèi)容重疊的現(xiàn)象。如果不給DIV設(shè)置高度,在Firefox中將不回因?yàn)槔锩娴膬?nèi)容而撐開,而IE中就會(huì)自動(dòng)根據(jù)內(nèi)容撐開
解決方案:
1、在DIV內(nèi)部的最后追加clear:both樣式
<div style="background-color:#FF0000;">
<div style="float:left; height:200px">Jmedia Design</div>
<div style="float:right; height:800px">www.jmedia.cn</div>
<div style="clear:both"></div>
</div>
2、對(duì)DIV使用overflow:auto;
<div style="overflow:auto;">
<div style="float:left; background-color:#000000;height:200px">1111111111</div>
<div style="float:right;background-color:#000000; height:300px"">2222222222</div>
</div>
相關(guān)文章
- 這篇文章主要介紹了淺談原生頁面兼容IE9問題的解決方案,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起2020-12-16
新版chrome瀏覽器設(shè)置允許跨域的實(shí)現(xiàn)
這篇文章主要介紹了新版chrome瀏覽器設(shè)置允許跨域的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起2020-11-30css hack之\9和\0就可能對(duì)hack IE11\IE9\IE8無效
每次設(shè)計(jì)一張網(wǎng)頁或一個(gè)表單,都被各種瀏覽器的兼容問題傷透腦筋,尤其是IE家族。在做兼容性設(shè)計(jì)時(shí),我們往往會(huì)使用各種瀏覽器能識(shí)別的獨(dú)特語法進(jìn)行hack,從而達(dá)到各種瀏覽2020-03-20css區(qū)分ie8/ie9/ie10/ie11 chrome firefox的代碼
這篇文章主要介紹了css區(qū)分ie8/ie9/ie10/ie11 chrome firefox的代碼,需要的朋友可以參考下2020-03-20- 這篇文章主要介紹了解決CSS瀏覽器兼容性問題的4種方案,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)2020-02-28
- 這篇文章主要介紹了常見的瀏覽器兼容性問題(小結(jié)),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)2020-02-20
- 這篇文章主要介紹了border-radius IE8兼容處理的方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)2020-02-12
- 這篇文章主要介紹了淺談?dòng)龅降膸讉€(gè)瀏覽器兼容性問題,詳細(xì)的介紹了幾種我遇到的問題和解決方式,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-09-26
- 這篇文章主要介紹了base64圖片在各種瀏覽器的兼容性處理的相關(guān)資料,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-09-14
對(duì)常見的css屬性進(jìn)行瀏覽器兼容性總結(jié)(推薦)
這篇文章主要介紹了對(duì)常見的css屬性進(jìn)行瀏覽器兼容性總結(jié)(推薦)的相關(guān)資料,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-07-20