不改变任何HTML代码,我需要三个按钮,分别对应每个图像,当我点击第一个按钮时,我需要将第二和第三幅图像的透明度设置为0%,第一幅图片设置为100%,其他两个按钮同理。
body {
font-family: Avenir, sans-serif;
}
h1 {
text-align: center;
font-weight: 100;
}
#works {
display: flex;
}
#works figure {
transition: 1s opacity;
}
#works figure img {
width: 100%;
margin-bottom: 1rem;
}
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>Sculptors and Architects of the Italian Renaissance</title>
</head>
<body>
<h1>Sculptors and Architects of the Italian Renaissance</h1>
<div id="works">
<figure data-artist="michelangelo">
<img src="david.jpg" alt>
<figcaption>Head of <i>David</i>, Michelangelo (c. 1501)</figcaption>
</figure>
<figure data-artist="donatello">
<img src="david-plaster.jpg" alt>
<figcaption>Detail from painted plaster replica of Donatello's bronze <i>David</i> (c. 1430)</figcaption>
</figure>
<figure data-artist="brunelleschi">
<img src="florence-cathedral.jpg" alt>
<figcaption>Dome of Florence Cathedral by Filippo Brunelleschi (1436)</figcaption>
</figure>
</div>
<div id="controls">
<button id="button">Michelangelo</button>
<button id="button2">Donatello</button>
<button id="button3">Brunelleschi</button>
</div>
<script>
</script>
</body>
</html>