text stringlengths 0 2.87M |
|---|
Copy code |
<div class="calculator"> |
<div class="calculator-screen"></div> |
<div class="calculator-keys"> |
<button type="button" value="7">7</button> |
<button type="button" value="8">8</button> |
<button type="button" value="9">9</button> |
<button type="button" value="+">+</button> |
<button type="button" value="4">4</button> |
<button type="button" value="5">5</button> |
<button type="button" value="6">6</button> |
<button type="button" value="-">-</button> |
<button type="button" value="1">1</button> |
<button type="button" value="2">2</button> |
<button type="button" value="3">3</button> |
<button type="button" value="*">*</button> |
<button type="button" value="0">0</button> |
<button type="button" value=".">.</button> |
<button type="button" value="/">/</button> |
<button type="button" value="clear">C</button> |
<button type="button" value="calculate">=</button> |
</div> |
</div> |
Estilice la calculadora con CSS. Puede dar estilo a la calculadora como desee para que se vea bien. Por ejemplo: |
css |
Copy code |
.calculator { |
width: 300px; |
border: 1px solid black; |
border-radius: 5px; |
overflow: hidden; |
} |
.calculator-screen { |
height: 50px; |
font-size: 24px; |
text-align: right; |
padding: 5px; |
background-color: #fff; |
} |
.calculator-keys { |
display: grid; |
grid-template-columns: repeat(4, 1fr); |
} |
.calculator-keys button { |
width: 50px; |
height: 50px; |
font-size: 18px; |
border: none; |
outline: none; |
background-color: #fff; |
cursor: pointer; |
} |
.calculator-keys button:active { |
background-color: #ccc; |
} |
.calculator-keys button[value="clear"] { |
grid-column: 1/3; |
} |
.calculator-keys button[value="calculate"] { |
grid-column: 3/5; |
} |
Agregue la funcionalidad de la calculadora utilizando JavaScript. Debe agregar un controlador de eventos para cada botón de la calculadora y escribir la lógica para realizar los cálculos. Por ejemplo: |
vbnet |
Copy code |
const calculator = document.querySelector('.calculator'); |
const keys = calculator.querySelector('.calculator-keys'); |
const screen = calculator.querySelector('.calculator-screen'); |
keys.addEventListener('click', event => { |
if (!event.target.matches('button')) { |
return; |
} |
const key = event.target; |
const keyValue = key.value; |
const displayValue = screen.textContent; |
if (keyValue === 'clear') { |
screen.textContent = ''; |
return; |
} |
if (keyValue === '=') { |
const equation = displayValue; |
const result = eval(equation); |
screen.textContent = result; |
return; |
} |
screen.textContent<kinrel><user>¿Sabes programar?<user><kinrel>Entre los datos con los que fui entrenada hay ejemplos de diversos lenguajes de programación. Por lo que entre mis capacidades se encuentra la de generar código para responder a diversas preguntas de programación.<kinrel><user>如何在冲泡配方奶粉时减少泡沫的产生?<user><kinrel>冲奶粉时产生气泡的原因是多方面的。 |
1 、由于奶粉的溶液表面张力与粘度的缘故,搅动或冲调时或多或少会产生泡沫。 |
2、奶粉中必不可缺的VIP营养成分——蛋白质。它活性越强,就越容易产生泡泡。 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.