cancel
Showing results for 
Search instead for 
Did you mean: 

how to create this clicked big circle button and selected circularly the small circle button

miker
Visitor

hi, every teacher! i need click the big green circle button, then the small circle button will trun green ,each click and small button turn more one , how to realize this function?nilfisk_800_480.png

 

4 REPLIES 4
mimi
Visitor

To create this kind of functionality — where clicking the big green circle button makes the small circular buttons turn green one by one — you could write something like this in HTML, CSS, and JavaScript. Let me know if you’d like me to put this into a code canvas so it’s easier to tweak!

Here’s a simple approach:

<!DOCTYPE html>
<html>
<head>
<style>
.big-button {
width: 80px;
height: 80px;
background-color: green;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 20px;
cursor: pointer;
}

.small-button {
width: 30px;
height: 30px;
border-radius: 50%;
background-color: gray;
display: inline-block;
margin: 5px;
}

.active {
background-color: green;
}
</style>
</head>
<body>
<div class="big-button" onclick="activateButton()">✔</div>

<div id="small-buttons">
<div class="small-button"></div>
<div class="small-button"></div>
<div class="small-button"></div>
</div>

<script>
let currentIndex = 0;

function activateButton() {
const buttons = document.querySelectorAll('.small-button');
if (currentIndex < buttons.length) {
buttons[currentIndex].classList.add('active');
currentIndex++;
}
}
</script>
</body>
</html>

LouisB
ST Employee

Hello @miker,

Sorry but I don't get everything, could you be more explicit, add a step by step explanation on what you want to achieve exactly.

BR,

Louis BOUDO
ST Software Developer | TouchGFX

miker_0-1740388756226.png

when I click '1', picture '3' is hide; when I click '1' again, picture '3' will be showed , this action is executed circularly 

 

 

 

 

LouisB
ST Employee

Hello @miker,

I saw that you created another post for the exact same question : https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/how-to-use-the-button-is-clicked-to-show-or-hide-the-image/m-p/775887.

Please don't spam the forum, and only create one topic for your question.

Regards, 

Louis BOUDO
ST Software Developer | TouchGFX