Android неправильно прокручивает фокус ввода, когда тело переполнено-y: скрыто - PullRequest
0 голосов
/ 18 июня 2020

во-первых, я хочу сказать, что я уже нашел здесь аналогичный ответ на этот вопрос, но он не работал со мной, поэтому я хочу другой ответ, возможно, он мог бы решить мою проблему.

  • Примечание: я использовал w3. css для модального окна, используемого в моем коде.

  • в моем теле у меня длинный текст, а в конце я есть кнопка, при нажатии на нее отображается модальное окно, внутри моего модального окна у меня много входов.

  • Я хочу, чтобы при прокрутке модального окна тело под ним не прокручивалось с помощью это, поэтому: я сделал переполнение тела: скрыто.

  • , но # проблема: когда я пытаюсь сфокусироваться на вводе, android не прокручивается правильно и вниз до внизу модального окна.

    Демо:

http://dzboutiques.ga/overFlow.htm

код

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1">
<title>dzBoutiques</title>

<link rel="stylesheet" type="text/css" href="https://www.w3schools.com/w3css/4/w3.css">

<style>
input, textarea
{
margin-top:16px;
padding:16px 0px;
width:100%;
border:1px solid gray;
}
textarea
{
 height:100px;
}
</style>
</head>
<body>

<div class="w3-modal">
<div class="w3-modal-content w3-container"  style="max-width:100%; margin-bottom:70px;">
<input type="text">
<input type="text">
<input type="text">
<input type="text">
<input type="text">
<input type="text">
<input type="text">
<input type="text">
<input type="text">
<input type="text">
<input type="text">
<input type="text">
</div>
</div>

<div class="w3-container">
Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..." "There is no one who loves pain itself, who seeks after it and wants to have it, simply because it is pain..." What is Lorem Ipsum? Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..." "There is no one who loves pain itself, who seeks after it and wants to have it, simply because it is pain..." What is Lorem Ipsum? Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..." "There is no one who loves pain itself, who seeks after it and wants to have it, simply because it is pain..." What is Lorem Ipsum? Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..." "There is no one who loves pain itself, who seeks after it and wants to have it, simply because it is pain..." What is Lorem Ipsum? Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.


<button style="background-color: blue; color:white; padding: 16px">Display the inputs</button>
</div>
<!-- jQuery CDN -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

<script>

$("button").click(function(){
$('.w3-modal').show();
$('html').css('overflow', 'hidden');
 });

/* I made this solution but the result is bad sometimes works and sometimes none.

$("input").focus (function(){
$('html').css('overflow',  'scroll');
});
$('.w3-modal').scroll(function(){
$('html').css('overflow', 'hidden');
});
*/

</script>
</body>
</html>
  • Так есть какие-нибудь обновления в моем исходном коде или помощь с другим решением? заранее спасибо!
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...