首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >单选按钮窗体的CSS样式

问单选按钮窗体的CSS样式
EN

Stack Overflow用户
提问于 2021-03-26 07:04:42
回答 1查看 31关注 0票数 0

我希望我的标签右对齐,但它弄乱了我的单选按钮。我需要按钮和标签更接近,这两个选项应该更接近。我试过很多方法,但似乎都做不对。表单的当前外观如下所示:

​

​

任何帮助都将不胜感激。

下面是单选按钮的HTML外观

​

代码语言:javascript
复制
#wrapper {
        width: 50%;
        margin-left:4%;
    }
    div#formcol1 {
        float:left; 
        width: 100%;
        line-height: 1em;
        padding-bottom: 15px;
    }
    label {
        margin-right: .3em;
        width: 6.3em;  /* I made this deliberately wide – come up with your own optimal width */
        margin-top: 10px;
        display: inline-block; /* width will not work for “inline” elements such as “label”. Therefore we need to set it to “inline-block” */
        text-align: right;
    }
    #formcol1 li {
        list-style:none;
        line-height: 1.5;
        margin: 5px
    }
    input[type=text]{
        width: 40%;
        padding: 0 20px;
    
    }
    input[type=radio] {
        margin-top: 10px;
        margin-left: 0px;
        margin-right: 5px;
    }
    /* adds highlights to current fields */
    input[type=text]:focus, textarea:focus {
        box-shadow: 0 0 5px rgba(81, 203, 238, 1);
        padding: 3px 0px 3px 3px;
        margin: 5px 1px 3px 0px;
        border: 5px solid rgba(81, 203, 238, 1);
代码语言:javascript
复制
<div id="multchoice">
    <fieldset>
    <legend>Type of Presentation</legend>
        <p><span><input value = "1" id = "TypeofPres_lec" name="p-type" type = "radio" /> 
            <label for = "TypeofPres_lec">Lecture</label></span>
           
            <span><input value = "2" id = "TypeofPres_lab" name="p-type" type = "radio" /> 
                <label for = "TypeofPres_lab">Lab</label></span></p>     
    </fieldset> 

    <p class="submit-button">    
        <input type="submit" value="Submit your proposal" /></p>
</div> <!-- end of multchoice div -->

​

EN

回答 1

Stack Overflow用户

发布于 2021-03-26 07:08:07

尝试将您的输入放在标签标记内。

​

代码语言:javascript
复制
  #wrapper {
  width: 50%;
  margin-left: 4%;
}

div#formcol1 {
  float: left;
  width: 100%;
  line-height: 1em;
  padding-bottom: 15px;
}

label {
  margin-right: .3em;
  width: 6.3em;
  /* I made this deliberately wide – come up with your own optimal width */
  margin-top: 10px;
  display: inline-block;
  /* width will not work for “inline” elements such as “label”. Therefore we need to set it to “inline-block” */
  text-align: right;
}

#formcol1 li {
  list-style: none;
  line-height: 1.5;
  margin: 5px
}

input[type=text] {
  width: 40%;
  padding: 0 20px;
}

input[type=radio] {
  margin-top: 10px;
  margin-left: 0px;
  margin-right: 5px;
}


/* adds highlights to current fields */

input[type=text]:focus,
textarea:focus {
  box-shadow: 0 0 5px rgba(81, 203, 238, 1);
  padding: 3px 0px 3px 3px;
  margin: 5px 1px 3px 0px;
  border: 5px solid rgba(81, 203, 238, 1);
代码语言:javascript
复制
<div id="multchoice">
  <fieldset>
    <legend>Type of Presentation</legend>
    <p><span>
    <label for = "TypeofPres_lec">
<input value = "1" id = "TypeofPres_lec" name="p-type" type = "radio" /> Lecture
</label>

<label for = "TypeofPres_lab">
<input value = "2" id = "TypeofPres_lab" name="p-type" type = "radio" /> Lab 
</label>
    </span></p>
  </fieldset>

  <p class="submit-button">
    <input type="submit" value="Submit your proposal" /></p>

​

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66808791

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档