【问题标题】:How to make the radio button background and border color different如何使单选按钮背景和边框颜色不同
【发布时间】:2022-01-23 02:14:08
【问题描述】:

.radio-f{
   border: 1px solid #ccc !important;
    border-radius: 50px !important;
    padding-top: 10px !important;
    background-color: #EDEDED !important;
    color: #808080;
    display: flex !important;
    justify-content: space-around !important;
    align-items: baseline !important;

}
<!DOCTYPE html>
<html lang="en">
<head>
   <head>
      <!-- Google Font -->
      <style>
        @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;500&display=swap');
      </style>
      <!-- Latest compiled and minified CSS -->
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css">
      <!-- jQuery library -->
      <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js"></script>
      <!-- Popper JS -->
      <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
      <!-- Latest compiled JavaScript -->
      <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.bundle.min.js"></script>
      <!-- Font Awesome library -->
      <script src="https://use.fontawesome.com/f1e10fbba5.js"></script>
      <meta charset="UTF-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <link rel="stylesheet" href="../Assets/css/index.css">
      <link rel="stylesheet" href="../Assets/css/inst-home.css">
      <link rel="stylesheet" href="../Assets/css/tutor-register-one.css">
      <title>Pakistan Tutor - Student Register</title>
    </head>
</head>
<body>
<div class="col-lg-12">
                        <div class="row mb-5">
                           <div class="col-lg-6 mt-3">
                              
                              <div class="radio-f">
                                 <label class="entry" for="input1"><div class="circle"></div><div class="entry-label">Online</div>
                                 </label>
                                 <input type="radio" class="hidden" id="input1" name="inputs">
                              </div>
                           </div>
                           <div class="col-lg-6 mt-3">
                             
                              <div class="radio-f">
                                 <label class="entry" for="input2">
                                    <div class="circle"></div>
                                    <div class="entry-label">Offline</div>
                                 </label>
                                    <input type="radio" class="hidden" id="input2" name="inputs">
                              </div>
                           </div>
                           <div class="highlight"></div>
                           <div class="overlay"></div>
                        </div>
                     </div>
</body>
</html>






> I want the radio button color and background same as shown in the image.
I tried very much but nothig is happen.
> I want the radio button color and background same as shown in the image.
I tried very much but nothig is happen.
> I want the radio button color and background same as shown in the image.
I tried very much but nothig is happen.

【问题讨论】:

  • 请修正您的问题的格式。 sn-p 中有不属于那里的文本。该文本将不必要地格式化为引号。另外为什么有三倍相同的文字?为什么sn-p(HTML部分应该只包含&lt;body&gt;元素的内容)被包裹在一个“图像”中,这个“图像”被包裹在一个图像中?
  • How do I ask a good question?: "在发布任何代码之前介绍问题:在问题的正文中,首先扩展您在标题中的摘要。解释您是如何遇到问题的您正在尝试解决问题,以及任何阻碍您自己解决问题的困难。您问题的第一段是大多数读者会看到的第二件事,因此请使其尽可能引人入胜且内容丰富。"
  • 我无话可说,但它继续要求我写更多。我想要与图片中显示的样式相同的样式。

标签: javascript html css twitter-bootstrap


【解决方案1】:

试试这个

input[type="radio"]::after {
    width: 100%;
    height: 100%;
    border-radius: 15px;
    top: 0;
    left: 0;
    background-color: #6b6b6b;
    content: "";
    display: inline-block;
}

input[type="radio"]:checked::after {
    all: initial;
}
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <input type="radio" checked />
        <input type="radio" />
    </body>
</html>

【讨论】:

  • “试试这个” 不是答案。 OPs 版本有什么问题(尽管 OP 从未提到任何问题......)?你的答案是如何解决这个未提及的问题的?
猜你喜欢
  • 2018-11-03
  • 1970-01-01
  • 2018-07-02
  • 1970-01-01
  • 1970-01-01
  • 2013-12-04
  • 2016-06-23
  • 2014-03-18
  • 1970-01-01
相关资源
最近更新 更多