2017-08-13 79 views
-1

爲什麼我的網頁不能響應,我如何使它響應?小屏幕上的按鈕變得笨拙。 [可選]是否有任何方法可以使按鈕尺寸變大並同時創建網站?[可選]響應也可以使用引導程序解決任何問題。按鈕在小屏幕上變得笨拙

Image

HTML:

<!DOCTYPE html> 
<html> 
<head> 
    <title>Calculator</title> 
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script> 
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
    <link rel="stylesheet" type="text/css" href="Calculator.css"> 
</head> 
<body> 
    <div id="container"> 
     <div id="display"> 
     </div> 
     <div id="buttons"> 
      <button id="clear" class="btn btn-default">CLEAR</button> 
      <button value="/" class="btn btn-default">÷</button> 
      <button value="*" class="btn btn-default">x</button><br><br> 
      <button value="7" class="btn btn-default">7</button> 
      <button value="8" class="btn btn-default">8</button> 
      <button value="9" class="btn btn-default">9</button> 
      <button value="-" class="btn btn-default">-</button><br><br> 
      <button value="4" class="btn btn-default">4</button> 
      <button value="5" class="btn btn-default">5</button> 
      <button value="6" class="btn btn-default">6</button> 
      <button value="+" class="btn btn-default">+</button><br><br> 
      <div id="float"> 
       <button value="1" class="btn btn-default">1</button> 
       <button value="2" class="btn btn-default">2</button> 
       <button value="3" class="btn btn-default">3</button><br><br> 
       <button id="zero" value="0" class="btn btn-default">0</button> 
       <button value="." class="btn btn-default">.</button> 
       <button id="equal" class="btn btn-default">=</button> 
      </div> 
     </div> 
    </div> 

    <script type="text/javascript" src="Calculator.js"></script> 
</body> 
</html> 

CSS:

body 
{ 
    background: lightblue; 
} 

#container 
{ 
    text-align: center; 
    margin: 200px auto; 
    width: 10%; 
} 

#display 
{ 
    text-align: right; 
    margin-bottom: 5px; 
    height: 50px; 
    border: 2px solid gray; 
    background: lightblue; 
} 

button 
{ 
    width: 30px; 
} 

.btn-default 
{ 
    background: white; 
    color: black; 
    border: none; 
    outline-style: none; 
} 

.btn-default:hover 
{ 
    background: black; 
    color: white; 
    border: none; 
    outline-style: none; 
} 

#clear, #zero 
{ 
    width: 65px; 
} 

#equal 
{ 
    position: absolute; 
    margin-left: 52px; 
    margin-top: -87px; 
    height: 87px; 
} 

#buttons 
{ 
    display: inline-block; 
} 

#float 
{ 
    float: left; 
} 
+0

「笨拙」對於發生的事情不是一個很好的定義?問題是您無法點擊任何按鈕?或點擊按鈕時不做任何事情?請編輯你的問題。 - 來自食評 - –

回答

0

#container

body 
 
{ 
 
    background: lightblue; 
 
} 
 

 
#container 
 
{ 
 
    text-align: center; 
 
    margin: 200px auto; 
 
    
 
} 
 

 
#display 
 
{ 
 
    text-align: right; 
 
    margin-bottom: 5px; 
 
    height: 50px; 
 
    border: 2px solid gray; 
 
    background: lightblue; 
 
} 
 

 
button 
 
{ 
 
    width: 30px; 
 
} 
 

 
.btn-default 
 
{ 
 
    background: white; 
 
    color: black; 
 
    border: none; 
 
    outline-style: none; 
 
} 
 

 
.btn-default:hover 
 
{ 
 
    background: black; 
 
    color: white; 
 
    border: none; 
 
    outline-style: none; 
 
} 
 

 
#clear, #zero 
 
{ 
 
    width: 65px; 
 
} 
 

 
#equal 
 
{ 
 
    position: absolute; 
 
    margin-left: 52px; 
 
    margin-top: -87px; 
 
    height: 87px; 
 
} 
 

 
#buttons 
 
{ 
 
    display: inline-block; 
 
} 
 

 
#float 
 
{ 
 
    float: left; 
 
}
<!DOCTYPE html> 
 
<html> 
 
<head> 
 
    <title>Calculator</title> 
 
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script> 
 
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 
    <link rel="stylesheet" type="text/css" href="Calculator.css"> 
 
</head> 
 
<body> 
 
    <div id="container"> 
 
     <div id="display"> 
 
     </div> 
 
     <div id="buttons"> 
 
      <button id="clear" class="btn btn-default">CLEAR</button> 
 
      <button value="/" class="btn btn-default">÷</button> 
 
      <button value="*" class="btn btn-default">x</button><br><br> 
 
      <button value="7" class="btn btn-default">7</button> 
 
      <button value="8" class="btn btn-default">8</button> 
 
      <button value="9" class="btn btn-default">9</button> 
 
      <button value="-" class="btn btn-default">-</button><br><br> 
 
      <button value="4" class="btn btn-default">4</button> 
 
      <button value="5" class="btn btn-default">5</button> 
 
      <button value="6" class="btn btn-default">6</button> 
 
      <button value="+" class="btn btn-default">+</button><br><br> 
 
      <div id="float"> 
 
       <button value="1" class="btn btn-default">1</button> 
 
       <button value="2" class="btn btn-default">2</button> 
 
       <button value="3" class="btn btn-default">3</button><br><br> 
 
       <button id="zero" value="0" class="btn btn-default">0</button> 
 
       <button value="." class="btn btn-default">.</button> 
 
       <button id="equal" class="btn btn-default">=</button> 
 
      </div> 
 
     </div> 
 
    </div> 
 

 
    <script type="text/javascript" src="Calculator.js"></script> 
 
</body> 
 
</html>
刪除

1

在使它響應之前,您必須在您的視口中包含一個視口;

<meta name="viewport" content="width=device-width, initial-scale=1.0">