html - 如何使按钮标签在移动视图中可见
问题描述
在我的博客中,我以两种不同的方式自定义了按钮标签,它们的代码如下:
.button1 {
border: 2px solid rgb(0, 0, 0);
box-sizing: inherit;
background-color: #ffffff;
margin-right: 1.7px;
color: black;
font-size: 18px;
font-weight: 980;
padding: 6px 32px;
text-align: center;
transition: all 0.3s ease-in-out 0s;
width: 96.6px;
text-decoration: none;
line-height: 22px;
font-size: 16px;
font-family: domine;
display: inline-table;
}
.button2 {
border: 2px solid rgb(255, 87, 51);
background-color: #FF5733;
box-sizing: inherit;
margin-right: 1.7px;
color: white;
font-size: 18px;
font-weight: 980;
padding: 6px 42px;
text-align: center;
transition: all 0.3s ease-in-out 0s;
width: 96.6px;
text-decoration: none;
line-height: 22px;
font-size: 16px;
font-family: domine;
display: inline-table;}
.button2:hover {
background-color: #FF5733;
color: #000000;}
但是有一个问题,我所做的自定义在移动视图中不可见,它显示为默认自定义。我应该如何将这些自定义实现到移动视图?帮我。
顺便说一句,我使用这些代码:
@media screen and (max-width: 390px) {
.button2 { padding: 6px 32px;width: 84.6px;font-size: 16px;display: inline-table;
}
@media screen and (max-width: 390px) {
.button1 { width: 76.6px;}
}}
使按钮标签自定义在移动视图中可见。我已经将这些代码粘贴在博主博客的 CSS 区域,但在移动视图中没有看到任何效果,如果我使用错误的代码或将代码粘贴到错误的位置,请帮助我。
解决方案
首先,这是一件简单的事情,但很多人都做错了:确保将@media 代码放在其他代码的下方。其次,如果您有相同的@media 屏幕和 (max-width: 390px),为什么不将两个按钮样式放在同一个@media 中?像这样:
@media screen and (max-width: 390px) {
.button2 { padding: 6px 32px;width: 84.6px;font-size: 16px;display: inline-table;
}
.button1 { width: 76.6px;}
}
哦,这个 css 应该使用模板的编辑 html 选项放置。
推荐阅读
- azure - 存储帐户中的 Terraform 状态文件
- r - 在 R 中提取相交值
- angular - ngx-formly 中表单字段的更改事件
- google-apps-script - 将传感器数据从 ESP8266 发送到 Google 表格
- flutter - Flutter - 如何使 ListTile(或 Row)的内容居中(垂直)?
- flutter - 如何在下拉列表中动态添加数据?
- python - 在excel中导出格式时出现openpyxl问题
- javascript - reactjs模式没有显示
- webdriver-io - 使用 Webdriver IO,我正在尝试比较两个屏幕(一个在单击按钮之前,一个在单击按钮之后)并期望它们有所不同
- javascript - Docker 映像无法在 localhost 上连接