要创建两行不同字体大小的按钮,可以使用HTML和CSS来实现。以下是一个简单的示例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Button Example</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="button-container">
<button class="button-large">大按钮</button>
<button class="button-small">小按钮</button>
</div>
</body>
</html>
.button-container {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 20px;
}
.button-large {
font-size: 24px;
padding: 10px 20px;
margin-bottom: 10px;
}
.button-small {
font-size: 16px;
padding: 5px 10px;
}
div
容器,并分别给按钮添加了不同的类名(button-large
和button-small
)。.button-container
:使用Flexbox布局,使按钮垂直排列并居中对齐。.button-large
:设置字体大小为24px,并添加了一些内边距和外边距。.button-small
:设置字体大小为16px,并添加了一些内边距。@media (max-width: 600px) {
.button-large {
font-size: 20px;
}
.button-small {
font-size: 14px;
}
}
通过这种方式,可以确保按钮在不同设备上都能良好显示。
领取专属 10元无门槛券
手把手带您无忧上云