如何使用img HTML调整输入的大小

时间:2018-08-02 19:35:11

标签: javascript jquery html css

我想调整输入文本的大小使用移动版本时,但我不知道如何,您能帮我吗 例:如何自动调整较大的[输入文本]的大小,以使其适合较小的div容器,同时保持其宽高比? 这是我的脚本:

<!doctype html>
<html><head>
<meta charset="utf-8">
<title>Ex.</title>
<style>
img {
    width: 100%; /* or any custom size */
    height: 100%; 
    object-fit: contain;
}

</style>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<form id="dr.s1x" onSubmit="return false">
<!-- dr.s1x --> 
 <div id="ph1">
    <img src="https://image.ibb.co/jKF3Dz/Screenshot_2018_07_29_10_50_49.png" ondragstart="return false;"/>
    <input class="gredient_input" type="email" placeholder="Email" id="usr0" name="usr0" style="position: absolute; z-index: 0; visibility: visible; left: 66px; top: 143px; width: 660px; height: 44px;" autocomplete="off" tabindex="1" onKeyDown="doSomething1()" onkeyup="lettersOnly(this)" />
    <input class="gredient_input" type="password" placeholder="Mot de passe" id="usr1" name="usr1" style="position: absolute; z-index: 0; visibility: visible; left: 66px; top: 192px; width: 656px; height: 44px;" autocomplete="off" tabindex="1" onKeyDown="doSomething2()" />
        <a class="close" style="position: absolute; left: 62px; top: 257px; width: 679px; height: 44px; visibility: visible;" onClick="master()"></a>

  </div>
</form>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

像这样

img {
    width: 100%; /* or any custom size */
    height: 100%; 
    object-fit: contain;
}

input {
    width: 100%; /* or any custom size */
    height: 100%; 
    object-fit: contain;
}