2017-06-21 4 views
0

シンプルなアコーディオンをブートストラップに基づいた簡単なレスポンシブウェブサイトに入れました。有効なコンポーネント(js、jqueryなど)がない状態でチェックボックスがオンになっています

<div class="container"> 
     <div class="row"> 
      <div class="accordion"> 
       <!--<h1>Descirption</h1>--> 
       <ul class="features_list"> 
        <li> 
         <input type="checkbox" checked> 
         <i></i> 
         <h2>Lorem ipsum dolor sit amet</h2> 
         <p>sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,</p>        
        </li> 

正常に動作します。しかし、今ではいくつかのアコーディオンが負荷で開かれるようにしたいと思っています。ちょうどCSSで。

アイデア?

これまでのところありがとうございます。

答えて

0

アコーディオンの最初のチェックボックスをオンに設定し、もう一方のチェックボックスをオフにします。次に、CSSでチェックされるアコーディオンを開くための動作を追加します。

------------- HTML ------------

<div id="wrapper"> 

     <ul> 
      <li> 
       <input type="checkbox" > 
       <i></i> 
       <h2>What is Lorem Ipsum ?</h2> 
       <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> 
      </li> 
      <li> 
       <input type="checkbox" checked> 
       <i></i> 
       <h2>Why do we use it ?</h2> 
       <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p> 
      </li> 
      <li> 
       <input type="checkbox" checked> 
       <i></i> 
       <h2>Wher we can it ?</h2> 
       <p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.</p> 
      </li> 
     </ul> 
    </div> 

------- CSS ----- - ここで

body { 
    width: 100%; 
    height: 100%; 
    background-color: #eeeeee; 
    font-family: 'Poiret One', cursive; 
    color: rgba(48, 69, 92, 0.8); 
} 
#wrapper { 
    min-height: 0; 
    display: inline-block; 
    position: relative; 
    left: 50%; 
    margin: 50px 0; 
    transform: translate(-50%, 0); 
    background-color: #fefffa; 
    max-width: 450px; 
    padding: 30px; 
} 
h1, 
h2 { 
    color: #000000; 
} 
h1 { 
    margin: 10% auto 0; 
    text-transform: uppercase; 
    font-size: 36px; 
    line-height: 42px; 
    letter-spacing: 3px; 
    font-weight: 100; 
    text-align: center; 
    display: table; 
    padding: 10px 0; 
    font-weight: bolder; 
    border-bottom: 2px solid #000; 
} 
h2 { 
    font-size: 26px; 
    line-height: 34px; 
    font-weight: 300; 
    letter-spacing: 1px; 
    display: block; 
    background-color: #fefffa; 
    margin: 0; 
    cursor: pointer; 
} 
p { 
    color: rgba(48, 69, 92, 0.8); 
    font-size: 17px; 
    line-height: 26px; 
    letter-spacing: 1px; 
    position: relative; 
    overflow: hidden; 
    max-height: 800px; 
    opacity: 1; 
    transform: translate(0, 0); 
    margin-top: 14px; 
    z-index: 2; 
    transition: all 500ms ease; 
} 
p, 
ul li i:before, 
ul li i:after { 
    transition: all 0.25s ease-in-out; 
} 
ul { 
    list-style: none; 
    padding: 0; 
    margin: 0; 
} 
ul li { 
    position: relative; 
    padding: 0; 
    margin: 0; 
    padding-bottom: 4px; 
    padding-top: 18px; 
    border-top: 1px dotted #dce7eb; 
} 
ul li i { 
    position: absolute; 
    transform: translate(-6px, 0); 
    margin-top: 9px; 
    right: 0; 
} 
ul li i:before, 
ul li i:after { 
    content: ""; 
    position: absolute; 
    background-color: #000000; 
    width: 3px; 
    height: 16px; 
} 
ul li i:before { 
    transform: translate(2px, 0) rotate(45deg); 
} 
ul li i:after { 
    transform: translate(2px, 0) rotate(-45deg); 
} 
ul li input[type=checkbox] { 
    position: absolute; 
    cursor: pointer; 
    width: 100%; 
    height: 100%; 
    z-index: 1; 
    opacity: 0; 
} 
ul li input[type=checkbox]:checked ~ p { 
    margin-top: 0; 
    max-height: 0; 
    opacity: 0; 
    transform: translate(0, 50%); 
} 
ul li input[type=checkbox]:checked ~ i:before { 
    margin-top: 9px; 
    height: 9px; 
    transform: translate(2px, 0) rotate(45deg); 
} 
ul li input[type=checkbox]:checked ~ i:after { 
    margin-top: 9px; 
    height: 9px; 
    transform: translate(-2px, 0) rotate(-45deg); 
} 

が働いfiddle

です
関連する問題