0

我是stackoverflow的新手,如果我的英语不好,抱歉

我的 css 代码有问题,我创建了一个布局,它看起来像 http://postimg.org/image/pg1oay3wl/

我的问题是如何使用 CSS 获得 div 之间的垂直空间我尝试提供 margin-bottom 和 padding 但它对我不起作用当我将位置指定为相对但右顶部的 div 向下滚动时向下移动我应该给一个弹性布局..请在这个问题上帮助我..

这是我的代码

CSS

@charset "utf-8";
/* CSS Document */


/* new clearfix */
.clearfix:after {
    visibility: hidden;
    display: block;
    font-size: 0;
    content: " ";
    clear: both;
    height: 0;
    }
* html .clearfix             { zoom: 1; } /* IE6 */
*:first-child+html .clearfix { zoom: 1; } /* IE7 */


#css-zen-garden {
    width: 80%;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 62.5%;
    margin: 0 auto;
    min-width: 200px;
    background: #EEE;   
}

h1,h2,h3,h4,h5,h6 {
    line-height: 1.1em;
    margin-bottom: 0.25em;  
}

h1 { font-size: 360%; }
h2 { font-size: 240%; }
h3 { font-size: 210%; }
h4 { font-size: 180%; }
h5 { font-size: 160%; }
h6 { font-size: 140%; }

p {
    font-size: 120%;
    line-height: 1.5em;
    margin-bottom: 0.6em;
}


header {
    border: 5px solid #928452;
    border-style: ridge;
    border-radius: 5px 150px 5px;
    display: block;
    width: 12%;
    height: 300px;
    max-width: 100%;
    padding: 10px;
    min-width: 200px;
    position: fixed;
    top: 50%;
    left: 50%;
    margin-top: -150px;
    margin-left: -150px;
    text-align: center;
    background: rgba(51,51,51,0.8);

}

header h1 {
    color: #928452;
    padding : 25px;
    display: block;
    vertical-align: middle; 
}

header h2 {
    color: #FFF;
    display: block;
    vertical-align: middle; 
}

.preamble, .explanation, .participation, .benefits {
    width: 21%;
    background: rgba(158,141,77,0.8);
    border-radius: 10px;
    display: block;
    position: absolute;
    clear: both;
    padding: 10px;
    min-width: 200px;
    margin-bottom: 30px;
    animation: zoom 2s;
    animation-direction:alternate;
}

.preamble {
    top: 15%;
    left: 15%;  
}

.explanation {
    top: 50%;   
    left: 8%;
}

.participation {
    top: 10%;
    right: 15%;

}

.benefits {
    top: 55%;
    right: 8%;  
}
.requirements {
    width: 40%;
    background: rgba(158,141,77,0.8);
    border-radius: 10px;
    padding: 10px;
    float: left;
    max-width: 100%;
    min-width: 200px;
    position: absolute;
    left: 35%;
    top: 80%;
    animation: zoom 2s;
    animation-direction:alternate;
}




@keyframes zoom{
        0% {
                opacity: 0;
                transform: scale(.3);
        }

        50% {
                opacity: 1;
                transform: scale(1.05);
        }

        70% {
                transform: scale(.9);
        }

        100% {
                transform: scale(1);
        }

}

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>CSS Zen Garden: The Beauty of CSS Design</title>

    <link rel="stylesheet" media="screen" href="/214/214.css?v=8may2013">
    <link rel="alternate" type="application/rss+xml" title="RSS" href="http://www.csszengarden.com/zengarden.xml">
    <link rel="stylesheet" type="text/css" href="css/default.css">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="author" content="Dave Shea">
    <meta name="description" content="A demonstration of what can be accomplished visually through CSS-based design.">
    <meta name="robots" content="all">


</head>


<body id="css-zen-garden">
<div class="page-wrapper">

    <section class="intro" id="zen-intro">
        <header role="banner">
            <h1>CSS Zen Garden</h1>
            <h2>The Beauty of <abbr title="Cascading Style Sheets">CSS</abbr> Design</h2>
        </header>

        <div class="preamble" id="zen-preamble" role="article">
            <h3>The Road to Enlightenment</h3>
            <p>Littering a dark and dreary road lay the past relics of browser-specific tags, incompatible <abbr title="Document Object Model">DOM</abbr>s, broken <abbr title="Cascading Style Sheets">CSS</abbr> 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 <abbr title="World Wide Web Consortium">W3C</abbr>, <abbr title="Web Standards Project">WaSP</abbr>, 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>
    </section>

    <div class="main supporting" id="zen-supporting" role="main">
        <div class="explanation" id="zen-explanation" role="article">
            <h3>So What is This About?</h3>
            <p>There is a continuing need to show the power of <abbr title="Cascading Style Sheets">CSS</abbr>. 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 <abbr title="HyperText Markup Language">HTML</abbr> remains the same, the only thing that has changed is the external <abbr title="Cascading Style Sheets">CSS</abbr> file. Yes, really.</p>
            <p><abbr title="Cascading Style Sheets">CSS</abbr> 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" id="zen-participation" role="article">
            <h3>Participation</h3>
            <p>Strong visual design has always been our focus. You are modifying this page, so strong <abbr title="Cascading Style Sheets">CSS</abbr> skills are necessary too, but the example files are commented well enough that even <abbr title="Cascading Style Sheets">CSS</abbr> novices can use them as starting points. Please see the <a href="http://www.mezzoblue.com/zengarden/resources/" title="A listing of CSS-related resources"><abbr title="Cascading Style Sheets">CSS</abbr> Resource Guide</a> for advanced tutorials and tips on working with <abbr title="Cascading Style Sheets">CSS</abbr>.</p>
            <p>You may modify the style sheet in any way you wish, but not the <abbr title="HyperText Markup Language">HTML</abbr>. This may seem daunting at first if you&#8217;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 <a href="/zengarden-sample.html" title="This page's source HTML code, not to be modified.">HTML</a> and <a href="/zengarden-sample.css" title="This page's sample CSS, the file you may modify.">CSS</a> to work on a copy locally. Once you have completed your masterpiece (and please, don&#8217;t submit half-finished work) upload your <abbr title="Cascading Style Sheets">CSS</abbr> file to a web server under your control. <a href="http://www.mezzoblue.com/zengarden/submit/" title="Use the contact form to send us your CSS file">Send us a link</a> 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" id="zen-benefits" role="article">
            <h3>Benefits</h3>
            <p>Why participate? For recognition, inspiration, and a resource we can all refer to showing people how amazing <abbr title="Cascading Style Sheets">CSS</abbr> 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="requirements" id="zen-requirements" role="article">
            <h3>Requirements</h3>
            <p>Where possible, we would like to see mostly <abbr title="Cascading Style Sheets, levels 1 and 2">CSS 1 &amp; 2</abbr> usage. <abbr title="Cascading Style Sheets, levels 3 and 4">CSS 3 &amp; 4</abbr> should be limited to widely-supported elements only, or strong fallbacks should be provided. The CSS Zen Garden is about functional, practical <abbr title="Cascading Style Sheets">CSS</abbr> and not the latest bleeding-edge tricks viewable by 2% of the browsing public. The only real requirement we have is that your <abbr title="Cascading Style Sheets">CSS</abbr> validates.</p>
            <p>Luckily, designing this way shows how well various browsers have implemented <abbr title="Cascading Style Sheets">CSS</abbr> 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 &#8212; especially when you factor in mobile &#8212; pixel-perfect layouts may not be possible across every platform. That&#8217;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&#8217;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 <a href="http://www.mezzoblue.com/zengarden/submit/guidelines/">submission guidelines</a>), but we ask you release your <abbr title="Cascading Style Sheets">CSS</abbr> under a Creative Commons license identical to the <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/" title="View the Zen Garden's license information.">one on this site</a> so that others may learn from your work.</p>
            <p role="contentinfo">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="https://rads.stackoverflow.com/amzn/click/com/0321303474" rel="nofollow noreferrer">Zen Garden, the book</a>.</p>
        </div>


</body>
</html>
4

0 回答 0