admin管理员组文章数量:1336659
I am making an android mobile app using HTML and JavaScript with CSS. The problem is, I sent it to my friend to test, and the buttons are tiny on his screen. Using CSS, I changed the button size by changing text size in CSS. Is there a way that I could have the button size change automatically so that it is proportional to the screen size? If not, how would I make the buttons bigger for larger screens, and smaller for smaller screens?
Please note: I am only using HTML, JavaScript, and CSS. If you give me anything else, please mane it possible to copy and paste because I will not know how to incorporate it in my code.
I am making an android mobile app using HTML and JavaScript with CSS. The problem is, I sent it to my friend to test, and the buttons are tiny on his screen. Using CSS, I changed the button size by changing text size in CSS. Is there a way that I could have the button size change automatically so that it is proportional to the screen size? If not, how would I make the buttons bigger for larger screens, and smaller for smaller screens?
Please note: I am only using HTML, JavaScript, and CSS. If you give me anything else, please mane it possible to copy and paste because I will not know how to incorporate it in my code.
Share Improve this question asked Feb 9, 2015 at 4:18 FyrebendFyrebend 1332 gold badges2 silver badges9 bronze badges 1- refer to this link stackoverflow./questions/11777598/… – Arpit Srivastava Commented Feb 9, 2015 at 4:28
3 Answers
Reset to default 2It sounds like you want a 'responsive' design, use media-queries and 'breakpoints'.
The breakpoints will be the width for each device you want to support.
for an iphone 5 you would use '641px' as the max width.
you first define the standard class. Then deviate from that using the media queries with css like so
#button{
width:100%; // first define your class
}
@media (max-width: 640px) {
#button {
width:50%;
}
}
http://iosdesign.ivomynttinen.
It probably be done by adding this tag in header
<meta name="viewport" content="width=device-width" />
or/and setting width in percentage.
ex.
<input type="text" style="width:30%" />
You need to use the meta tag for responsive:
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
The HTML:
<input type="submit" name="" class="my_button"/>
The CSS:
input.my_button{
width:50%;
height:32px;
display:table;
margin:0 auto;
}
@media screen and (max-width:360px){
input.my_button{
width:100%;
}
}
本文标签: javascriptAutomatically resize HTML buttons based onscreen sizeStack Overflow
版权声明:本文标题:javascript - Automatically resize HTML buttons based onscreen size? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742419836a2471434.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论