2016-09-09 4 views
0

プログレスバーをページの上部(クラス:outerDiv_S)にロックしようとしているので、ユーザーがスクロールすると常に進行状況がわかります。divを画面の上部に固定する

が、私は成功せず、このポストからさまざまな提案されたソリューションを試してみた:How do you create non scrolling div at the top of an HTML page without two sets of scroll bars

/*basic reset*/ 
 
* {margin: 0; padding: 0;} 
 

 
.html_S { 
 
\t height: 100%; 
 
    
 
} 
 
.toast { 
 
    opacity: 1 !important; 
 
} 
 
.body_S { 
 
    min-height: 100%; 
 
    margin: 0; 
 
    background-repeat: no-repeat; 
 
    background-attachment: fixed; 
 
\t font-family: montserrat, arial, verdana; 
 
\t background-color: black !important; 
 

 
} 
 

 
.reqSpan_S { 
 
    top: -15px; 
 
\t position:relative; 
 
} 
 

 
.reqFieldText_S { 
 
    color: red; 
 
    padding: 0; 
 
    margin: 0; 
 
} 
 

 
.reqFieldStar_S { 
 
    font-weight: bold; 
 
} 
 
.k-button { 
 
    color: red; 
 
} 
 

 
.buttonCentre_S { 
 
    clear: left; 
 
    text-align: center; 
 
} 
 

 
.outerDiv_S { 
 
    width: 85%; 
 
    margin: 50px auto; 
 
    text-align: center; 
 
    position: fixed; 
 
} 
 

 

 
#surveyForm { 
 
\t top: 135px; 
 
\t position:relative; 
 
    width: 85%; 
 
\t margin: 50px auto; 
 
\t text-align: left; 
 
} 
 
#surveyForm fieldset { 
 
\t background: white; 
 
\t border: 0 none; 
 
\t border-radius: 3px; 
 
\t box-shadow: 0 0 15px 1px rgba(0, 0, 0, 0.4); 
 
\t padding: 20px 30px; 
 
\t 
 
\t box-sizing: border-box; 
 
\t width: 80%; 
 
\t margin: 0 10%; 
 
} 
 

 
/*inputs*/ 
 
#surveyForm input, #surveyForm textarea { 
 
\t padding: 15px; 
 
\t border: 1px solid #ccc; 
 
\t border-radius: 3px; 
 
\t margin-bottom: 10px; 
 
\t width: 100%; 
 
\t box-sizing: border-box; 
 
\t font-family: montserrat; 
 
\t color: #2C3E50; 
 
\t font-size: 13px; 
 
} 
 
/*buttons*/ 
 
#surveyForm .action-button { 
 
    text-align: center; 
 
\t width: 100px; 
 
\t background: #27AE60; 
 
\t font-weight: bold; 
 
\t color: white; 
 
\t border: 0 none; 
 
\t border-radius: 1px; 
 
\t cursor: pointer; 
 
\t padding: 10px 5px; 
 
\t margin: 10px 5px; 
 
} 
 
#surveyForm .action-button:hover, #surveyForm .action-button:focus { 
 
\t box-shadow: 0 0 0 2px white, 0 0 0 3px #27AE60; 
 
} 
 
#surveyForm .action-button-submit { 
 
\t width: 100px; 
 
\t background: #3498db; 
 
\t font-weight: bold; 
 
\t color: white; 
 
\t border: 0 none; 
 
\t border-radius: 1px; 
 
\t cursor: pointer; 
 
\t padding: 10px 5px; 
 
\t margin: 10px 5px; 
 
} 
 

 
/*For Toast not part of surveyForm...*/ 
 
.action-button-ok { 
 
\t width: 100px; 
 
\t background: rgba(255, 255, 255, 0.3); 
 
\t font-weight: bold; 
 
\t color: white; 
 
\t border: 0 none; 
 
\t border-radius: 1px; 
 
\t cursor: pointer; 
 
\t padding: 10px 5px; 
 
\t margin: 10px 5px; 
 
} 
 

 
#surveyForm .action-button-submit:hover, #surveyForm .action-button-submit:focus { 
 
\t box-shadow: 0 0 0 2px white, 0 0 0 3px #3498db; 
 
} 
 
/*headings*/ 
 
.fs-title { 
 
\t font-size: 15px; 
 
\t text-transform: uppercase; 
 
\t color: #2C3E50; 
 
\t margin-bottom: 10px; 
 
} 
 
.fs-subtitle { 
 
\t font-weight: normal; 
 
\t font-size: 13px; 
 
\t color: #666; 
 
\t margin-bottom: 20px; 
 
} 
 
/*progressbar*/ 
 
#progressbar { 
 
\t margin-bottom: 30px; 
 
\t overflow: hidden; 
 
\t /*CSS counters to number the steps*/ 
 
\t counter-reset: step; 
 
} 
 
#progressbar li { 
 
\t list-style-type: none; 
 
\t color: white; 
 
\t text-transform: uppercase; 
 
\t font-size: 9px; 
 

 
\t /* width should be 100 divided by the number of steps */ 
 
\t /* this is set in the code dynamically in javascript */ 
 
\t width: 12.5%; 
 

 
\t float: left; 
 
\t position: relative; 
 
} 
 
#progressbar li:before { 
 
\t content: counter(step); 
 
\t counter-increment: step; 
 
\t width: 20px; 
 
\t line-height: 20px; 
 
\t display: block; 
 
\t font-size: 10px; 
 
\t color: #333; 
 
\t background: white; 
 
\t border-radius: 3px; 
 
\t margin: 0 auto 5px auto; 
 
} 
 
/*progressbar connectors*/ 
 
#progressbar li:after { 
 
\t content: ''; 
 
\t width: 100%; 
 
\t height: 2px; 
 
\t background: white; 
 
\t position: absolute; 
 
\t left: -50%; 
 
\t top: 9px; 
 
\t z-index: -1; /*put it behind the numbers*/ 
 
} 
 
#progressbar li:first-child:after { 
 
\t /*connector not needed before the first step*/ 
 
\t content: none; 
 
} 
 
/*marking active/completed steps green*/ 
 
/*The number of the step and the connector before it = green*/ 
 
#progressbar li.active:before, #progressbar li.active:after{ 
 
\t background: #27AE60; 
 
\t color: white; 
 
} 
 

 
.k-dropdown { 
 
    width: 100%; 
 
} 
 
.k-state-selected.k-state-focused { 
 
    background-color: #27AE60; 
 
    border: 0; 
 
} 
 

 
#surveyForm hr { 
 
    border: 0; 
 
    height: 0; 
 
    border-top: 1px solid rgba(0, 0, 0, 0.1); 
 
    border-bottom: 1px solid rgba(255, 255, 255, 0.3); 
 
\t margin-bottom: 10px; 
 
} 
 

 

 
/* https://stackoverflow.com/a/17541916/1550052 */ 
 

 

 
.rad, 
 
.ckb{ 
 
    cursor: pointer; 
 
    user-select: none; 
 
    -webkit-user-select: none; 
 
    -webkit-touch-callout: none; 
 
    padding: 10px; 
 
    /*float: left;*/ 
 
} 
 

 
label { 
 
    display:block; 
 
} 
 

 
.rad > input, 
 
.ckb > input{ /* HIDE ORG RADIO & CHECKBOX */ 
 
    visibility: hidden; 
 
    position: absolute; 
 
} 
 
/* RADIO & CHECKBOX STYLES */ 
 
.rad > i, 
 
.ckb > i{  /* DEFAULT <i> STYLE */ 
 
    display: inline-block; 
 
    vertical-align: middle; 
 
    width: 16px; 
 
    height: 16px; 
 
    border-radius: 50%; 
 
    transition: 0.2s; 
 
    box-shadow: inset 0 0 0 8px #fff; 
 
    border: 1px solid #d3d3d3; 
 
    background: #666; 
 
    margin-right: 4px; 
 
} 
 
/* CHECKBOX OVERWRITE STYLES */ 
 
.ckb > i { 
 
    width: 25px; 
 
    border-radius: 3px; 
 
} 
 
.rad:hover > i{ /* HOVER <i> STYLE */ 
 
    box-shadow: inset 0 0 0 3px #fff; 
 
    background: #666; 
 
} 
 
.rad > input:checked + i{ /* (RADIO CHECKED) <i> STYLE */ 
 
    box-shadow: inset 0 0 0 3px #fff; 
 
    background: #27AE60; 
 
} 
 
/* CHECKBOX */ 
 
.ckb > input + i:after{ 
 
    content: ""; 
 
    display: block; 
 
    height: 12px; 
 
    width: 12px; 
 
    margin: 2px; 
 
    border-radius: inherit; 
 
    transition: inherit; 
 
    background: #d3d3d3; 
 
} 
 
.ckb > input:checked + i:after{ /* (RADIO CHECKED) <i> STYLE */ 
 
    margin-left: 11px; 
 
    background: #27AE60; 
 
}
<body class='body_S'> \t 
 

 
    \t <div class='outerDiv_S'> 
 
\t \t <!-- progressbar --> 
 
\t \t <ul id='progressbar'> 
 
      <li>First</li><li>Second</li><li>Third</li><li>Fourth</li><li>Fifth</li><li>Sixth</li><li>Seventh</li><li>Eighth</li> \t \t 
 
\t \t </ul> 
 
     <span class='reqFieldText_S reqSpan_S'><span class='reqFieldStar'>*</span> indicates required field</span> 
 
    </div> 
 
    
 

 
\t <form id='surveyForm'> 
 
     
 

 
     
 
\t \t <!-- fieldsets --> 
 
\t \t <fieldset > 
 
<h2 class="fs-title"> 
 
\t Title 
 
    <br /><br /><br /><br /><br /><br /><br /><br /> 
 
</h2> 
 
<h2 class="fs-subtitle"> 
 
\t Subheading 
 
</h2> 
 
      <br /><br /> 
 
<h2 class="fs-subtitle"> 
 
\t 1 
 
</h2> 
 
<label>Type of Business 
 
</label> 
 
<br /> 
 

 
<label class="ckb" for="cb-638-0"> 
 
<input type="checkbox" name="cb-638" id="cb-638-0" value="3223" /> 
 

 
<i></i>Accommodations 
 
</label> 
 
      
 
      <br /><br /> 
 
      
 
<label class="ckb" for="cb-638-1"> 
 
<input type="checkbox" name="cb-638" id="cb-638-1" value="3224" /> 
 

 
<i></i>Activities 
 
</label> 
 
<label class="ckb" for="cb-638-2"> 
 
<input type="checkbox" name="cb-638" id="cb-638-2" value="3225" /> 
 

 
<i></i>Association 
 
</label> 
 
<label class="ckb" for="cb-638-3"> 
 
<input type="checkbox" name="cb-638" id="cb-638-3" value="3226" /> 
 

 
<i></i>Convention 
 
</label> 
 
<label class="ckb" for="cb-638-4"> 
 
<input type="checkbox" name="cb-638" id="cb-638-4" value="3227" /> 
 

 
<i></i>Convention Centre 
 
</label> 
 
<label class="ckb" for="cb-638-5"> 
 
<input type="checkbox" name="cb-638" id="cb-638-5" value="3228" /> 
 

 
<i></i>Cruise Line 
 
</label> 
 
<label class="ckb" for="cb-638-6"> 
 
<input type="checkbox" name="cb-638" id="cb-638-6" value="3229" /> 
 

 
<i></i>Destination 
 
</label> 
 
<label class="ckb" for="cb-638-7"> 
 
<input type="checkbox" name="cb-638" id="cb-638-7" value="3230" /> 
 

 
<i></i>Destination 
 
</label> 
 
<label class="ckb" for="cb-638-8"> 
 
<input type="checkbox" name="cb-638" id="cb-638-8" value="3231" /> 
 

 
<i></i>Event 
 
</label> 
 
<label class="ckb" for="cb-638-9"> 
 
<input type="checkbox" name="cb-638" id="cb-638-9" value="3232" /> 
 

 
<i></i>Technology 
 
</label> 
 
<label class="ckb" for="cb-638-10"> 
 
<input type="checkbox" name="cb-638" id="cb-638-10" value="3233" /> 
 

 
<i></i>Transportation 
 
</label> 
 
<label class="ckb" for="cb-638-11"> 
 
<input type="checkbox" name="cb-638" id="cb-638-11" value="3234" /> 
 

 
<i></i>Tourism 
 
</label> 
 
<label class="ckb" for="cb-638-12"> 
 
<input type="checkbox" name="cb-638" id="cb-638-12" value="3235" /> 
 

 
<i></i>Venues 
 
</label> 
 

 

 

 

 
</fieldset> 
 

 

 

 
     
 
\t </form> \t 
 
</body> 
 
</html>

+1

そして、何で回答で問題だったために求めているものの実施例でありますもう一つの質問? –

+3

例のHTMLとCSSを問題の原因となっている部分のみにカットすることを検討してください。 [mcve]のように。そのままでは、進歩バーのためにCSSを探さなければなりません。この修正は 'position:fixed'を適用するのと同じくらい簡単です。残念ながら、私がそれを行うと、ソリューションがアプリケーションに常に適用されるとは限りません。 –

+0

しかし、ポイントを取った。 – etw3

答えて

3

位置を追加してみてください:固定; outerDiv_S

.outerDiv_S { 
    position: fixed; 
} 

に何これが行うことは、それが一つの位置にdiv要素を確保したときにユーザーがスクロール、ページを下に移動しませんです。

divやその他のコンテンツの位置を固定するには、スタイリングを行う必要があります。

あなたがする必要があるスタイリングは、ここでは、この

.outerDiv_S { 
    width: 85%; 
    margin: 0px auto; 
    text-align: center; 
    position: fixed; 
    left: 0; 
    right: 0; 
    top: 0; 
    z-index: 9999; 
    padding-top: 80px; 
    box-sizing: border-box; 
    background-color: #000; 
} 

ようになりますあなたは

https://jsfiddle.net/ofk6tq50/1/

+0

私はdivを修正することができましたが、コンテンツはまだそれの上にスクロールします。 – etw3

+1

はい、固定div /その他のコンテンツを適切に配置するにはCSSを行う必要があります –

+1

編集のための@hohannes –

関連する問題