我在媒体查询中有以下CSS(最小宽度为768px):
.formHolder-section {width: 235px; position: relative; float: left; margin:0;}
.formHolder-section:first-child { margin: 0 20px 0 40px; }
覆盖(for:first-child)适用于除IE7之外的所有浏览器。我想知道是否有任何合理的理由...我也试过反转边距值(将其应用于所有(2).formHolder-section div,然后使用不同的选择器:
.formHolder-section {width: 235px; position: relative; float: left; margin: 0 20px 0 40px;}
.formHolder-section + .formHolder-section { margin: 0; }
这也没用。我已经解决了我的问题,只给两个div一些余量(而不是只有第一个div)。奇怪的是......除了第一个子选择器之外,所有其他CSS都在这里工作。我想知道是否有人知道这个问题的原因是什么。
以下是一些HTML(但是,除了IE7之外,HTML / CSS还可以在任何地方使用):
<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,毫无疑问 - 但是,不要认为这是问题)。使用modernizer进行媒体查询(这是一个响应式网站):
<!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>
答案 0 :(得分:0)
两个字 - 怪癖模式。在你到达IE9之前,第一个子伪选择器确实不能正常工作。