2017-04-17 2 views
-1

가로 행에 4 개의 버튼을 만들고 싶습니다. 변수를 사용하여 'x'좌표를 설정하고 있습니다.php while 루프를 사용하여 일련의 버튼을 만드는 방법은 무엇입니까?

이 코드가 있습니다.

<?php 
$x=0; 
while ($x<1000) 
{ 
    echo $x; 
    echo '<div style="position: absolute;top: 0; left: '.$x.';width: 200px;"> 
    <button style="width: 200px; height: 125px" onclick="this.parentElement.style.display=\'none\'" class="w3-button w3-red"></button> 
    </div>'; 
    $x=$x+250; 
} 
?> 

하지만 버튼 하나만 표시하고 4 버튼은 표시하지 않습니다. 문제가 어디

+0

그것의 내가 실행하면 4 개 버튼을 표시합니다. 한번 더 확인하십시오. 또는 캐시를 지 웁니다. –

+0

당신은 뭔가를 생각해 냈습니까? –

+0

아래 답변은 그것을 분류했습니다. – stilts77

답변

1

당신은 왼쪽 후 픽셀 누락 ... 볼 수 없습니다 :

echo '<div style="position: absolute;top: 0; left: '.$x.'px;width: 200px;"> 

<div class="section result" style="margin-top:80px;"> 
 
    0 
 
    <div style="position: absolute;top: 0; left: 0;width: 200px;"> 
 
    <button style="width: 200px; height: 125px" onclick="this.parentElement.style.display='none'" class="w3-button w3-red">1</button> 
 
    </div>250 
 
    <div style="position: absolute;top: 0; left: 250px;width: 200px;"> 
 
    <button style="width: 200px; height: 125px" onclick="this.parentElement.style.display='none'" class="w3-button w3-red">2</button> 
 
    </div>500 
 
    <div style="position: absolute;top: 0; left: 500px;width: 200px;"> 
 
    <button style="width: 200px; height: 125px" onclick="this.parentElement.style.display='none'" class="w3-button w3-red">3</button> 
 
    </div>750 
 
    <div style="position: absolute;top: 0; left: 750px;width: 200px;"> 
 
    <button style="width: 200px; height: 125px" onclick="this.parentElement.style.display='none'" class="w3-button w3-red">4</button> 
 
    </div> 
 
</div>

+0

고맙습니다. 나는 그것이 효과가 있어야한다는 것을 알았다. – stilts77

관련 문제