0

我目前正在学习 html/css,并想开发我的第一个 Web 表单。但是,我在将单选按钮放置在相关标签旁边时遇到问题。

这是我的jsfiddle

我假设我必须在我的 css 中创建一个 .radio 样式。但是,我不确定该怎么做。

<form id="contactform" class="rounded" method="post" action="">

<h3>Equipment Procurement Form</h3>

    <p>Use this form to submit requests to Medical Physics for new equipment</p>
    <div class="field">
        <label for="Directorate">Directorate</label>
        <input type="text" class="input" name="Directorate" id="Directorate" />
        <p class="hint">Enter your directorate.</p>
    </div>
    <div class="field">
        <label for="Department">Department:</label>
        <input type="text" class="input" name="Department" id="Department" />
        <p class="hint">Enter your department.</p>
    </div>
    <div class="field">
        <label for="Request">Equipment Requested:</label>
        <textarea class="input textarea" name="Request" id="Request"></textarea>
        <p class="hint">Summarise equipment request..</p>
    </div>

    <div class="radio">  
        <input id="Capital" type="radio" name="Capital" value="Capital">  
            <label for="Capital">Capital
                <span class="small">&#62;&pound;5000 (inc VAT)</span></label>  
        <input id="Capital" type="radio" name="Capital" value="Revenue">  
        <label for="Capital">Revenue
            <span class="small">&#60;&pound;5000 (inc VAT)</span></label>   
    </div>  

    <input type="submit" name="Submit" class="button" value="Submit" />
</form>
4

3 回答 3

2

请参阅此http://jsfiddle.net/3sPNH/13/。我希望这是你想要的。只是放在input里面。

于 2013-09-19T13:20:41.057 回答
1
<form id="contactform" class="rounded" method="post" action="">

<h3>Equipment Procurement Form</h3>

<p>Use this form to submit requests to Medical Physics for new equipment</p>
<div class="field">
    <label for="Directorate">Directorate</label>
    <input type="text" class="input" name="Directorate" id="Directorate" />
    <p class="hint">Enter your directorate.</p>
</div>
<div class="field">
    <label for="Department">Department:</label>
    <input type="text" class="input" name="Department" id="Department" />
    <p class="hint">Enter your department.</p>
</div>
<div class="field">
    <label for="Request">Equipment Requested:</label>
    <textarea class="input textarea" name="Request" id="Request"></textarea>
    <p class="hint">Summarise equipment request..</p>
</div>
<div class="radio">  
    <label><input id="Capital" type="radio" name="Capital" value="Capital">  
        Capital
            <span class="small">&#62;&pound;5000 (inc VAT)</span></label>  

    <label>
        <input id="Capital" type="radio" name="Capital" value="Revenue">
        Revenue
        <span class="small">&#60;&pound;5000 (inc VAT)</span></label>   
</div>  

<input type="submit" name="Submit" class="button" value="Submit" />

于 2013-09-19T13:22:21.607 回答
1

你把单选按钮放在标签外面,如果你把它们放进去,它会把它们固定在一起。

<div class="radio">  
        <label for="Capital">Capital
        <input id="Capital" type="radio" name="Capital" value="Capital">  
        <span class="small">&#62;&pound;5000 (inc VAT)</span></label>  

         <label for="Capital">Revenue
         <input id="Capital" type="radio" name="Capital" value="Revenue"> 
         <span class="small">&#60;&pound;5000 (inc VAT)</span></label>   
    </div>  
于 2013-09-19T13:25:00.433 回答