2017-06-22 80 views
0

因此,我正在開發一個電子郵件簽名創建器,並且我製作了自己的單選按鈕(我不喜歡普通的按鈕)。我基於this post。我希望它們看起來相似,所以我或多或少地複製它們,以便我希望得到相同的結果。我調整了他們的大小,並使用他們的功能,最終我得到了這個:Radio Buttons。我喜歡它們,但它們太靠近了。你絕對可以看到,當你看到它的其餘部分:自定義單選按鈕沒有正確放置

Rest of picture

正如你所看到的,按鈕靠得太近。我希望他們分開一點(不管我想要他們多少),但是當我嘗試rightmargin-right和其他東西時,他們透露了他們背後實際無聊的舊輸入。

任何想法?這裏是我的整個程序代碼至今:

$(function() { 
 
    $("#editorTextInfoName").keyup(function() { 
 
    var infoNameTextValue = $("#editorTextInfoName").val(); 
 
    $("#fullName").text(infoNameTextValue); 
 
    }); 
 
    $("#editorTextInfoJob").keyup(function() { 
 
    var infoJobTextValue = $("#editorTextInfoJob").val(); 
 
    $("#jobText").text(infoJobTextValue); 
 
    }); 
 
});
table { 
 
    display: inline-block; 
 
} 
 
#image { 
 
    width: 125px; 
 
    height: 125px; 
 
    border-radius: 50%; 
 
    margin-top: -45px; 
 
} 
 
.spacer { 
 
    width: 15px; 
 
} 
 
hr { 
 
    height: 200px; 
 
    width: 7.5px; 
 
    border-radius: 20px; 
 
    border: none; 
 
    background-color: cornflowerBlue; 
 
} 
 
#fullName { 
 
    font-family: 'Source Sans Pro', sans-serif; 
 
    font-size: 24px; 
 
    color: orange; 
 
    margin-top: -40px; 
 
    } 
 
#job { 
 
    font-family: 'Source Sans Pro', sans-serif; 
 
    font-size: 18px; 
 
    margin-top: -10px; 
 
    } 
 
#jobLocationText { 
 
    font-family: 'Source Sans Pro', sans-serif; 
 
    font-size: 16px; 
 
    margin-top: -10px; 
 
} 
 
.otherText { 
 
    color: seaGreen; 
 
} 
 
#emailAddress, #phoneNumber, #officePhoneNumber, #address, #website { 
 
    font-size: 17px; 
 
} 
 
#extra1, #extra2, #extra3, #extra4, #extra5, #extra6 { 
 
    white-space: pre-wrap; 
 
} 
 
#signatureEditorText { 
 
    font-family: 'Source Sans Pro', sans-serif; 
 
    font-size: 24px; 
 
    margin-bottom: 40px; 
 
} 
 
.editorTextInfo { 
 
    color: gray; 
 
    font-family: 'Lato', sans-serif; 
 
    font-size: 18px; 
 
    margin-bottom: 7px; 
 
    margin-right: 60px; 
 
} 
 
.editorTextBox { 
 
    font-family: 'Source Sans Pro', sans-serif; 
 
    margin-right: 60px; 
 
    margin-bottom: 20px; 
 
    font-size: 16px; 
 
    height: 20px; 
 
    width: 160px; 
 
    border: 2px solid darkGray; 
 
    border-radius: 6px; 
 
} 
 
.editorTextBox:focus { 
 
    outline: 0; 
 
} 
 
input[type = "radio"]:after { 
 
    width: 25px; 
 
    height: 25px; 
 
    border-radius: 50%; 
 
    top: -12px; 
 
    right: 6px; 
 
    margin-right: 50px; 
 
    background-color: darkGray; 
 
    content: ""; 
 
    position: relative; 
 
    display: inline-block; 
 
} 
 
input[type = "radio"]:hover { 
 
    cursor: pointer; 
 
} 
 
input[type = "radio"]:checked:after { 
 
    width: 25px; 
 
    height: 25px; 
 
    border-radius: 50%; 
 
    background-color: orange; 
 
    top: -12px; 
 
    right: 6px; 
 
    content: ""; 
 
    position: relative; 
 
    display: inline-block; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<!DOCTYPE html> 
 
<html> 
 
    <head> 
 
     <meta charset="utf-8"> 
 
     <meta name="viewport" content="width=device-width"> 
 
     <link rel="icon" href="Logo.ico"> 
 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> 
 
     <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro" rel="stylesheet"> 
 
     <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet"> 
 
     <title>HTML Hub</title> 
 
     <link href="index.css" rel="stylesheet" type="text/css"/> 
 
    </head> 
 
    <body> 
 
     <center> 
 
     <table cellpadding="0" cellspacing="0" border="0" style="background: none; border-width: 0px; border: 0px; margin: 0; padding: 0;"> 
 
      <tr> 
 
      <td> 
 
       <center> 
 
       <img src="https://vignette2.wikia.nocookie.net/mafiagame/images/2/23/Unknown_Person.png/revision/latest?cb=20151119092211" id="image" title="Picture to be displayed"> 
 
       </center> 
 
      </td> 
 
      <td class="spacer"></td> 
 
      <td rowspan="4"> 
 
       <hr> 
 
      </td> 
 
      <td class="spacer"></td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <center> 
 
       <div id="fullName">Billy Staples</div> 
 
       </center> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <center> 
 
       <div id="job"><i id = "jobText">Programmer</i></div> 
 
       </center> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <center> 
 
       <div id="jobLocationText">at <b id="jobLocation">My Company</b></div> 
 
       </center> 
 
      </td> 
 
      </tr> 
 
     </table> 
 
     <table id="contactInfo" cellpadding="0" cellspacing="0" border="0" style="background: none; border-width: 0px; border: 0px; margin: 0; padding: 0;"> 
 
      <tr> 
 
      <td> 
 
       <div id="emailAddress"><span class="otherText">Email: </span><span id="emailAddressText">[email protected]</span></div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div id="phoneNumber"><span class="otherText">Phone: </span><span id="phoneNumberFirst">111</span>-<span id="phoneNumberSecond">222</span>-<span id="phoneNumberThird">3333</span></div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div id="officePhoneNumber"><span class="otherText">Office Phone: </span><span id="officePhoneNumberFirst">444</span>-<span id="officePhoneNumberSecond">555</span>-<span id="officePhoneNumberThird">6666</span></div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div id="address"><span class="otherText">Address: </span><span id="addressText">1379 Philadelphia Avenue</span></div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div id="website"><span class="otherText">Website: </span><span id="websiteText">example.com</span></div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div id="extra1"><span class="otherText" id="extra1Label"></span><span id="extra1Text"> </span></div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div id="extra2"><span class="otherText" id="extra2Label"></span><span id="extra2Text"> </span></div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div id="extra3"><span class="otherText" id="extra3Label"></span><span id="extra3Text"> </span></div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div id="extra4"><span class="otherText" id="extra4Label"></span><span id="extra4Text"> </span></div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div id="extra5"><span class="otherText" id="extra5Label"></span><span id="extra5Text"> </span></div> 
 
      </td> 
 
      </tr> 
 
     </table> 
 
     </center> 
 
     &nbsp; 
 
     <p></p> 
 
     <table id = "editTable" cellpadding="0" cellspacing="0" border="0" style="background: none; border-width: 0px; border: 0px; margin: 0; padding: 0;"> 
 
      <tr> 
 
      <td> 
 
       <div id = "signatureEditorText">Signature Editor</div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div class = "editorTextInfo">Name</div> 
 
      </td> 
 
      <td> 
 
       <div class = "editorTextInfo">Job</div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <input id = "editorTextInfoName" type = "text" class = "editorTextBox"> 
 
      </td> 
 
      <td> 
 
       <input id = "editorTextInfoJob" type = "text" class = "editorTextBox"> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div class = "editorTextInfo">Company</div> 
 
      </td> 
 
      <td> 
 
       <div class = "editorTextInfo">At/At the</div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <input id = "editorTextInfoCompany" type = "text" class = "editorTextBox"> 
 
      </td> 
 
      <td> 
 
       <input name = "radio" id = "editorRadioInfoCompany1" type = "radio" class = "editorRadio"> 
 
       <input name = "radio" id = "editorRadioInfoCompany2" type = "radio" class = "editorRadio"> 
 
      </td> 
 
      </tr> 
 
     </table> 
 
    </body> 
 
</html>

謝謝!

+0

對於額外的信息,爲什麼我有一個單選按鈕*在/在*是因爲有些時候,你可能會工作*在*空白,而其他時候,你可能會奏效*在*空白。 – CyanCoding

+0

您是否嘗試過輸入收音機的保證金? – XYZ

+0

我做到了。我相信我在這個問題中說過,我試着用'margin-right'將它右移。 – CyanCoding

回答

1

代碼之間添加& NBSP單選按鈕如見於以下代碼段

$(function() { 
 
    $("#editorTextInfoName").keyup(function() { 
 
    var infoNameTextValue = $("#editorTextInfoName").val(); 
 
    $("#fullName").text(infoNameTextValue); 
 
    }); 
 
    $("#editorTextInfoJob").keyup(function() { 
 
    var infoJobTextValue = $("#editorTextInfoJob").val(); 
 
    $("#jobText").text(infoJobTextValue); 
 
    }); 
 
});
table { 
 
    display: inline-block; 
 
} 
 
#image { 
 
    width: 125px; 
 
    height: 125px; 
 
    border-radius: 50%; 
 
    margin-top: -45px; 
 
} 
 
.spacer { 
 
    width: 15px; 
 
} 
 
hr { 
 
    height: 200px; 
 
    width: 7.5px; 
 
    border-radius: 20px; 
 
    border: none; 
 
    background-color: cornflowerBlue; 
 
} 
 
#fullName { 
 
    font-family: 'Source Sans Pro', sans-serif; 
 
    font-size: 24px; 
 
    color: orange; 
 
    margin-top: -40px; 
 
    } 
 
#job { 
 
    font-family: 'Source Sans Pro', sans-serif; 
 
    font-size: 18px; 
 
    margin-top: -10px; 
 
    } 
 
#jobLocationText { 
 
    font-family: 'Source Sans Pro', sans-serif; 
 
    font-size: 16px; 
 
    margin-top: -10px; 
 
} 
 
.otherText { 
 
    color: seaGreen; 
 
} 
 
#emailAddress, #phoneNumber, #officePhoneNumber, #address, #website { 
 
    font-size: 17px; 
 
} 
 
#extra1, #extra2, #extra3, #extra4, #extra5, #extra6 { 
 
    white-space: pre-wrap; 
 
} 
 
#signatureEditorText { 
 
    font-family: 'Source Sans Pro', sans-serif; 
 
    font-size: 24px; 
 
    margin-bottom: 40px; 
 
} 
 
.editorTextInfo { 
 
    color: gray; 
 
    font-family: 'Lato', sans-serif; 
 
    font-size: 18px; 
 
    margin-bottom: 7px; 
 
    margin-right: 60px; 
 
} 
 
.editorTextBox { 
 
    font-family: 'Source Sans Pro', sans-serif; 
 
    margin-right: 60px; 
 
    margin-bottom: 20px; 
 
    font-size: 16px; 
 
    height: 20px; 
 
    width: 160px; 
 
    border: 2px solid darkGray; 
 
    border-radius: 6px; 
 
} 
 
.editorTextBox:focus { 
 
    outline: 0; 
 
} 
 
input[type = "radio"]:after { 
 
    width: 25px; 
 
    height: 25px; 
 
    border-radius: 50%; 
 
    top: -12px; 
 
    right: 6px; 
 
    margin-right: 50px; 
 
    background-color: darkGray; 
 
    content: ""; 
 
    position: relative; 
 
    display: inline-block; 
 
} 
 
input[type = "radio"]:hover { 
 
    cursor: pointer; 
 
} 
 
input[type = "radio"]:checked:after { 
 
    width: 25px; 
 
    height: 25px; 
 
    border-radius: 50%; 
 
    background-color: orange; 
 
    top: -12px; 
 
    right: 6px; 
 
    content: ""; 
 
    position: relative; 
 
    display: inline-block; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<!DOCTYPE html> 
 
<html> 
 
    <head> 
 
     <meta charset="utf-8"> 
 
     <meta name="viewport" content="width=device-width"> 
 
     <link rel="icon" href="Logo.ico"> 
 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> 
 
     <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro" rel="stylesheet"> 
 
     <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet"> 
 
     <title>HTML Hub</title> 
 
     <link href="index.css" rel="stylesheet" type="text/css"/> 
 
    </head> 
 
    <body> 
 
     <center> 
 
     <table cellpadding="0" cellspacing="0" border="0" style="background: none; border-width: 0px; border: 0px; margin: 0; padding: 0;"> 
 
      <tr> 
 
      <td> 
 
       <center> 
 
       <img src="https://vignette2.wikia.nocookie.net/mafiagame/images/2/23/Unknown_Person.png/revision/latest?cb=20151119092211" id="image" title="Picture to be displayed"> 
 
       </center> 
 
      </td> 
 
      <td class="spacer"></td> 
 
      <td rowspan="4"> 
 
       <hr> 
 
      </td> 
 
      <td class="spacer"></td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <center> 
 
       <div id="fullName">Billy Staples</div> 
 
       </center> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <center> 
 
       <div id="job"><i id = "jobText">Programmer</i></div> 
 
       </center> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <center> 
 
       <div id="jobLocationText">at <b id="jobLocation">My Company</b></div> 
 
       </center> 
 
      </td> 
 
      </tr> 
 
     </table> 
 
     <table id="contactInfo" cellpadding="0" cellspacing="0" border="0" style="background: none; border-width: 0px; border: 0px; margin: 0; padding: 0;"> 
 
      <tr> 
 
      <td> 
 
       <div id="emailAddress"><span class="otherText">Email: </span><span id="emailAddressText">[email protected]</span></div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div id="phoneNumber"><span class="otherText">Phone: </span><span id="phoneNumberFirst">111</span>-<span id="phoneNumberSecond">222</span>-<span id="phoneNumberThird">3333</span></div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div id="officePhoneNumber"><span class="otherText">Office Phone: </span><span id="officePhoneNumberFirst">444</span>-<span id="officePhoneNumberSecond">555</span>-<span id="officePhoneNumberThird">6666</span></div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div id="address"><span class="otherText">Address: </span><span id="addressText">1379 Philadelphia Avenue</span></div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div id="website"><span class="otherText">Website: </span><span id="websiteText">example.com</span></div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div id="extra1"><span class="otherText" id="extra1Label"></span><span id="extra1Text"> </span></div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div id="extra2"><span class="otherText" id="extra2Label"></span><span id="extra2Text"> </span></div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div id="extra3"><span class="otherText" id="extra3Label"></span><span id="extra3Text"> </span></div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div id="extra4"><span class="otherText" id="extra4Label"></span><span id="extra4Text"> </span></div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div id="extra5"><span class="otherText" id="extra5Label"></span><span id="extra5Text"> </span></div> 
 
      </td> 
 
      </tr> 
 
     </table> 
 
     </center> 
 
     &nbsp; 
 
     <p></p> 
 
     <table id = "editTable" cellpadding="0" cellspacing="0" border="0" style="background: none; border-width: 0px; border: 0px; margin: 0; padding: 0;"> 
 
      <tr> 
 
      <td> 
 
       <div id = "signatureEditorText">Signature Editor</div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div class = "editorTextInfo">Name</div> 
 
      </td> 
 
      <td> 
 
       <div class = "editorTextInfo">Job</div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <input id = "editorTextInfoName" type = "text" class = "editorTextBox"> 
 
      </td> 
 
      <td> 
 
       <input id = "editorTextInfoJob" type = "text" class = "editorTextBox"> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <div class = "editorTextInfo">Company</div> 
 
      </td> 
 
      <td> 
 
       <div class = "editorTextInfo">At/At the</div> 
 
      </td> 
 
      </tr> 
 
      <tr> 
 
      <td> 
 
       <input id = "editorTextInfoCompany" type = "text" class = "editorTextBox"> 
 
      </td> 
 
      <td> 
 
       <input name = "radio" id = "editorRadioInfoCompany1" type = "radio" class = "editorRadio"> &nbsp;&nbsp;&nbsp; 
 
       <input name = "radio" id = "editorRadioInfoCompany2" type = "radio" class = "editorRadio"> 
 
      </td> 
 
      </tr> 
 
     </table> 
 
    </body> 
 
</html>

2

給輸入本身(不是:元素「後」)一些餘量,應該解決問題。是這樣的:

input[type = "radio"] { margin:5px }