2012-09-05 30 views
0

我已經在媒體查詢下面的CSS(爲最小寬度768px):IE7 CSS:第一胎選擇與媒體查詢

.formHolder-section {width: 235px; position: relative; float: left; margin:0;} 
.formHolder-section:first-child { margin: 0 20px 0 40px; } 

的倍率(爲:第一胎)適用於所有除IE7之外的瀏覽器。我不知道是否有任何好的理由...我也嘗試扭轉臨界值(它適用於所有(2).formHolder節的div,然後使用不同的選擇:

.formHolder-section {width: 235px; position: relative; float: left; margin: 0 20px 0 40px;} 
.formHolder-section + .formHolder-section { margin: 0; } 

這也沒有工作,我解決了我的問題,只是給兩個div一些保證金(相對於只有第一個div)。奇怪的是......除了第一個孩子的選擇器,其他所有的CSS都在這裏工作,米想知道如果任何人有任何想法可能是什麼問題的原因

下面是一些HTML(雖然,同樣,HTML/CSS作品無處不在,除了IE7)的:

<div class="formContainer"> 
    <div class="formHolder-section"> 
     <span class="form-required">*Denotes field as required</span> 
     <ul class="form-list"> 
      <li> 
       <label>First:*</label> 
       <input type="text" value="" class="form-input-full" name="firstName" id="firstName"> 
      </li> 
      <li> 
       <label>Last:*</label> 
       <input type="text" value="" class="form-input-full" name="lastName" id="lastName"> 
      </li> 
      <li> 
       <label>Email Address:*</label> 
       <input type="text" value="" class="form-input-full" name="email" id="email"> 
      </li> 
      <li> 
       <label class="listOptionPadding">Are you 18 years old?*</label> 
       <input type="radio" value="true" class="form-radio" name="over18" id="over181"> <span class="italic">Yes</span> 
       <br> 
       <input type="radio" value="true" class="form-radio" name="over18" id="over182"> <span class="italic">No</span> 
      </li> 
      [...] 
     </ul> 
    </div> 
    <div class="formHolder-section"> 
     <ul class="form-list"> 
      <li> 
       <label class="listOptionPaddingBottom">When Do You Intend to Purchase a New Vehicle?</label> 
       <input type="radio" value="1_MONTH" class="form-radio" name="nextPurchase" id="nextPurchase1"> <span class="italic">Within a Month</span> 
       <br> 
       <input type="radio" value="3_MONTH" class="form-radio" name="nextPurchase" id="nextPurchase2"> <span class="italic">Within the next 3 Months</span> 
       <br> 
       <input type="radio" value="6_MONTH" class="form-radio" name="nextPurchase" id="nextPurchase3"> <span class="italic">Within the next 6 Months</span> 
       <br> 
       <input type="radio" value="WITHIN_YEAR" class="form-radio" name="nextPurchase" id="nextPurchase4"> <span class="italic">Within a Year</span> 
       <br> 
       <input type="radio" value="OVER_YEAR" class="form-radio" name="nextPurchase" id="nextPurchase5"> <span class="italic">More than 1 Year</span> 
      </li> 
      <li class="interested-in"> 
       <label>What Toyota vehicles are you interested in?</label> 
      </li> 
      [...] 
     </ul>  
     <input type="submit" value="Submit" class="form-button rounded"> 
     <a class="form-terms" href="/ToyotaMotorApp/mobile/tyw/terms.html">View all the terms and conditions</a> 
    </div> 
</div> 

這裏是DOCTYPE(使用HTML5這裏 - 我已經看到一些奇怪的東西與quirksmode,毫無疑問 - 但是,不認爲這是這裏的問題)。利用近代化的媒體查詢(這是一個負責任的網站):

<!doctype html> 
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]--> 
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]--> 
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]--> 
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--> 
<head> 
  • 順便說一下,我把這個從IE8(這樣的HTML標籤將是IE7不同 - 不過,我在測試中現在是不同的虛擬機)。
+0

什麼是你使用的doctype,你可以請張貼包含'.formHolder-section'的div的HTML的一部分? – jrrdnx

+0

你可以顯示你的媒體查詢嗎?您是否使用任何腳本來允許IE7和IE8讀取媒體查詢(Modernizr不支持* polyfill支持,只能測試它)? – BoltClock

+0

對您評論的延遲迴復感到抱歉。以下是用於包含上述CSS的媒體查詢:@media only screen和(min-width:768px){[...]}。但是,IE又一次提取了本節中的樣式(例如,在第一個孩子或X + X選擇器之前的選擇器工作正常 - 以及該查詢中的所有其他CSS)。 –

回答

0

兩個字 - 怪癖模式。直到你到達IE9時,第一個孩子的假選擇器才真正奏效。

http://www.quirksmode.org/css/contents.html#t17

+0

不是一個真正的答案。偉大的網站(我一直使用它),但不適用於這個特定的問題。 :第一個孩子在CSS的其他地方工作。我正在尋找一個確切的原因 - 不是「只有在版本9之前它才能正常工作」。我使用:IE中的第一個孩子經常沒有問題。所以,我想知道這裏的問題是什麼......以防萬一有人看到媒體查詢的問題,特別是。 –

+0

另外,請注意,我已經取消了:第一個孩子選擇器和第二個CSS線(覆蓋)不起作用(請參閱上面的第二個css示例)!所以,這不是特定於選擇器(但是,相反,立即保證金覆蓋)。 –

+0

第二個示例使用next-sibling(+)而不是第一個孩子,直到您訪問IE9時也會遇到問題:http://www.quirksmode.org/css/contents.html#t12。怪癖模式是一種生活方式,有很多不同的方式來做同樣的事情,以至於你應該能夠完成工作。 – mmertel