javascript - 如何使这些按钮响应?

标签 javascript html css

我有一个 HTMl 和一个 CSS 实例。

我正在尝试根据屏幕尺寸使这些按钮变小并关联到一列中。现在,当我更改窗口大小时,按钮就会消失。

/* grid */ 

.col-1of1 {
width: 100%;
margin-left: auto;
margin-right: auto;

}

.col-1of2 {
width: 50%;
float: left;
}

.col-1of3 {
width: 33.33%;
float: left;
}

.col-1of4 {
width:25%;
float: left;    
}

.col-1of5 {
width: 20%;
float: left;
}

#p-button {
font-size: 1.5vmin;
color: white;
background: #F0AB00;
    position: relative;
width: 200px;
min-width:20px;
height: 50px;
border-radius: 6px;
margin-top: 180px;
margin-right: 25px;
margin-left: 25px;
line-height: 50px;
text-align: center;

    -webkit-transition-duration: 0.3s; /* Safari */
transition-duration: 0.3s;
}

#p-button: hover {
background: #970A82;
}
<p id="player-text">Please select the number of players</p>

<div class="col-1of1" id="options">
<a href="form1.html?player=1&form=1"><p class="col-1of4" id="p-
button">1 Player</p></a> <!--button--> 
<a href="form1.html?player=2&form=1"><p class="col-1of4" id="p-
button">2 Players</p></a> 
<!--button--> 
<a href="form1.html?player=3&form=1"><p class="col-1of4" id="p-
button">3 Players</p></a> <!--button--> 
<a href="form1.html?player=4&form=1"><p class="col-1of4" id="p-
button">4 Players</p></a> <!--button--> 
</div>

最佳答案

您可以使用媒体查询。例如。

@media(max-width: 767px){
    #p-button{
        font-size: 1vmin;
        width: 100px;
    }
}

关于javascript - 如何使这些按钮响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44010228/

相关文章:

javascript - 使用 jQuery 无限滚动固定数量的 li 元素

css - 删除 Microsoft Edge(以前称为 Project Spartan)中的 'x' 输入装饰

html - 我们如何在css中添加点凸起效果?

jquery - 负边距点击应该不起作用

html - 屏幕左右两侧的单独页脚

javascript - 单击 anchor 和图像映射导致页面不必要地移动

javascript - NodeJS 异步函数与 mongoose

javascript - 尝试提取字符串的子字符串,直到字符串的第一个数字

html - span 与文本和无文本的对齐方式不同

javascript - 如何在 switch 语句中的字符串上使用正则表达式?