Geek Answers Handbook

      Css only for the first direct child

      I have the following html structure:

      <div class="nav-collapse">
                    <ul class="nav">
      
                    </ul>
      
                    <ul id="registerCart" class="nav pull-right">
      
                    </ul>
      
      </div>
      

      and I wanted to apply the following rule only to the first nav, so I did:

      .nav-collapse > .nav {
          left: 135px;
      }
      

      however, this is also case-sensitive. How to apply this only to the first nav?

      0
      html css css3
      adit Nov 04 '13 at 9:01
      source share
      3 answers

      Use first child selector:

      .nav-collapse .nav:first-child {}
      

      You can combine it with a direct child selector if you have more nested elements .nav.

      .nav-collapse > .nav:first-child {}
      
      +4
      Fleshgrinder Nov 04 '13 at 9:03
      source share

      p > , , ( , ) , , .

      : first-child , IE7 IE8, . . http://www.quirksmode.org/css/selectors . , class id.

      +1
      jazZRo 04 . '13 9:28

      'nav' 'nave', ! , "nav" - .

      0
      MalcolmTW 21 . '19 9:51

      More articles:

      • Is solr and cut possible? - join
      • Sprite-Kit colorizeWithColor does not mix sprite with the right color - ios
      • Matrix game design - javascript
      • C # Error - Namespaces ManagementClass, ManagementObject, and ManagementObjectCollection not found - c #
      • css changes color after a certain HTML tag - html
      • Convert string to function in AngularJS - javascript
      • How to disable Quill Editor - quill
      • I need 1/10 and 1/100 parts of a percent in the kendo ui text box - kendo-ui
      • https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1548916/an-exception-occurred-while-creating-local-git-repository-openshift&usg=ALkJrhgigq4DYTBSEmwc_mhbwy--0dqgbg
      • CKEditor: диалог остановки ссылки появляется при двойном щелчке URL-адреса или в любом другом событии - ckeditor

      All Articles

      Geek Answers | 2019