Advertisement
giganciprogramowania

lista zakupów

Jun 15th, 2021
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="pl">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>Lista zakupów</title>
  7. <link rel="stylesheet" href="style.css">
  8. </head>
  9. <body>
  10.  
  11.  
  12.  
  13. <div id="dodajElement">
  14.  
  15. <h1>Lista zakupów</h1>
  16.  
  17.  
  18. <input id="element" type="text" maxlength="25">
  19. <button id="przyciskDodaj">Dodaj produkt</button>
  20. <button id="przyciskDrukuj">Drukuj</button>
  21.  
  22. <p id="komunikat">
  23.  
  24.  
  25. </p>
  26.  
  27. </div>
  28.  
  29. <div id="doWydrukowania">
  30. <div id="kontenerLista">
  31.  
  32. <ol id="listaZakupow">
  33.  
  34. </ol>
  35.  
  36.  
  37. </div>
  38. </div>
  39.  
  40.  
  41.  
  42.  
  43. <script>
  44.  
  45. document.getElementById('przyciskDodaj').addEventListener('click',function(){
  46.  
  47. const nowyElement = document.getElementById("element").value.trim();
  48.  
  49. if (nowyElement!=''){
  50. document.getElementById('komunikat').textContent='';
  51. document.getElementById('listaZakupow').innerHTML += '<li>'+nowyElement+'</li>';
  52. document.getElementById('element').value='';
  53. }
  54.  
  55. else{
  56.  
  57. document.getElementById('komunikat').textContent='Uzupełnij pole';
  58. }
  59. });
  60.  
  61.  
  62. document.getElementById('listaZakupow').addEventListener('click', function(e) {
  63.  
  64. const elementListy=e.target;
  65.  
  66. this.removeChild(elementListy);
  67. });
  68.  
  69.  
  70.  
  71.  
  72. document.getElementById('przyciskDrukuj').addEventListener('click', function () {
  73.  
  74. const obszarWydruku = document.getElementById('doWydrukowania').innerHTML;
  75. //ustawiamy obszar wydruku tylko na elementy naszej listy zakupów
  76. document.body.innerHTML = obszarWydruku;
  77. //okno drukowania
  78. window.print();
  79. //odświeżenie całej strony
  80. window.location.reload();
  81. });
  82.  
  83. </script>
  84. </body>
  85. </html>
  86.  
  87.  
  88.  
  89.  
  90. ///////////////////////////////CSS//////////////////////////////
  91.  
  92. @import url('https://fonts.googleapis.com/css?family=Caveat+Brush&display=swap');
  93. body {
  94. background-image:url('https://cdn.glitch.com/c9051263-269d-450f-930e-58a96d981a79%2Fnrd-D6Tu_L3chLE-unsplash.jpg?v=1584791624862');
  95. background-repeat: no-repeat;
  96. background-size: cover;
  97. background-attachment: fixed;
  98. font-family: 'Caveat Brush', cursive;
  99. }
  100.  
  101.  
  102. #dodajElement {
  103.  
  104. margin: 0px auto 0px auto;
  105. width:1000px;
  106. height:350px;
  107. text-align:center;
  108. padding:10px;
  109. background-color:#e8ebe9;
  110. border-radius:80px;
  111. }
  112.  
  113. li{
  114. margin-left:auto;
  115. margin-right:auto;
  116. width:200px;
  117. height:30px;
  118. border-radius:10px;
  119. padding:15px;
  120. }
  121.  
  122. li:hover{
  123.  
  124. color:red;
  125. cursor: pointer;
  126. text-decoration: line-through;
  127. }
  128.  
  129. h1{
  130.  
  131. font-size:80px;
  132. }
  133.  
  134. #kontenerLista{
  135. font-family: 'Caveat Brush', cursive;
  136. font-size:40px;
  137. width:500px;
  138. background-color:#ffd35c;
  139. margin-left:auto;
  140. margin-right:auto;
  141. border-radius:10px;
  142. color:#003a91;
  143. }
  144. #przyciskDodaj, #przyciskDrukuj{
  145. width:180px;
  146. height:70px;
  147. background-color: #fa4a0a;
  148. color: white;
  149. font-size: 16px;
  150. border-radius: 4px;
  151. transition-duration: 0.4s;
  152. border: 2px solid #fa4a0a;
  153. text-transform:uppercase;
  154.  
  155.  
  156. }
  157.  
  158.  
  159. #przyciskDrukuj:hover,#przyciskDodaj:hover {
  160. cursor:pointer;
  161. opacity:0.6;
  162. }
  163.  
  164. input{
  165.  
  166. width: 330px;
  167. height: 30px;
  168. font-family: 'Caveat Brush', cursive;
  169. font-size:20px;
  170. }
  171.  
  172. #komunikat{
  173. color:red;
  174. font-size:24px;
  175. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement