html - 如何应用背景颜色

标签 html css

除了那个黄色圆圈,我想在红色边框内应用背景色。

这是我的代码并帮助我解决我的问题:

http://codepen.io/mgkrish/pen/YNwqVO

<html>
   <head>
      <title>newtab</title>
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
   <style type="text/css">
   body{
    background-color: #f5683d;
   }
    legend i{
        font-size: 52px !important;
    padding: 24px;
    padding-left: 33px;
    padding-right: 33px;
    color:#ffffff;
    background-color: #ffd200;
    border: 1px solid #ffd200;
    border-radius: 168px;
    }
    form{
        width: 300px;
        margin: 0 auto;
        background-color: #ececec; 
    }
    input{
        margin-bottom: 20px;
        width: 264px;
        height: 40px;
        text-align: center;
        border:none;
        color:#717171;
    }
    a{
        padding-left: 29%;
        text-decoration: none;
        color:#f5683d;
    }
    #loginbutton{
        background-color: #4591fb;
         color:#ececec;

    }
    fieldset{
        margin-right: 0;
        margin-left: 0;
      border-color:red;
    }
   </style>
   </head>
<body>

<form>
 <fieldset>
  <legend style="margin:0 auto;"><i class="fa fa-user"></i></legend>
  <div>
  <h1 style="font-size: 29PX; color:#717171;text-align: center;"> Member Login</h1>
  <input type="name" name="username" placeholder="username" >
  <br>
 <input type="password" name="pswd" placeholder="password" >
 <br>
  <input type="button" value="LOGIN" id="loginbutton" >
  <a href="#">Forgot Password?</a>

 </div>
</form>

</body>

在此先感谢您的帮助。

最佳答案

您需要将定义 background-color: #ececec;form 移动到 fieldset

http://codepen.io/anon/pen/EZPKRo

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

             <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
   <style type="text/css">
   body{
    background-color: #f5683d;
   }
    legend i{
        font-size: 52px !important;
    padding: 24px;
    padding-left: 33px;
    padding-right: 33px;
    color:#ffffff;
    background-color: #ffd200;
    border: 1px solid #ffd200;
    border-radius: 168px;
    }
    form{
        width: 300px;
        margin: 0 auto;
    }
    input{
        margin-bottom: 20px;
        width: 264px;
        height: 40px;
        text-align: center;
        border:none;
        color:#717171;
    }
    a{
        padding-left: 29%;
        text-decoration: none;
        color:#f5683d;
    }
    #loginbutton{
        background-color: #4591fb;
         color:#ececec;

    }
    fieldset{
        margin-right: 0;
        margin-left: 0;
      border-color:red;
            background-color: #ececec; 
    }
   </style>
   </head>
<body>

<form>
 <fieldset>
  <legend style="margin:0 auto;"><i class="fa fa-user"></i></legend>
  <div>
  <h1 style="font-size: 29PX; color:#717171;text-align: center;"> Member Login</h1>
  <input type="name" name="username" placeholder="username" >
  <br>
 <input type="password" name="pswd" placeholder="password" >
 <br>
  <input type="button" value="LOGIN" id="loginbutton" >
  <a href="#">Forgot Password?</a>

 </div>
</form>

</body>

关于html - 如何应用背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41571261/

相关文章:

html - 设置中心位置的 margin-left 和 margin-right

javascript - 在悬停时更改背景图像时防止浏览器闪烁

javascript - 在响应式 div 中居中 div 的最佳方式

html - Font-Face - 你能引用 HTML 中的路径吗?

javascript - 以纯文本或 XML 形式解析 HTML

jquery - 鼠标悬停时交叉淡入淡出 div

html - CSS 表格,显示内容的反转顺序

html - 跨浏览器双边框/内轮廓

javascript - 如何在 JavaScript 中删除 blob 文件?

html - 如何使描述列表中的不同定义彼此相邻 float ?