2014-12-26 3 views
0

나는 배우고/연습하고 있으므로 어떤 도움이라도 SUPER가 될 것입니다. 또한보고있는 동안 다른 오류나 비효율을 발견하면 그에 대해 듣고 싶습니다.Z- 인덱스 레이어링 문제 (CSS)

나는 4 개의 레이어가 있습니다. .body

.main .main 측 .sidebar

This 내가 다시 노력하고있어 모든 것이 제 3 층 이외의 잘 작동, 또는 예의 경우에 어떤 본질적으로 오른쪽에 수직으로 연장 된 해군 파란색 바. 두 번째 레이어 (기본 배경 바로 위)로 이동하거나 모든 항목 (사이드 바 포함)을 덮을 수는 있지만 레이어 2와 4 사이에서 가져올 수는 없습니다 (이 예에서는 연한 파란색 내부 상자 및 더 작은, 노란 옆 상자.) 미리 감사드립니다!

다음은 HTML과 CSS입니다.

<!doctype html> 
<html> 
<head> 
    <link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,900' rel='stylesheet' type='text/css'> 
    <link rel="stylesheet" type="text/css" href="./style.css"/> 
    <title>CSS Zen Garden</title> 
    <meta charset="utf-8" /> 
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> 
    <meta name="viewport" content="width=device-width, initial-scale=1" /> 
</head> 
<body> 
<div class="main-side"></div> 
<div class="main"> 
    <h1 class="redbox">CSS Zen Garden</h1> 

    <h2>The Beauty of CSS Design</h2> 
    <div class="sub-heading"> 
     <p class="top>">A demonstration of what can be accomplished through CSS-based design. Select any style sheet from the list to load it into this page.</p> 

     <hr> 

     <p class="bottom">Download the example <a href="#">HTML file</a> and <a href="#">CSS file</a> 
    </div> 
<div class="enlightenment">   
    <h3>The Road to Enlightenment</h3> 

     <p>Littering a dark and dreary road lay the past relics of browser-specific tags, incompatible DOMs, broken CSS support, and abandoned browsers</p> 

     <p>We must clear the mind of the past. Web enlightenment has been achieved thanks to the tireless efforts of folk like the W3C, WaSP, and the major browser creators.</p> 

     <p>The CSS Zen Garden invites you to relax and meditate on the important lessons of the masters. Begin to see with clarity. Learn to use the time-honored techniques in new and invigorating fashion. Become one with the web.</p> 
</div> 

<div class="about"> 
    <h3>So What is This About?</h3> 

     <p>There is a continuing need to show the power of CSS. The Zen Garden aims to excite, inspire, and encourage participation. To begin, view some of the existing designs in the list. Clicking on any one will load the style sheet into this very page. The HTML remains the same, the only thing that has changed is the external CSS file. Yes, really.</p> 

     <p>CSS allows complete and total control over the style of a hypertext document. The only way this can be illustrated in a way that gets people excited is by demonstrating what it can truly be, once the reins are placed in the hands of those able to create beauty from structure. Designers and coders alike have contributed to the beauty of the web; we can always push it further.</p> 
</div> 

<div class="participation"> 
    <h3>Participation</h3> 

     <p>Strong visual design has always been our focus. You are modifying this page, so strong CSS skills are necessary too, but the example files are commented well enough that even CSS novices can use them as starting points. Please see the CSS Resource Guide for advanced tutorials and tips on working with CSS.</p> 

     <p>You may modify the style sheet in any way you wish, but not the HTML. This may seem daunting at first if you’ve never worked this way before, but follow the listed links to learn more, and use the sample files as a guide.</p> 

     <p>Download the sample HTML and CSS to work on a copy locally. Once you have completed your masterpiece (and please, don’t submit half-finished work) upload your CSS file to a web server under your control. Send us a link to an archive of that file and all associated assets, and if we choose to use it we will download it and place it on our server.</p> 
</div> 

<div class="benefits"> 
    <h3>Benefits</h3> 

     <p>Why participate? For recognition, inspiration, and a resource we can all refer to showing people how amazing CSS really can be. This site serves as equal parts inspiration for those working on the web today, learning tool for those who will be tomorrow, and gallery of future techniques we can all look forward to.</p> 
</div> 

<div class="sidebar"> 
    <h3>Select a Design:</h3> 

     <ul> 
      <li> 
       <a href="/221/" class="design-name">Mid Century Modern</a> by      <a href="http://andrewlohman.com/" class="designer-name">Andrew Lohman</a> 
      </li> 

      <li> 
       <a href="/220/" class="design-name">Garments</a> by      <a href="http://danielmall.com/" class="designer-name">Dan Mall</a> 
      </li>     

      <li> 
       <a href="/219/" class="design-name">Steel</a> by      <a href="http://steffen-knoeller.de" class="designer-name">Steffen Knoeller</a> 
      </li>     

      <li> 
       <a href="/218/" class="design-name">Apothecary</a> by      <a href="http://trentwalton.com" class="designer-name">Trent Walton</a> 
      </li>     

      <li> 
       <a href="/217/" class="design-name">Screen Filler</a> by      <a href="http://elliotjaystocks.com/" class="designer-name">Elliot Jay Stocks</a> 
      </li>     

      <li> 
       <a href="/216/" class="design-name">Fountain Kiss</a> by      <a href="http://jeremycarlson.com" class="designer-name">Jeremy Carlson</a> 
      </li>     

      <li> 
       <a href="/215/" class="design-name">A Robot Named Jimmy</a> by      <a href="http://meltmedia.com/" class="designer-name">meltmedia</a> 
      </li>     

      <li> 
       <a href="/214/" class="design-name">Verde Moderna</a> by      <a href="http://www.mezzoblue.com/" class="designer-name">Dave Shea</a> 
      </li>     
     </ul> 

    <h3>Archives:</h3> 
     <ul> 
      <li> 
       <a href="/217/page1">     Next Designs <span class="indicator">&rsaquo;</span></a> 
       </li> 

      <li> 
      <a href="http://www.mezzoblue.com/zengarden/alldesigns/" title="View every submission to the Zen Garden.">View All Designs</a> 
      </li> 
     </ul> 

    <h3>Resources:</h3> 
     <ul> 
      <li> 
       <a href="/217/217.css" title="View the source CSS file of the currently-viewed design.">View This Design&#8217;s CSS</a> 
      </li> 

      <li> 
       <a href="http://www.mezzoblue.com/zengarden/resources/" title="Links to great sites with information on using CSS.">CSS Resources</a> 
      </li> 

      <li> 
       <a href="http://www.mezzoblue.com/zengarden/faq/" title="A list of Frequently Asked Questions about the Zen Garden.">FAQ</a> 
      </li> 

      <li> 
       <a href="http://www.mezzoblue.com/zengarden/submit/" title="Send in your own CSS file."> 
       Submit a Design</a> 
      </li> 

      <li> 
       <a href="http://www.mezzoblue.com/zengarden/translations/" title="View translated versions of this page.">Translations</a> 
      </li> 
     </ul> 
</div> 

<div class="requirements"> 
    <h3>Requirements</h3> 

     <p>Where possible, we would like to see mostly CSS 1 & 2 usage. CSS 3 & 4 should be limited to widely-supported elements only, or strong fallbacks should be provided. The CSS Zen Garden is about functional, practical CSS and not the latest bleeding-edge tricks viewable by 2% of the browsing public. The only real requirement we have is that your CSS validates.</p> 

     <p>Luckily, designing this way shows how well various browsers have implemented CSS by now. When sticking to the guidelines you should see fairly consistent results across most modern browsers. Due to the sheer number of user agents on the web these days — especially when you factor in mobile — pixel-perfect layouts may not be possible across every platform. That’s okay, but do test in as many as you can. Your design should work in at least IE9+ and the latest Chrome, Firefox, iOS and Android browsers (run by over 90% of the population).</p> 

     <p>We ask that you submit original artwork. Please respect copyright laws. Please keep objectionable material to a minimum, and try to incorporate unique and interesting visual themes to your work. We’re well past the point of needing another garden-related design.</p> 

     <p>This is a learning exercise as well as a demonstration. You retain full copyright on your graphics (with limited exceptions, see submission guidelines), but we ask you release your CSS under a Creative Commons license identical to the one on this site so that others may learn from your work.</p> 

     <hr> 
    <div class="author"> 
     <p>By <a href="http://www.mezzoblue.com/">Dave Shea</a>. Bandwidth graciously donated by <a href="http://www.mediatemple.net/">mediatemple</a>. Now available: <a href="http://rads.stackoverflow.com/amzn/click/0321303474">Zen Garden, the book</a>.</p> 
    </author> 
</div> 

     <footer> 
      <a href="http://validator.w3.org/check/referer" title="Check the validity of this site&#8217;s HTML" class="zen-validate-html">HTML</a> 
      <a href="http://jigsaw.w3.org/css-validator/check/referer" title="Check the validity of this site&#8217;s CSS" class="zen-validate-css">CSS</a> 
      <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/" title="View the Creative Commons license of this site: Attribution-NonCommercial-ShareAlike." class="zen-license">CC</a> 
      <a href="http://mezzoblue.com/zengarden/faq/#aaa" title="Read about the accessibility of this site" class="zen-accessibility">A11y</a> 
      <a href="https://github.com/mezzoblue/csszengarden.com" title="Fork this site on Github" class="zen-github">GH</a> 
     </footer> 
</div> 
</body> 
</html> 


body { 
    font-family: 'Source Sans Pro'; 
    line-height: 120%; 
    font-size: 16px; 
    font-weight: 400; 
    color: #333; 
    background: #daede2; 
    z-index: 1; 
    width: 90%; 
    vertical-align: center; 
} 

p { 
    font-size: 20px; 
    line-height: 140%; 
    padding-left: 50px; 
} 

h1 { 
    font-weight: 300; 
    text-transform: uppercase; 
    font-size: 30px; 
    color: white; 
    margin-bottom: -25px; 
} 

h2 { 
    font-weight: 900; 
    font-size: 130px; 
    line-height: 100%; 
    color: white; 
    letter-spacing: -.025em; 
    line-height: 1em; 
    width: 65%; 
    margin-left: 50px; 
    position: relative; 
} 

.sub-heading { 
    text-transform: uppercase; 
    width: 60%; 
    margin: 0 0 50px 14px; 
    position: relative; 
    color: white; 
    letter-spacing: .07em; 
    font-size: 18px; 
} 

h3 { 
    font-size: 30px; 
    font-weight: 400; 
    padding-left: 50px; 
} 

.main { 
    background: #77c4d3; 
    position: relative; 
    top: 50px; 
    left: 50px; 
    z-index: 2; 
    height: 5000px; 
} 

.main-side { 
    background: #3a4453; 
    position: absolute; 
    left: 1020px; 
    height: 2000px; 
    top: -200px; 
    width: 30%; 
    z-index: 1; 
} 

.redbox { 
    background: #df3c56; 
    position: relative; 
    top: 50px; 
    left: 50px; 
    padding: 25px; 
    width: 224px; 
    text-align: center; 
} 

.enlightenment { 
    background: #f2f9fb; 
    padding: 50px 50px 50px 0; 
    width: 58%; 
    position: relative; 
    top: 40px; 
    margin-bottom: 150px; 
} 

.about { 
    color: white; 
    width: 45%; 
    margin-bottom: 100px; 
    margin-top: 250px; 
} 

.about h3 { 
    color: white; 
} 

.benefits { 
    background: #f2f9fb; 
    position: relative; 
    top: 225px; 
    float: left; 
    padding: 50px; 
    width: 25%; 
    left: 50px; 
} 

.sidebar { 
    background: #e9f198; 
    position: absolute; 
    top: 70px; 
    right: 0px; 
    width: 25%; 
    font-size: 18px; 
    line-height: 200%; 
    letter-spacing: -.01em; 
    padding-right: 40px; 
    z-index: 4; 
} 

.sidebar a, h3 { 
    color: #333; 
} 

.sidebar h3 { 
    font-weight: 400; 
    padding-left: 40px; 
    margin-bottom: -20px; 
} 

.sidebar ul { 
    list-style-type: none; 
} 

.participation { 
    background: #df3c56; 
    float: right; 
    width: 45%; 
    color: white; 
    position: relative; 
    top: -618px; 
    right: 80px; 
    padding-top: 50px; 
} 

.participation p { 
    padding: 0 50px 0 50px; 
} 

.participation h3 { 
    color: white; 
} 

.requirements { 
    background: #f2f9fb; 
    position: relative; 
    float: right; 
    top: -625px; 
    width: 57%; 
    padding: 50px; 
} 

.requirements a { 
    color: #333; 
    text-transform: uppercase; 
} 

.author { 
    text-transform: uppercase; 
} 

footer { 
    background: #e9f198; 
    position: relative; 
    top: 119px; 
    padding: 25px; 
    font-size: 22px; 
    word-spacing: 10px; 
    color: #333; 
    left: -440px; 
    width: 80%; 
} 

a { 
    text-decoration: none; 
    color: white; 
    border-bottom: solid 1px #999; 
    padding-bottom: 2px; 
} 

hr { 
    border: 0; 
    height: 0; 
    border-top: 1px solid #df3c56; 
    width: 93%; 
    margin: 50px 0 50px 50px; 
} 

답변

1

당신이 할 필요가 그래서 당신이 값은 당신이 게시 된 예와 같이 중복 확인하고 조정하는 데에 대한 권리 z-index을 추가 할 수 있습니다 .main.main-side를 이동할 수 있습니다 :

.main-side { 
    background: rgba(58,68,83, .8); //convert to rgba so you can fade the background like the example 
    position: absolute; 
    right: -150px; //update - change to right instead 
    height: 2400px; //update 
    top: -200px; 
    width: 30%; 
    z-index: 1; 
} 

가 나는 또한 일부 변환을하여 색상을 rgba으로 지정하면 투명하게 보입니다.

FIDDLE

+0

굉장합니다. 그것은 완전히 효과가있었습니다. 자, 내가 너에게 한 번 더 문제를 일으킬 수 있다면, 나는 그 일을하고 왜 내 일을하지 않았는지 대답 할 수 있겠 니? 불편을 드려 죄송합니다. 나는 여전히 CSS에 대해 매우 익숙하다. 이것은 내가 직접 작성한 첫 번째 CSS 였고 그 옆에 (아마도) 지나치게 효율적이지는 않았으며, 이것이 작동하지 않아서, 나는 그것을 자랑스러워했습니다. –

+0

당신은 자랑스러워해야합니다, 그것은 좋은 출발입니다. 'z-index '로 작업하면 레이어를 구성하는 데 도움이되지만 같은 영역에 포함 된 두 요소 사이에'주면 '을 슬라이드하려고합니다. 그래서 '메인 슬라이드'가 거기에 있어야했습니다. 두 요소 뒤에 또는 두 요소 사이에 '주 슬라이드'를 넣을 수 있었지만 두 요소 사이에는 끼지 않을 수있었습니다. 이해와 행운을 빕니다 희망 – jmore009

0

나는 당신이 무엇을 요구하고 있는지 잘 모르지만, 도움이 될만한 몇 가지 사항이 있습니다.

.sidebar { 
    background: #e9f198; 
    position: absolute; 
    top: 70px; 
    right: -100px; 
    width: 25%; 
    font-size: 18px; 
    line-height: 200%; 
    letter-spacing: -.01em; 
    padding-right: 40px; 
    z-index: 4; 
} 

당신은 사이드 바는 이제 더 그들의 같이 배치되는 것을 볼 수 있습니다 : 첫째, 노란 메뉴 무슨 달성하기 위해,이 같은 것을 사용한다.

그리고이 두 가지 변경 사항을 통해 찾고있는 것과 더 가까워 질까요?

.main { 
    background: #77c4d3; 
    position: relative; 
    top: 50px; 
    left: 50px; 
    z-index: 2; 
    height: 5000px; 
} 

.main-side { 
    background: #3a4453; 
    position: absolute; 
    left: 900px; 
    height: 2000px; 
    top: 70px; 
    width: 30%; 
    z-index: 1; 
} 

는 또한 당신은 항상이 같은 질문에 대해 앞으로 어떻게해야 JSFIDDLE을했습니다!

+0

감사합니다. Jamie. 첫 번째 부분은 CSS를 사용하는 것보다 확실히 의미가 있으며, 훨씬 더 효율적입니다. 나는 두 번째 부분을 작동시키지 못했지만이 아래의 주석은 대답했다. .main (HTML) 부분의 .main 사이드 바를 움직여야합니다. 그것은 그것을 고쳤다. 다시 한 번 감사드립니다! –