我有一个按钮,前任创建的,但当在智能手机或缩小浏览器窗口查看,文字缩小,几乎难以辨认.我也创建了自己的按钮,没有这个问题,但我试图找出如何修复旧的,看看问题在哪里.我想这是因为他们的字体大小是大众,而我的是一个设置像素量,但我不确定.:(
/* 旧:*/
.Button-transparent03 {
display: inline-flex;
height: 6vh;
width: 17vw;
line-height: 2em;
padding: 0.2em;
margin: 0.3em;
border: 6px solid #2b547e;
border-radius: 13px;
font-size: 1vw;
font-weight: bold;
text-align: center;
/* display: flex; */
justify-content: center;
align-items: center;
background-color: transparent;
word-wrap: break-word;
}
.Button-transparent03:hover {
color: #001f3f;
/* background-color: white; */
background-image: url("/buttons/WTR-landscape.jpg");
color: white;
}
字符串
/* 新增 */
/* Hot Topic Button */
.Button-solid {
display: inline-flex;
color: white;
border: 6px solid #5ce1e6;
border-radius: 13px;
font-family: Arial;
text-transform: uppercase;
text-align: center;
line-height: 1;
font-size: 18px;
font-weight: bold;
background-color: #083f5c;
padding: 10px;
outline: none;
}
.Button-solid:hover {
font-size: 18px;
color: white;
background-color: #083f5c;
}
型
See the difference between the old buttons and my new one
我已经尝试使用px而不是大众的旧按钮,但它只是在一个混乱的结果。
Testing out a px size to see what happens的
2条答案
按热度按时间col17t5w1#
我已经创建了一个代码片段,其中包含您的前任旧按钮,您的新按钮和一个修订的旧按钮。
我将测量单位从基于viewport大小的单位改为明确定义的单位,从em & vw/vh改为px,这样按钮设计就可以保持一致,无论viewport大小如何。
一些CSS属性在添加了特定的宽度和高度后变得多余,所以我删除了不再相关的属性。
如果按钮需要调整屏幕大小,你可以使用媒体查询来完成这一点。我添加了一个600 px宽的较小屏幕尺寸的示例:
个字符
o2gm4chl2#
是的,这是因为你使用的是视口单位。另外,你不需要设置按钮的宽度和高度,使用填充来控制按钮的大小。
个字符
p.s你不需要使用CSS将按钮文本居中,它默认居中。