需要一段HTML CSS代码 让一张图片居中显示PC端图片宽度60移动端图片宽度80在下面再显示两个按钮也要居中
以下是一段HTML和CSS代码,可以实现图片居中显示,PC端图片宽度为60%,移动端图片宽度为80%,并在下方居中显示两个按钮:
<!DOCTYPE html>
<html>
<head>
<style>
.container {
text-align: center;
}
img {
width: 60%;
}
@media screen and (max-width: 600px) {
img {
width: 80%;
}
}
.buttons {
display: flex;
justify-content: center;
margin-top: 20px;
}
.button {
margin: 0 10px;
}
</style>
</head>
<body>
<div class="container">
<img src="your_image.jpg" alt="Image">
<div class="buttons">
<button class="button">Button 1</button>
<button class="button">Button 2</button>
</div>
</div>
</body>
</html>
你需要将your_image.jpg替换为你自己的图片路径。这段代码将图片居中显示,PC端图片宽度为60%,移动端图片宽度为80%。在图片下方,两个按钮会居中显示。
原文地址: https://www.cveoy.top/t/topic/i3FZ 著作权归作者所有。请勿转载和采集!