我面临一个有关CSS选择器的问题,虽然看起来很简单,但相当复杂。
看看我的HTML代码:
<p class="room">
<strong></strong>
<strong></strong>
Wycombe Letting are pleased to present this spacious one bedroom, ground floor flat which is in good decorative order and boasts from a well presented kitchen and bathroom. The property is situated within a popular residential area, just outside town centre and benefits from having an allocated parking space for one car and an communal gardens.
<br>
<br>
<br>
<br>
Please note this property will not accept tenants in receipt of housing benefits and will also not accept pets so please inform us as soon as possible if this will affect any possible applications to rent this property.
<br>
<br>
<br>
<br>
Additional Fees:
<br>
<br>
Security Deposit:
<br>
<br>
Fee for first applicant of £149.00
<br>
<br>
Fee for subsequent applicants £85, -
<br>
<br>
Check-In Fee: £200.00
<br>
<br>
Tenancy Renewal Fee: £75.00 (on each occasion the tenancy is renewed)
<br>
<br>
<br>
<br>
Note: These particulars are intended only as a guide to prospective Tenants to enable them to decide whether to make further enquiries with a view to taking up negotiations but they are otherwise not intended to be relied upon in any way for any purpose whatsoever and accordingly neither their accuracy nor the continued availability of the property is in any way guaranteed and they are furnished on the express understanding that neither the Agents nor the Vendors are to be or become under any liability or claim in respect of their contents. Any prospective Tenant must satisfy himself by inspection or otherwise as to the correctness of the particulars contained
<br>
<br>
<strong>Letting</strong>
<strong>details</strong>
<strong></strong>
<br>
<br>
<strong>-</strong>
<strong>Available</strong>
<strong>now</strong>
<strong></strong>
<br>
<br>
<strong>-</strong>
<strong>Unfurnished</strong>
<strong></strong>
<br>
<br>
<strong>-</strong>
<strong>Long</strong>
<strong>term</strong>
<strong>let</strong>
<strong></strong>
</p>
如你所见,段落标签包含许多“强”标记和“br”标记。我需要的是,在这一段中,我需要选择所有奇怪的“br”标签或所有偶数“br”标记。如果段落只包含“br”标记,这不会是一个问题,但是由于“强”标记也存在,所以选择所有偶数或奇数的“br”标记是一个挑战。
有人能建议我一个CSS解决方案吗?
要清楚的是,最终的输出应该是这样的。我的目标是删除选定的“br”标签
<p class="room">
<strong></strong>
<strong></strong>
Wycombe Letting are pleased to present this spacious one bedroom, ground floor flat which is in good decorative order and boasts from a well presented kitchen and bathroom. The property is situated within a popular residential area, just outside town centre and benefits from having an allocated parking space for one car and an communal gardens.
<br>
<br>
Please note this property will not accept tenants in receipt of housing benefits and will also not accept pets so please inform us as soon as possible if this will affect any possible applications to rent this property.
<br>
<br>
Additional Fees:
<br>
Security Deposit:
<br>
Fee for first applicant of £149.00
<br>
Fee for subsequent applicants £85, -
<br>
Check-In Fee: £200.00
<br>
Tenancy Renewal Fee: £75.00 (on each occasion the tenancy is renewed)
<br>
<br>
Note: These particulars are intended only as a guide to prospective Tenants to enable them to decide whether to make further enquiries with a view to taking up negotiations but they are otherwise not intended to be relied upon in any way for any purpose whatsoever and accordingly neither their accuracy nor the continued availability of the property is in any way guaranteed and they are furnished on the express understanding that neither the Agents nor the Vendors are to be or become under any liability or claim in respect of their contents. Any prospective Tenant must satisfy himself by inspection or otherwise as to the correctness of the particulars contained.
<br>
<strong>Letting</strong>
<strong>details</strong>
<strong></strong>
<br>
<strong>-</strong>
<strong>Available</strong>
<strong>now</strong>
<strong></strong>
<br>
<strong>-</strong>
<strong>Unfurnished</strong>
<strong></strong>
<br>
<strong>-</strong>
<strong>Long</strong>
<strong>term</strong>
<strong>let</strong>
<strong></strong>
</p>
发布于 2018-07-30 11:04:32
你应该使用:nth-of-type
(第一个孩子的指数为1):
br:nth-of-type(odd) {
// Styling
// display: none;
}
br:nth-of-type(even) {
// Styling
// display: none;
}
发布于 2018-07-30 12:47:31
要实际删除标记,需要JavaScript(假设不是静态的)
如果您只是想隐藏它,可以使用nth-of-type
要做到这一点,你只需添加br:nth-of-type(even) { display: none; }
,自然切换even
为odd
。
https://stackoverflow.com/questions/-100001719
复制相似问题