简体   繁体   English

仅应用CSS的第一个元素?

[英]Apply CSS only first element?

I create price form like this: 我创建这样的价格表:

Please click to full page at bellow my code to easy look. 请单击下面的full page我的代码以方便查看。

 @import url('http://fonts.googleapis.com/css?family=Indie+Flower'); @import url('http://fonts.googleapis.com/css?family=Open+Sans:300,400,700'); body{ background-color: rgb(237, 237, 237); } #pricing{ width: 1340px; /* margin: 100px auto; */ font-family: 'Open Sans', Helvetica; } .price_card{ width: 295px; max-height: 173px; background: rgb(255, 255, 255); display: inline-table; top: 0; border: 1px solid green; } .price_card:not(:last-child){ margin-right: 32px; } .header{ color: rgb(255, 255, 255); background-color: rgb(113, 191, 68); font-size: 20px; font-weight: 100; height: 68px; display: block; text-align: center; padding: 28px 0 0px; } .price{ width: 100%; font-size: 18px; font-weight: 300; display: block; text-align: center; padding: 10px 0 10px; } .name{ width: 100%; font-size: 25px; font-weight: 100; display: block; text-align: center; padding: 0; } .features{ list-style: none; text-align: center; color: rgb(255, 255, 255); background-color: rgb(144, 205, 109); margin: 0; padding: 0; } .features li{ margin: 0 35px; padding: 20px 15px; width: 200px; } .features li:not(:last-child){ border: 1px solid rgb(242, 242, 242); border-top: 0; border-left: 0; border-right: 0; } button{ color: rgb(255, 255, 255); border: 0; border-radius: 0px; height: 42px; width: 177px; display: block; font-weight: 200; background-color: rgb(113, 191, 68); font-size: 18px; text-transform: uppercase; margin: 20px auto 35px; } 
 <div id="pricing"> <div class="content"> <h1>PRICE POPULAR CLOUD SERVICES</h1> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ratione voluptates magnam nam eligendi, maiores quis, <br />ut perspiciatis odit eos accusamus modi sequi laborum veritatis quasi harum dolorem maxime, magni at! </p> <br /> </div> <div class="price_card"> <div class="header"> <span class="name">Google Cloud</span> </div> <ul class="features"> <span class="price">800 USD</span> </ul> <button>More info</button> </div> <div class="price_card"> <div class="header"> <span class="name">Amazon Cloud</span> </div> <ul class="features"> <li class="price">1000 USD</li> </ul> <button>More info</button> </div> <div class="price_card"> <div class="header"> <span class="name">GO DADDY</span> </div> <ul class="features"> <li class="price">1200 USD</li> </ul> <button>More info</button> </div> <div class="price_card"> <div class="header"> <span class="name">PLUS+ </span> </div> <ul class="features"> <li class="price">2000 USD</li> </ul> <button>More info</button> </div> </div> 

I have two question: 我有两个问题:

You can see: 您可以看到:

  1. The first element of class: price_card is applied style CSS. 类的第一个元素: price_card是样式CSS。 Another is nothing. 另一个没什么。

Why I meet this problem? 为什么我遇到这个问题?

  1. I don't have experience with the responsive website. 我没有响应式网站的经验。 Can you example at a resolution about 800x400 pixel? 您能否以约800x400像素的分辨率作为示例? It auto scale only two card in first rows and two cards in second rows? 它会自动缩放第一行中的两张卡和第二行中的两张卡吗?

You are using a different HTML element in one of your blocks. 您在其中一个块中使用了另一个HTML元素。

Change: 更改:

<div class="price_card">
<div class="header">
  <span class="name">Google Cloud</span>
</div>
<ul class="features">
  <span class="price">800 USD</span>
</ul>
<button>More info</button>

To: 至:

<div class="price_card">
<div class="header">
  <span class="name">Google Cloud</span>
</div>
<ul class="features">
  <li class="price">800 USD</li>
</ul>
<button>More info</button>

Your unordered list had a "span" as the first child element, but should have had an "li" as the first child element. 您的无序列表以“ span”作为第一个子元素,但是应该以“ li”作为第一个子元素。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 仅当所选元素是CSS中特定父级的第一个子级时,样式才适用 - Styles will only apply if the selected element is the first child of a specific parent in CSS CSS 检查元素是否存在并应用于第一个元素 - CSS to check element exists and apply to first element 将 CSS 应用于第一个子元素,将 CSS 应用于元素内部的最后一个子元素,但如果只有子元素则不适用 - Apply CSS to first child and CSS to last child inside element but not if only child 为什么如果你定位 CSS 中的“Form”元素,属性只适用于第一个子元素,而不是全部? - Why is it that if you target a “Form” element in CSS, the properties apply only to the first child-element, and not all? CSS 仅用于第一个匹配元素 - CSS only for first matching element 仅使用javascript将CSS样式应用于div中的第一个可用类元素 - only apply css style to first available class element within div using javascript 我正在尝试在向下滚动后将 css 添加到所有“li”元素,但它仅适用于第一个 li - i am trying add css to all ' li ' element after scroll down but it apply only first li 仅当类第一次或最后一次出现时才应用 CSS - Apply CSS only if first or last occurence of a class 初学者css =&gt;仅将属性应用于一个元素 - beginner css => apply property to only one element css 规则适用于只有一个元素位于另一个元素旁边时 - css rule to apply if only one element sits next to other element
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM