java - 表单填充历史数据后如何更改表单背景?

标签 java php html css

在填充历史数据后如何更改表单的背景。仅在 Mozilla 中一切正常,输入背景在填充或(自动填充)历史数据后变为黄色,而在 Chrome 中则变为蓝色。我希望在每种情况下都将其设置为白色。以下是已放置表单的 index.php 中的代码:

<?php
    session_start();
    if(isset($_SESSION['zalogowany'])&&$_SESSION['zalogowany']==true)
    {   
    header('Location:panel.php');
    exit();
    }
?>

<!Doctype HTML>
<html lang="pl">
    <head>
        <link href="style.css" rel="stylesheet">
        <meta charset="utf-8"/>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
        <title>Bukowski-panel sprzedaży</title>
    </head>
    <body>
        <div class="flex-box">
            <div class="form-container">
                <form action="zaloguj.php" method="post">
                    <input type="text" name="login" placeholder="login" onfocus="this.placeholder=''" onblur="this.placeholder='login'">
                    <input type="password" name="haslo" placeholder="haslo" onfocus="this.placeholder=''" onblur="this.placeholder='haslo'">
                    <input id="submit "type="submit" value="zaloguj się">
                </form>
                <div class="logo">Bukowski</div>
                <div class="blad">
                        <?php
                        if(isset($_SESSION['blad']))
                            echo $_SESSION['blad'];
                        ?>
                </div>
            </div>
        </div>
    </body>
</html>

这里是 CSS 文件中的代码,其中表单已设置样式:

body{
    background-image: url("img/black_twill.png");
    color: white;
    font-size: 20px;
}
@font-face
{
    src: url(mistral.ttf);
    font-family: mistral;
}
.form-container
{
    background-color: white;
    width: 350px;
    text-align: center;
    padding-top: 35px;
    -webkit-box-shadow: inset 0px 0px 5px 11px rgba(0,0,0,0.98);
    -moz-box-shadow: inset 0px 0px 5px 11px rgba(0,0,0,0.98);
    box-shadow: inset 0px 0px 5px 11px rgba(0,0,0,0.98);
}
.flex-box{
    display: flex;
    justify-content: center;
    min-height: calc(100vh - 20px);
    align-items: center;
}
.blad{
    min-height: 30px;
    padding-bottom:5px;
    margin:0px;
}
.logo{
    color: black;
    min-height: 30px;
    padding: 10px 0px 0px 0px;
    font-family: mistral;
    font-size: 25px;
}
input{
    width: 200px;
    border: 1px solid black;
}
input[type=text],
input[type=password]
{
    margin: 8px;
}


input[type=submit]{
    background-color: black;
    color: white;
    cursor: pointer;
    border: 2px solid black;
    padding: 3px;
    font-size: 12px;
    margin: 15px;
}
input[type=submit]:hover
{
    background-color:#222222;
}

还有一些图片来说明我的意思: enter image description here

enter image description here

最佳答案

试试这个:

input:-webkit-autofill {
  -webkit-box-shadow:0 0 0 50px white inset; /* Change the color to your own 
  background color */
  -webkit-text-fill-color: #333;
}

input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 50px white inset;/*your box-shadow*/
  -webkit-text-fill-color: #333;
} 

body {
  background-image: url("img/black_twill.png");
  color: white;
  font-size: 20px;
}

@font-face {
  src: url(mistral.ttf);
  font-family: mistral;
}

.form-container {
  background-color: white;
  width: 350px;
  text-align: center;
  padding-top: 35px;
  -webkit-box-shadow: inset 0px 0px 5px 11px rgba(0, 0, 0, 0.98);
  -moz-box-shadow: inset 0px 0px 5px 11px rgba(0, 0, 0, 0.98);
  box-shadow: inset 0px 0px 5px 11px rgba(0, 0, 0, 0.98);
}

.flex-box {
  display: flex;
  justify-content: center;
  min-height: calc(100vh - 20px);
  align-items: center;
}

.blad {
  min-height: 30px;
  padding-bottom: 5px;
  margin: 0px;
}

.logo {
  color: black;
  min-height: 30px;
  padding: 10px 0px 0px 0px;
  font-family: mistral;
  font-size: 25px;
}

input {
  width: 200px;
  border: 1px solid black;
}

input[type=text],
input[type=password] {
  margin: 8px;
}

input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 50px white inset;
  /* Change the color to your own background color */
  -webkit-text-fill-color: #333;
}

input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 50px white inset;
  /*your box-shadow*/
  -webkit-text-fill-color: #333;
}

input[type=submit] {
  background-color: black;
  color: white;
  cursor: pointer;
  border: 2px solid black;
  padding: 3px;
  font-size: 12px;
  margin: 15px;
}

input[type=submit]:hover {
  background-color: #222222;
}
<html lang="pl">

<head>
  <link href="style.css" rel="stylesheet">
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <title>Bukowski-panel sprzedaży</title>
</head>

<body>
  <div class="flex-box">
    <div class="form-container">
      <form action="zaloguj.php" method="post">
        <input type="text" name="login" placeholder="login" onfocus="this.placeholder=''" onblur="this.placeholder='login'">
        <input type="password" name="haslo" placeholder="haslo" onfocus="this.placeholder=''" onblur="this.placeholder='haslo'">
        <input id="submit " type="submit" value="zaloguj się">
      </form>
      <div class="logo">Bukowski</div>
      <div class="blad">
        <?php
                        if(isset($_SESSION['blad']))
                            echo $_SESSION['blad'];
                        ?>
      </div>
    </div>
  </div>
</body>

</html>

关于java - 表单填充历史数据后如何更改表单背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61452790/

相关文章:

php - laravel 6 + elasticsearch-php 7.6 + xampp : No alive nodes found in your cluster

html - 样式表 "path/to/font-awesome/css/font-awesome-min.css"未加载,因为它的 MIME 类型 text/html 不是 text/css

html - 100% 宽度的 HTML 元素问题

java - 原因: unable to find valid certification path to requested target

java - 获取 "$ is not defined"

java - java jar文件输出上的php exec是空数组

php - HTML5日期输入,保存到MySQL数据库

javascript - onchange html 值返回后 select2 不起作用

java - 在 webview 中显示博客

java - 如何将成员变量与接口(interface)和匿名实现一起使用