css - 调整图像类型单选按钮中的标签位置

标签 css html radio-button

我正在创建单选按钮,但我要调整标签位置。请帮我解决这个问题。 我的代码是:

<style>
input[type=radio]:not(old){
width   : 50px;
 margin  : 0;
 padding : 0;
 opacity : 0;
}


input[type=radio]:not(old) + label{
 display      : inline-block;
padding-left : 63px;
background   : url('radio.png') no-repeat 0 0;
line-height  : 25px;

}

input[type=radio]:not(old):checked + label{
  background-position : 0 -24px;
}

html:

<input id="radio1" type="radio" name="radio" value="1" onclick="javascript:yesnoCheck();" checked="checked"><label for="radio1">Now </label>

 
    <input id="radio2" type="radio" name="radio" onclick="javascript:yesnoCheck();"  value="2"><label for="radio2">Later</label>

请看图片,我需要将标签移到左侧

Please have a look at image, i need to move labels to the left side

最佳答案

HTML:

<input id="radio1" type="radio" name="radio" value="1" onclick="javascript:yesnoCheck();" checked="checked"><label for="radio1">Now </label>


    <input id="radio2" type="radio" name="radio" onclick="javascript:yesnoCheck();"  value="2"><label for="radio2">Later</label>

CSS:

input[type=radio]:not(old){
width   : 50px;
 margin  : 0;
 padding : 0;
 opacity : 0;
}


input[type=radio]:not(old) + label{
 display      : inline-block;
padding-left : 63px;
line-height  : 25px;
  position: relative;
}

input[type=radio]:not(old) + label:after{
  content: '';
  position: absolute;
  top: 0;
  left: 23px;
  width: 100%;
  height: 100%;
  z-index: -1;
  background   : url('radio.png') no-repeat 0 0;
}

input[type=radio]:not(old):checked + label{
  background-position : 0 -24px;
}

这有帮助吗?

关于css - 调整图像类型单选按钮中的标签位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38433588/

相关文章:

javascript - 当使用 2 种语言时,如何使用 css 反转一种语言的单词顺序?

css - 全屏背景图像(有点) - 没有裁剪?

html - 对齐 wrapper-div 内部的 content-div 元素

HTML 列表垂直对齐?

jquery - 更改单选按钮时打开关闭 div

html - jQuery 选项卡样式右缩进加载的内容

css - 使用 CSS3 飞行路径的对象的无限动画

html - 是否可以一起使用 Polymer 和 Brick?

javascript - ASP.NET 中的 JQuery 和单选按钮。点击未注册

objective-c - 不使用 NSMatrix 的 Cocoa 单选按钮可以绑定(bind)吗?