2017-06-05 78 views
0

我有一個單選按鈕的問題。 我試圖修復背景上的單選按鈕,就像其他元素一樣。 但是現在當我縮小頁面時,它們會隨着背景滾動。 你能幫我嗎? 在此先感謝! 例如:單選按鈕滾動背景,如何解決這個問題?

Screenshot

label[class=number]::before { 
 
    counter-increment: section; 
 
    content: counter(section) " " ; 
 
    display: inline-block; 
 
    color: white; 
 
    width: 20px; 
 
    background-color: black; 
 
    text-align: center; 
 
    padding-top: 1%; 
 
    margin-left: 10px; 
 
    padding-bottom: 1%; 
 
} 
 

 
label[class=number] { 
 
\t display: inline-block; 
 
    margin-top: 20px; 
 
    width: 345px; 
 
} 
 

 
#bestellen input[type=number], #bestellen input[type=text], select { 
 
\t width: 40px; 
 
    margin-left: 102%; 
 
    display: block; 
 
    margin-top: -7%; 
 
    border-color: skyblue; 
 
    border-style: double; 
 
} 
 

 
input[type=range] { 
 
    width: 40px; 
 
    position: relative; 
 
    margin-left: 102%; 
 
    background-color: transparent; 
 
    margin-top: -5%; 
 
    display: block; 
 
} 
 

 
small { 
 
\t display: block; 
 
    margin-left: 420px; 
 
    margin-top: -1.5%; 
 
}
<form id="bestellen" action="http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echo.cgi"> 
 
     <label class="number" id="David_Vann">David Vann - Aquarium: <input size="3" name="David_Vann" type="number" min="1"></label><small> Max. 10 exemplaren</small> 
 
     <label class="number" id="Robert_Seethaler">Robert Seethaler - Een heel leven: <input size="3" name="Robert_Seethaler" type="text" pattern="[0-9]{2}"></label><small> Max. 99 exemplaren</small> 
 
     <label id="Paula" class="number">Paula Hawkins - Het meisje in de trein: <input name="Paula_Hawkins" type="range" min="0" max="15" step="5" list="Paula_Hawkins"></label><small>Bestel 0, 5, 10 of 15 exemplaren</small> 
 
      <datalist id="Paula_Hawkins"> 
 
      <option value="0"> 
 
      <option value="5"> 
 
      <option value="10"> 
 
      <option value="15"> 
 
     </datalist> 
 
     <label class="number" id="Ernest_van_der_kwast">Ernest van der Kwast - De ijsmakers: </label> 
 
     <label id="ernest"> <input type="radio" name="Ernest van der kwast" value="1">1</label> 
 
     <label id="ernest"> <input type="radio" name="Ernest van der kwast" value="10">10</label> 
 
     <label id="ernest"> <input type="radio" name="Ernest van der kwast" value="20">20</label><br> 
 
     <label class="number" id="Bert_natter">Bert Natter - Remington: 
 
      <select name="Bert Natter"> 
 
       <option value="geen">geen</option> 
 
       <option value="1">1</option> 
 
       <option value="2">2</option> 
 
       <option value="3">3</option> 
 
       <option value="4">4</option> 
 
       <option value="5">5</option> 
 
       <option value="6">6</option> 
 
       <option value="7">7</option> 
 
       <option value="8">8</option> 
 
       <option value="9">9</option> 
 
       <option value="10">10</option> 
 
      </select> 
 
     </label> 
 
    </form>

+0

不會導致此問題,但ID對於文檔應該是唯一的。換句話說,你不能重複三次

回答

0
如果你想設置單選按鈕後,標籤然後更新代碼和標籤標記後移動輸入無線電

<label id="ernest"> 1<input type="radio" name="Ernest van der kwast" value="1"></label> 
<label id="ernest"> 10<input type="radio" name="Ernest van der kwast" value="10"></label> 
<label id="ernest"> 20<input type="radio" name="Ernest van der kwast" value="20"></label><br> 
+0

謝謝你的回答!但我遇到的問題是,當我使頁面變小時,單選按鈕將與背景一起滾動。它們必須像其他元素一樣被修復。你知道怎麼做嗎? – Jolanda

+0

resposive? .... ?? –

+0

你想讓它承擔責任嗎? –

0

label[class=number]::before { 
 
    counter-increment: section; 
 
    content: counter(section) " " ; 
 
    display: inline-block; 
 
    color: white; 
 
    width: 20px; 
 
    background-color: black; 
 
    text-align: center; 
 
    padding-top: 1%; 
 
    margin-left: 10px; 
 
    padding-bottom: 1%; 
 
} 
 

 
label[class=number] { 
 
\t display: inline-block; 
 
    margin-top: 20px; 
 
    width: 345px; 
 
} 
 

 
#bestellen input[type=number], #bestellen input[type=text], select { 
 
\t width: 40px; 
 
    margin-left: 102%; 
 
    display: block; 
 
    margin-top: -7%; 
 
    border-color: skyblue; 
 
    border-style: double; 
 
} 
 

 
input[type=range] { 
 
    width: 40px; 
 
    position: relative; 
 
    margin-left: 102%; 
 
    background-color: transparent; 
 
    margin-top: -5%; 
 
    display: block; 
 
} 
 

 
small { 
 
\t display: block; 
 
    margin-left: 420px; 
 
    margin-top: -1.5%; 
 
}
<form id="bestellen" action="http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echo.cgi"> 
 
     <label class="number" id="David_Vann">David Vann - Aquarium: <input size="3" name="David_Vann" type="number" min="1"></label><small> Max. 10 exemplaren</small> 
 
     <label class="number" id="Robert_Seethaler">Robert Seethaler - Een heel leven: <input size="3" name="Robert_Seethaler" type="text" pattern="[0-9]{2}"></label><small> Max. 99 exemplaren</small> 
 
     
 
     <label id="Paula" class="number">Paula Hawkins - Het meisje in de trein: <input name="Paula_Hawkins" type="range" min="0" max="15" step="5" list="Paula_Hawkins"></label><small>Bestel 0, 5, 10 of 15 exemplaren</small> 
 
      <datalist id="Paula_Hawkins"> 
 
      <option value="0"> 
 
      <option value="5"> 
 
      <option value="10"> 
 
      <option value="15"> 
 
     </datalist> 
 
     <br> 
 
      
 
      
 
     <label class="number" id="Ernest_van_der_kwast">Ernest van der Kwast - De ijsmakers: </label> 
 
     
 
     1<label id="ernest"> <input type="radio" name="Ernest van der kwast" value="1"></label> 
 
     10<label id="ernest"> <input type="radio" name="Ernest van der kwast" value="10"></label> 
 
     20<label id="ernest"> <input type="radio" name="Ernest van der kwast" value="20"></label><br> 
 
     
 
     
 
     <label class="number" id="Bert_natter">Bert Natter - Remington: 
 
      <select name="Bert Natter"> 
 
       <option value="geen">geen</option> 
 
       <option value="1">1</option> 
 
       <option value="2">2</option> 
 
       <option value="3">3</option> 
 
       <option value="4">4</option> 
 
       <option value="5">5</option> 
 
       <option value="6">6</option> 
 
       <option value="7">7</option> 
 
       <option value="8">8</option> 
 
       <option value="9">9</option> 
 
       <option value="10">10</option> 
 
      </select> 
 
     </label> 
 
    </form>

+0

自己的代碼塊通常不是有用的答案,並且更有可能吸引downvotes。請解釋您所展示的解決方案的功能,以及該代碼爲什麼/如何回答這個問題。 –

+0

@Jolanda你想resposive單選按鈕,我認爲?? right –

+0

@Jolanda嘗試在標籤中使用class =「radio-inline」,並在標頭中包含bootstrap css .. –