gpt4 book ai didi

css - IE7 CSS :first-child Selector with Media Query

转载 作者:行者123 更新时间:2023-11-28 13:42:04 26 4
gpt4 key购买 nike

我在媒体查询中有以下 CSS(对于最小宽度 768px):

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

覆盖(对于 :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)解决了我的问题。奇怪的是……除了第一个 child 选择器之外,所有其他 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 东西——但是,不要认为这是这里的问题)。使用 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>
  • 顺便说一下,这是我从 IE8 中获取的(因此 html 标签对于 IE7 会有所不同——但是,我现在正在不同的 VM 中进行测试)。

最佳答案

两个字——怪癖模式。在您到达 IE9 之前,第一个 child 伪选择器并不能很好地工作。

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

关于css - IE7 CSS :first-child Selector with Media Query,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12272901/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com