Making nice buttons with css and javascript

A button made in html, css and javascript.

The html and javascript code.

<html>

<head>
<style>

@import "button54.css"
</style>


</head>

<body>
<!-- HTML !-->
<!-- debug -->

<button id="b1" class="button-54" onclick="button_clicked()">Click me</button>
<div id="inspect">...</div>



<!-- code -->

<script>

function button_clicked(){
	b1 = document.getElementById("b1")
	b1.innerHTML = "You got me";
	inspect = document.getElementById("inspect");
	inspect.innerHTML = b1.innerHTML;
}

</script>
</body>

</html>

The css

/* CSS */
.button-54 {
  font-family: "Open Sans", sans-serif;
  font-size: 16px;
  letter-spacing: 2px;
  text-decoration: none;
  text-transform: uppercase;
  color: #000;
  cursor: pointer;
  border: 3px solid;
  padding: 0.25em 0.5em;
  box-shadow: 1px 1px 0px 0px, 2px 2px 0px 0px, 3px 3px 0px 0px, 4px 4px 0px 0px, 5px 5px 0px 0px;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.button-54:active {
  box-shadow: 0px 0px 0px 0px;
  top: 5px;
  left: 5px;
}

@media (min-width: 768px) {
  .button-54 {
    padding: 0.25em 0.75em;
  }
}
the button n. 54
button 82
First part
Second part

You can find the second part of the code here

How to create buttons with javascript with the help of pyhton

The repository

https://github.com/formazione/html_buttons


Subscribe to the newsletter for updates
Tkinter templates
Avatar My youtube channel

Twitter: @pythonprogrammi - python_pygame

Videos

Speech recognition game

Pygame's Platform Game

Other Pygame's posts

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.