简体   繁体   English

对齐项目清单

[英]Aligning list of items

I'm having a problem getting the text that goes with a list of items - each preceded by a letter - on an online questionnaire to align properly. 我在在线调查表上获取包含项目列表的文本时遇到了问题-每个项目前都有一个字母-以便正确对齐。 In other words, I have a list that looks like this (using the letter 'o' to represent radio buttons), where with letters such as f, i, j, etc., the radio button and accompanying text are shifted slightly but noticeably to the left: 换句话说,我有一个看起来像这样的列表(使用字母“ o”表示单选按钮),其中在使用字母f,i,j等字母时,单选按钮和随附的文本稍有移动,但值得注意靠左:

a.  o Yes  o No  Asbestosis  
b.  o Yes  o No  Asthma  
c.  o Yes  o No  Chronic bronchitis  
d.  o Yes  o No  Emphysema  
e.  o Yes  o No  Pneumonia  
f.  o Yes  o No  Tuberculosis 

Here is the HTML code, leaving out the code for items b, c, d and e for brevity's sake. 这是HTML代码,为简洁起见,省略了项目b,c,d和e的代码。

<div id="question20" class="indent" style="display:block;line-height:15px">
    <span class="num-bullet">3</span>Have you <em><b>ever had</b></em> any of the following pulmonary or lung problems?
    <p class="p1">a.
    <input type="hidden" xmlTag="asbestosis" is_required='yes' id="question20a" name="question20a" number="20" prerequisite="0" section="Part A. Section 2." description="3.a. Have you had asbestosis?" />
    <input type="radio" id="20y" name="20" value="Yes" style="padding-left:5em"/>Yes
    <input type="radio" id="20n" name="20" value="No"/>No
    Asbestosis
    </p>
    <div id="div_explanation20" class="indent" style="display:none;padding-left:60px">
        <input type="text" id="explanation20" name="explanation20" number="20" xmlTag="asbestosis_explanation" size="40" maxlength="40" value="Please explain" text_label="Please explain"  section="Part A. Section 2." description="3.a. Have you had asbestosis?" /><br />
    </div>  
    <p class="p1">f.
    <input type="hidden" xmlTag="tuberculosos" is_required='yes' id="question28" name="question28" number="28" section="Part A. Section 2." description="3.i. Have you had tuberculosis?" />
    <input type="radio" id="28y" name="28" value="Yes" style="padding-left:5em"/>Yes
    <input type="radio" id="28n" name="28" value="No"/>No
    Tuberculosis
    </p>
    <div id="div_explanation28" class="indent" style="display:none;padding-left:60px">
        <input type="text" id="explanation28" name="explanation28" number="28" xmlTag="tuberculosis_explanation" size="40" maxlength="40" value="Please explain" text_label="Please explain"  section="Part A. Section 2." description="3.i. Have you had tuberculosis?" /><br />
    </div>

Here is what I believe to be the applicable CSS code: 我认为这是适用的CSS代码:

span.num-bullet { display:block; float:left; width:15px; line-height:15px; text-align:center; color:#00588a; font-size:11px; font-weight:bold; background:url(../img/numbered-bullet.gif) no-repeat; margin-right:10px;}  

p.p1 {text-indent:30px}  

form div.group div.indent {margin-left:30px; clear:left;}  

I'm in no way a CSS expert; 我绝对不是CSS专家。 novice at best. 新手充其量。 Much of this was provided by a co-worker. 其中大部分是由同事提供的。

Thanks! 谢谢!

JSFiddle JSFiddle

If I understand the issue correctly then it may be resolved by using a fixed-width or monospaced font, such as Courier New, where all characters have the same width. 如果我正确理解了该问题,则可以使用固定宽度或等宽字体(例如,Courier New)来解决此问题,其中所有字符的宽度都相同。 Otherwise characters such as i,l,f etc. may appear narrower and throw off the alignment. 否则,诸如i,l,f等字符可能会变窄并偏离对齐方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM