So I have this css code to define a <div class='mc-menu' id ='menu'>
JavaScript
x
39
39
1
.mc-menu {
2
--btn-size: 30pt;
3
display: grid;
4
grid-template-columns: var(--btn-size) calc(var(--btn-size) * 10) var(--btn-size);
5
grid-template-rows: repeat(3, var(--btn-size)) 16px var(--btn-size);
6
grid-template-areas: ". first ." ". second ." ". third ." ". . ." "lang fourth .";
7
grid-gap: 8px;
8
}
9
.mc-menu .mc-button:nth-child(1) {
10
grid-area: first;
11
}
12
.mc-menu .mc-button:nth-child(2) {
13
grid-area: second;
14
}
15
.mc-menu .mc-button:nth-child(3) {
16
grid-area: third;
17
}
18
.mc-menu .double {
19
grid-area: fourth;
20
}
21
.mc-menu .double .mc-button:nth-child(1) {
22
grid-area: left;
23
}
24
.mc-menu .double .mc-button:nth-child(2) {
25
grid-area: right;
26
}
27
.mc-menu .mc-button:nth-child(5) {
28
grid-area: lang;
29
}
30
.mc-menu .double {
31
width: 100%;
32
height: 100%;
33
display: grid;
34
grid-template-columns: 1fr 1fr;
35
grid-template-rows: 1fr;
36
grid-template-areas: 'left right';
37
grid-gap: 8px;
38
}
39
I have this function that does document.getElementById('menu').style.display = 'none';
This resets the styling for this menu. Is it possible to create the CSS using a javascript function
JavaScript
1
6
1
document.getElementById('menu').style.display="grid";
2
document.getElementById('menu').style.gridTemplateColumns = "30pt 300pt 30pt)";
3
document.getElementById('menu').style.gridTemplateRows = 'repeat(3, 30pt) 16px 30pt';
4
document.getElementById('menu').style.gridGap ='8px';
5
document.getElementById('menu').style.gridTemplateAreas = '". first ." ". second ." ". third ." ". . ." "lang fourth ."';
6
doesn’t work. If someone can try and help me make it so that I can use javascript to represent that CSS, it would be greatly appreciated.
EDIT: Full Code Here: https://paste.pythondiscord.com/ijuluwuzab.xml
Advertisement
Answer
if you want hide particular div using JavaScript,
JavaScript
1
2
1
document.getElementById('menu').style.opacity = "0";
2
then if you want that display that div again
JavaScript
1
2
1
document.getElementById('menu').style.opacity = "1";
2
& you can use also this for hide perticular div
JavaScript
1
2
1
document.getElementById('menu').style.display = "none";
2
then for display again
JavaScript
1
2
1
document.getElementById('menu').style.display = "block";
2
Thank You…